static BOOL VManInit(SDL_PrivateVideoData *pPVData) { CHAR achBuf[256]; ULONG ulRC; INITPROCOUT sInitProcOut; ulRC = DosLoadModule( achBuf, sizeof(achBuf), "VMAN", &hmodVMan ); if ( ulRC != NO_ERROR ) { debug( "Could not load VMAN.DLL, rc = %u : %s", ulRC, achBuf ); return FALSE; } ulRC = DosQueryProcAddr( hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry ); if ( ulRC != NO_ERROR ) { debug( "Could not query address of pfnVMIEntry function of VMAN.DLL, " "rc = %u", ulRC ); DosFreeModule( hmodVMan ); hmodVMan = NULLHANDLE; return FALSE; } sInitProcOut.ulLength = sizeof(sInitProcOut); ulRC = pfnVMIEntry( 0, VMI_CMD_INITPROC, NULL, &sInitProcOut ); if ( ulRC != RC_SUCCESS ) { debug( "Could not initialize VMAN for this process" ); DosFreeModule( hmodVMan ); hmodVMan = NULLHANDLE; return FALSE; } if ( pPVData == NULL ) { // It only check VMan availability... pfnVMIEntry( 0, VMI_CMD_TERMPROC, NULL, NULL ); return TRUE; } ulVRAMAddress = sInitProcOut.ulVRAMVirt; // Set routine that run when the current process ends, before PM-related // internal procedure. ulRC = DosExitList( EXLST_ADD | 0x00009900, // Before Presentation Manager (0xA0 - 0xA8) _AtExit ); return TRUE; }
void DrvMountDrivesThread( void * hev) { ULONG rc; HMODULE hmod = 0; pRediscover_PRMs pfn = 0; char * pErr = 0; char szErr[16]; rc = DosLoadModule( szErr, sizeof(szErr), "LVM", &hmod); if (rc) pErr = "DosLoadModule"; else { rc = DosQueryProcAddr( hmod, 0, "Rediscover_PRMs", (PFN*)&pfn); if (rc) pErr = "DosQueryProcAddr"; else { pfn( &rc); if (rc) pErr = "Rediscover_PRMs"; } rc = DosFreeModule( hmod); if (rc && !pErr) pErr = "DosFreeModule"; } if (pErr) printf( "DrvMountDrivesThread - %s - rc= %lx\n", pErr, rc); rc = DosPostEventSem( (HEV)hev); if (rc) printf( "DrvMountDrivesThread - DosPostEventSem - rc= %lx\n", rc); return; }
// RemovePlugin(hwnd, pTBData, dllName, appName, bActive) // hwnd --> Handle of the calling window // pTBData --> Pointer to the titlebar's CandyBarZ data structure // index --> index of the plugin to be removed BOOL RemovePlugin( /*HWND hwnd, */ CBZDATA *pCBZData, int index) { //remove the plugin from the given index, and move all plugins below it up 1 int i, count; if ((index >= pCBZData->cbPlugins) || (index < 0)) return (FALSE); count = pCBZData->cbPlugins; //free resources of removed plugin if (pCBZData->Plugins[index].hModDll != NULLHANDLE) DosFreeModule(pCBZData->Plugins[index].hModDll); //should call the CBZDestroy Function here instead! if (pCBZData->Plugins[index].pData != NULL) DosFreeMem(pCBZData->Plugins[index].pData); //move the lower plugins up 1 for (i = index; i < count; i++) { SwapPlugins(pCBZData, i, i + 1); } //update the plugin count pCBZData->cbPlugins--; return (TRUE); }
BOOL Settings :: ReloadResources (PSZ psz) { if (g_hmod) DosFreeModule(g_hmod); APIRET rc; if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod))) { DisplayError("ERROR", "Could not (re)load Gotcha! resource module " "'%s' (DosLoadModule() return code %d). First make sure the DLL is in the LIBPATH. If this is the case, try to delete " "GOTCHA.INI and start Gotcha! again. If it does not work " "then, contact the author ([email protected]).", psz, rc); exit(1); } ResourceString::Module(g_hmod); pszPageTab[0] = RSTR (IDS_PAGESAVE); pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT); pszPageTab[2] = RSTR (IDS_PAGEMISC); pszPageTab[3] = RSTR (IDS_PAGELANGUAGE); for( int i = 0; i < BMF_INVALID; i++ ) { ifi[ i ].label = RSTR ( IDS_BITMAP12INTERNAL+i ); } return TRUE; }
VOID ExitListRoutine( ULONG ExitReason ) { SpyDeRegister( SpyInstance ); /* De-Register with our DLL */ if ( hSwitch != NULLH ) WinRemoveSwitchEntry(hSwitch); if ( hwndFrame != NULLH ) WinDestroyWindow(hwndFrame); if ( hmq != NULLH ) WinDestroyMsgQueue(hmq); /* cleanup STRINGTABLEs loaded for us... */ FreeStringTable(sizeof(Strings) / sizeof(Strings[0]), /* max # Strings[] */ Strings); /* start of string table */ FreeStringTable(sizeof(Controls) / sizeof(Controls[0]), /* max # Controls[] */ Controls); /* start of string table */ if ( hmodNLS != 0 ) DosFreeModule(hmodNLS); if ( hab != 0 ) WinTerminate(hab); DosExitList(EXLST_EXIT, NULL); /* Indicate "done" */ }
/** * Stop all service threads and free the device chain. */ USBProxyServiceOs2::~USBProxyServiceOs2() { LogFlowThisFunc(("\n")); /* * Stop the service. */ if (isActive()) stop(); /* * Free resources. */ if (mhmod) { if (mpfnUsbDeregisterNotification) mpfnUsbDeregisterNotification(mNotifyId); mpfnUsbRegisterChangeNotification = NULL; mpfnUsbDeregisterNotification = NULL; mpfnUsbQueryNumberDevices = NULL; mpfnUsbQueryDeviceReport = NULL; DosFreeModule(mhmod); mhmod = NULLHANDLE; } }
mad_status MADSysLoad( const char *path, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { HMODULE dll; mad_init_func *init_func; mad_status status; char madname[CCHMAXPATH] = ""; char madpath[CCHMAXPATH] = ""; /* To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ strcpy( madname, path ); strcat( madname, ".D32" ); _searchenv( madname, "PATH", madpath ); if( madpath[0] == '\0' || DosLoadModule( NULL, 0, madpath, &dll ) != 0 ) { return( MS_ERR|MS_FOPEN_FAILED ); } status = MS_ERR|MS_INVALID_MAD; if( DosQueryProcAddr( dll, 0, "MADLOAD", (PFN FAR *)&init_func ) == 0 && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = dll; return( MS_OK ); } DosFreeModule( dll ); return( status ); }
HB_BOOL hb_libFree( PHB_ITEM pDynLib ) { HB_BOOL fResult = HB_FALSE; void ** pDynLibPtr = ( void ** ) hb_itemGetPtrGC( pDynLib, &s_gcDynlibFuncs ); if( pDynLibPtr && *pDynLibPtr && hb_vmLockModuleSymbols() ) { void * hDynLib = *pDynLibPtr; if( hDynLib ) { *pDynLibPtr = NULL; hb_vmExitSymbolGroup( hDynLib ); #if defined( HB_OS_WIN ) fResult = FreeLibrary( ( HMODULE ) hDynLib ); #elif defined( HB_OS_OS2 ) fResult = DosFreeModule( ( HMODULE ) hDynLib ) == NO_ERROR; #elif defined( HB_HAS_DLFCN ) fResult = dlclose( hDynLib ) == 0; #elif defined( HB_CAUSEWAY_DLL ) FreeLibrary( hDynLib ); fResult = HB_TRUE; #endif } hb_vmUnlockModuleSymbols(); } return fResult; }
/* Depending on GBM.DLL version the number of pages can be retrieved (versions > 1.35) * or the functionality does not yet exist. * * Dynamically link the specific function to support also older versions of GBM.DLL. */ gbm_boolean SupportsNumberOfPagesQuery(void) { #if defined(__OS2__) || defined(OS2) HMODULE hmod; PFN functionAddr = NULL; APIRET rc = 0; /* check version first */ if (gbm_version() < 135) { return GBM_FALSE; } /* now dynamically link GBM.DLL */ rc = DosLoadModule("", 0, "GBM", &hmod); if (rc) { return GBM_FALSE; } /* lookup gbm_read_imgcount() */ rc = DosQueryProcAddr(hmod, 0L, "gbm_read_imgcount", &functionAddr); DosFreeModule(hmod); return rc ? GBM_FALSE : GBM_TRUE; #else /* On all other platforms we assume so far that the correct lib is there. */ return GBM_TRUE; #endif }
/* free dynamically-linked library */ int dlclose(void *handle) { int rc; DLLchain tmp = find_id(handle); if (!tmp) goto inv_handle; switch (rc = DosFreeModule(tmp->handle)) { case NO_ERROR: free(tmp->name); dlload = tmp->next; free(tmp); return 0; case ERROR_INVALID_HANDLE: inv_handle: strcpy(dlerr, "invalid module handle"); return -1; case ERROR_INVALID_ACCESS: strcpy(dlerr, "access denied"); return -1; default: return -1; } }
/* *************************************************************** */ void _catcher(bundle s) { char msg[512]; char *b[4]; HMODULE hmod; PFNWP DlgProc; int c = 0, bx = 0; if (msgHead != NULL) { for (msg[0] = '\0'; *msgHead != NULL; ++msgHead) strcat(msg,*msgHead); b[bx++] = msg; c = strlen(msg) + 1; } for (msg[c] = '\0'; *s != NULL; ++s) strcat(&msg[c],*s); b[bx++] = &msg[c]; b[bx++] = "Application will terminate now"; b[bx] = NULL; if (DosLoadModule(NULL, 0, "GPRTS", &hmod) || DosQueryProcAddr(hmod, 0, "DlgProc", (PFN *)&DlgProc)) WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to load error message","GPM Fatal Error", 0, MB_ICONHAND | MB_OK); else { WinAlarm(HWND_DESKTOP, WA_ERROR); WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DlgProc, hmod, GPRTS_DLG, b); DosFreeModule(hmod); } DosExit(EXIT_PROCESS, 0); }
// Obtains all of the information currently available for this plugin. nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info) { nsresult rv = NS_ERROR_FAILURE; HMODULE hPlug = 0; // Need a HMODULE to query resource statements char failure[ CCHMAXPATH] = ""; APIRET ret; nsCAutoString path; if (NS_FAILED(rv = mPlugin->GetNativePath(path))) return rv; nsCAutoString fileName; if (NS_FAILED(rv = mPlugin->GetNativeLeafName(fileName))) return rv; ret = DosLoadModule( failure, CCHMAXPATH, path.get(), &hPlug); info.fVersion = nsnull; while( ret == NO_ERROR) { info.fName = LoadRCDATAString( hPlug, NS_INFO_ProductName); info.fVersion = LoadRCDATAVersion( hPlug, NS_INFO_ProductVersion); // get description (doesn't matter if it's missing)... info.fDescription = LoadRCDATAString( hPlug, NS_INFO_FileDescription); char * mimeType = LoadRCDATAString( hPlug, NS_INFO_MIMEType); if( nsnull == mimeType) break; char * mimeDescription = LoadRCDATAString( hPlug, NS_INFO_FileOpenName); if( nsnull == mimeDescription) break; char * extensions = LoadRCDATAString( hPlug, NS_INFO_FileExtents); if( nsnull == extensions) break; info.fVariantCount = CalculateVariantCount(mimeType); info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType); if( info.fMimeTypeArray == nsnull) break; info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription); if( nsnull == info.fMimeDescriptionArray) break; info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions); if( nsnull == info.fExtensionArray) break; info.fFullPath = PL_strdup(path.get()); info.fFileName = PL_strdup(fileName.get()); rv = NS_OK; break; } if( 0 != hPlug) DosFreeModule( hPlug); return rv; }
void XPCOMGlueUnload() { while (sTop) { DosFreeModule(sTop->libHandle); DependentLib *temp = sTop; sTop = sTop->next; delete temp; } if (sXULLibrary) { DosFreeModule(sXULLibrary); sXULLibrary = nsnull; } }
/* static */ void wxDynamicLibrary::Unload(wxDllType handle) { #if defined(__OS2__) || defined(__EMX__) DosFreeModule( handle ); #else #error "runtime shared lib support not implemented" #endif }
VOID IM32Term( VOID ) { if( !fIM32Inited ) return; DosFreeModule( hIM32Mod ); fIM32Inited = FALSE; }
/* Depending on GBM.DLL version the number of pages can be retrieved (versions > 1.35) * or the functionality does not yet exist. * * Dynamically link the specific function to support also older versions of GBM.DLL. */ gbm_boolean GetNumberOfPages(const char * fileName, const int fd, const int ft, int * numPages) { #if defined(__OS2__) || defined(OS2) HMODULE hmod; PFN functionAddr = NULL; APIRET rc = 0; /* check version first */ if (gbm_version() < 135) { return GBM_FALSE; } /* now dynamically link GBM.DLL */ rc = DosLoadModule("", 0, "GBM", &hmod); if (rc) { return GBM_FALSE; } /* lookup gbm_read_imgcount() */ rc = DosQueryProcAddr(hmod, 0L, "gbm_read_imgcount", &functionAddr); if (rc) { DosFreeModule(hmod); return GBM_FALSE; } /* call gbm_read_imgcount(const char *fn, int fd, int ft, int *pimgcnt) */ if (functionAddr(fileName, fd, ft, numPages) != GBM_ERR_OK) { DosFreeModule(hmod); return GBM_FALSE; } DosFreeModule(hmod); return GBM_TRUE; #else /* On all other platforms we assume so far that the correct lib is there. */ return (gbm_read_imgcount(fileName, fd, ft, numPages) != GBM_ERR_OK) ? GBM_FALSE : GBM_TRUE; #endif }
/** * Initialize data members. */ USBProxyBackendOs2::USBProxyBackendOs2(USBProxyService *aUsbProxyService, const com::Utf8Str &strId) : USBProxyBackend(aUsbProxyService, strId), mhev(NULLHANDLE), mhmod(NULLHANDLE), mpfnUsbRegisterChangeNotification(NULL), mpfnUsbDeregisterNotification(NULL), mpfnUsbQueryNumberDevices(NULL), mpfnUsbQueryDeviceReport(NULL) { LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService)); /* * Try initialize the usbcalls stuff. */ int rc = DosCreateEventSem(NULL, &mhev, 0, FALSE); rc = RTErrConvertFromOS2(rc); if (RT_SUCCESS(rc)) { rc = DosLoadModule(NULL, 0, (PCSZ)"usbcalls", &mhmod); rc = RTErrConvertFromOS2(rc); if (RT_SUCCESS(rc)) { if ( (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryNumberDevices", (PPFN)&mpfnUsbQueryNumberDevices)) == NO_ERROR && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryDeviceReport", (PPFN)&mpfnUsbQueryDeviceReport)) == NO_ERROR && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbRegisterChangeNotification", (PPFN)&mpfnUsbRegisterChangeNotification)) == NO_ERROR && (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbDeregisterNotification", (PPFN)&mpfnUsbDeregisterNotification)) == NO_ERROR ) { rc = mpfnUsbRegisterChangeNotification(&mNotifyId, mhev, mhev); if (!rc) { /* * Start the poller thread. */ rc = start(); if (RT_SUCCESS(rc)) { LogFlowThisFunc(("returns successfully - mNotifyId=%d\n", mNotifyId)); mLastError = VINF_SUCCESS; return; } } LogRel(("USBProxyServiceOs2: failed to register change notification, rc=%d\n", rc)); } else LogRel(("USBProxyServiceOs2: failed to load usbcalls\n")); DosFreeModule(mhmod); } else LogRel(("USBProxyServiceOs2: failed to load usbcalls, rc=%d\n", rc)); mhmod = NULLHANDLE; } else mhev = NULLHANDLE; mLastError = rc; LogFlowThisFunc(("returns failure!!! (rc=%Rrc)\n", rc)); }
/* static */ void wxDynamicLibrary::Unload(wxDllType handle) { #if defined(__WXPM__) || defined(__EMX__) DosFreeModule( handle ); #elif defined(__WXMAC__) && !defined(__DARWIN__) CloseConnection( (CFragConnectionID*) &handle ); #else #error "runtime shared lib support not implemented" #endif }
short UnLoadMMPM( void ) { if( !mmpmInstalled ) return 0; mmpmInstalled = 0; DosFreeModule( MMOS2Handle ); MMOS2Handle = NULLHANDLE; return 1; }
int unload_pstotext(void) { if (pstotextInstance) dllfn_pstotextExit(pstotextInstance); pstotextInstance = NULL; if (pstotextModule) DosFreeModule(pstotextModule); pstotextModule = (HMODULE)NULL; return 0; }
APIRET DeInitializeXPIStub() { pfnXpiInit = NULL; pfnXpiInstall = NULL; pfnXpiExit = NULL; if(hXPIStubInst) DosFreeModule(hXPIStubInst); return(0); }
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { HMODULE hmodule; PFN retval = NULL; char error[256]; if (DosLoadModule(&error, sizeof(error), fname, &hmodule) == NO_ERROR) { if (DosQueryProcAddr(hmodule, 0, sym, &retval) != NO_ERROR) { DosFreeModule(hmodule); } } return (void *) retval; }
HRESULT DeInitializeXPIStub() { pfnXpiInit = NULL; pfnXpiInstall = NULL; pfnXpiExit = NULL; if(hXPIStubInst) DosFreeModule(hXPIStubInst); chdir(szSetupDir); return(0); }
void KillTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { FiniFunc(); FiniFunc = NULL; } InfoFunc = NULL; HardFunc = NULL; if( TrapFile != 0 ) { DosFreeModule( TrapFile ); TrapFile = 0; } }
static APIRET APIENTRY woDone( VOID ) { ULONG rc; free( m_hwvc.fccColorType ); WinSubclassWindow( m_hwndKVA, m_pfnwpOld ); rc = m_pfnHWVIDEOClose(); DosFreeModule( m_HWVideoHandle ); return rc; }
/** Load functions from GBM.DLL. */ static void unload_functions(HMODULE hModule, FUNCTION_TABLE_DEF * table, const int tableLength) { int i; for (i = 0; i < tableLength; i++) { table[i].functionAddress = NULL; } if (hModule != NULLHANDLE) { DosFreeModule(hModule); } }
void ErasePluginList() { WaWEPlugin_p temp; if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR) { while (PluginListHead) { temp = PluginListHead; PluginListHead=PluginListHead->pNext; DosFreeModule(temp->hmodDLL); dbg_free(temp); } DosReleaseMutexSem(PluginListProtector_Sem); } }
void Free7ZLibrary(HMODULE pModule) { APIRET rc=0; rc = DosFreeModule(pModule); if (rc) { #if defined(_OS2_LIBDEBUG) std::cerr << "DosFreeModule: unloading lib at " << pModule << " failed, (ret code: " << rc << ")" << std::endl; #endif } else { #if defined(_OS2_LIBDEBUG) std::cerr << "DosFreeModule: unloading lib at " << pModule << " succeeded. " << std::endl; #endif } free(hmod2); hmod2 = NULL; }
/** Load functions from a DLL. */ static HMODULE load_functions(PSZ moduleName, FUNCTION_TABLE_DEF * table, const int tableLength, char * foundModuleName, const int foundModuleNameLength) { int i; HMODULE moduleHandle = NULLHANDLE; UCHAR loadError[GBMVER_FILENAME_MAX+1] = { 0 }; APIRET rc = 0; /* load the module */ rc = DosLoadModule(loadError, sizeof(loadError)-1, moduleName, &moduleHandle); if (rc) { return NULLHANDLE; } /* get the full path name */ rc = DosQueryModuleName(moduleHandle, foundModuleNameLength, foundModuleName); if (rc) { DosFreeModule(moduleHandle); return NULLHANDLE; } /* get all function addresses */ for (i = 0; i < tableLength; i++) { rc = DosQueryProcAddr(moduleHandle, 0L, table[i].functionName, &table[i].functionAddress); if (rc) { table[i].functionAddress = NULL; } } return moduleHandle; }
mad_status MADSysLoad( char *path, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { HMODULE dll; mad_init_func *init_func; mad_status status; if( DosLoadModule( NULL, 0, path, &dll ) != 0 ) { return( MS_ERR|MS_FOPEN_FAILED ); } status = MS_ERR|MS_INVALID_MAD; if( DosGetProcAddr( dll, "MADLOAD", (PFN FAR *)&init_func ) == 0 && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = dll; return( MS_OK ); } DosFreeModule( dll ); return( status ); }