public WindowClass(Machine machine, Module16 module, StringOrId menuID, Win32.WNDCLASS wc32, Win16.WNDCLASS wc16) { _machine = machine; _module = module; _menuID = menuID; this.wc32 = wc32; this.wc16 = wc16; _procInstance = _machine.MakeProcInstance(module.DataSelector, wc16.lpfnWndProc); WndProc32 = _machine.Messaging.GetWndProc32(_procInstance, false); }
public ModuleBase LoadModuleInternal(string fileOrModuleName, string parentPath) { // Remove trailing '.' - VBRUN100 calls LoadLibrary("gdi.") if (fileOrModuleName.EndsWith(".")) { fileOrModuleName = fileOrModuleName.Substring(0, fileOrModuleName.Length - 1); } // Look for already loaded module with correct name ModuleBase module; if (_loadedModules.TryGetValue(fileOrModuleName, out module)) { module.LoadCount++; return(module); } // Look for module with same filename foreach (var kv in _loadedModules) { if (System.IO.Path.GetFileName(kv.Value.GetModuleFileName()).ToLowerInvariant() == fileOrModuleName.ToLowerInvariant()) { kv.Value.LoadCount++; return(kv.Value); } } // Locate the module var locatedModuleGuest = LocateModule(fileOrModuleName, parentPath); if (locatedModuleGuest == null) { throw new VirtualException(string.Format("Can't find module '{0}'", fileOrModuleName)); } // Look for already loaded module var existingModule = _loadedModules.Values.FirstOrDefault(x => x.GetModuleFileName() == locatedModuleGuest); if (existingModule != null) { existingModule.LoadCount++; return(existingModule); } // Load it var locatedModuleHost = _machine.PathMapper.MapGuestToHost(locatedModuleGuest, false); var nativeModule = new Module16(locatedModuleHost); // Log the module if (_machine.logModules) { nativeModule.NeFile.Dump(_machine.logRelocations); } // Setup the guest module filename nativeModule.SetGuestFileName(locatedModuleGuest.ToUpper()); // Load it try { LoadModule(nativeModule); return(nativeModule); } catch (VirtualException) { nativeModule.Unload(_machine); throw; } }