- Timestamp:
- Feb 20, 2003, 10:47:01 AM (23 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/windlllx.cpp
r9411 r9828 1 /* $Id: windlllx.cpp,v 1.2 6 2002-11-18 13:53:54sandervl Exp $ */1 /* $Id: windlllx.cpp,v 1.27 2003-02-20 09:47:01 sandervl Exp $ */ 2 2 3 3 /* … … 34 34 #include <wprocess.h> 35 35 #include "oslibmisc.h" 36 #include <custombuild.h> 36 37 37 38 #include <exe386.h> … … 40 41 #include "dbglocal.h" 41 42 43 /******************************************************************************* 44 * Global Variables * 45 *******************************************************************************/ 42 46 char *lpszCustomDllName = NULL; 43 47 char *lpszCustomExportPrefix = NULL; 44 48 ULONG dwOrdinalBase = 0; 45 49 50 /** 51 * FreeLibrary callback for LX Dlls, it's call only when the library is actually 52 * being unloaded. 53 * Maintained by ODIN_SetLxDllUnLoadCallback(). 54 */ 55 PFNLXDLLUNLOAD pfnLxDllUnLoadCallback = NULL; 56 46 57 //****************************************************************************** 47 58 //****************************************************************************** 48 59 void WIN32API SetCustomBuildName(char *lpszName, DWORD ordinalbase, 49 char *lpszExportPrefix) 60 char *lpszExportPrefix) 50 61 { 51 62 lpszCustomDllName = lpszName; … … 261 272 ULONG Win32LxDll::Release() 262 273 { 263 HINSTANCE hinst; 274 HINSTANCE hinst = hinstanceOS2; 275 HINSTANCE hinstOdin = hinstance; 264 276 WIN32DLLENTRY EntryPointTmp = dllEntryPoint; 265 277 PVOID pResDataTmp = (PVOID)pResRootDir; … … 267 279 DWORD MinorImageVersionTmp = MinorImageVersion; 268 280 DWORD SubsystemTmp = Subsystem; 281 BOOL fNoUnload = fDisableUnload; //only set for kernel32.dll 282 BOOL fDynLoaded = isDynamicLib(); 269 283 ULONG ret; 270 284 APIRET rc; 271 BOOL fNoUnload = fDisableUnload; //only set for kernel32.dll 272 Win32LxDll *pModule; 273 274 hinst = hinstanceOS2; 285 275 286 ret = Win32DllBase::Release(); 276 if(ret == 0 && !fNoUnload) {//only set for kernel32.dll (fDisableUnload) 287 288 /** @sketch 289 * If this module is not unreference and it was loaded using LoadLibrary() then 290 * call the custombuild callback if present. 291 * The callback should call UnRegisterLxDll(). 292 * Endif 293 * 294 * @remark 295 * #ifdef HACK_NEVER_UNLOAD_LX_DLLS 296 * This will never be called! 297 * #endif 298 * 299 * @todo: call pfnLxDllLoadCallback if DosFreeModule failes. 300 * It's not implemented because it's complex and at the moment we will 301 * never actually get here. 302 * So, this callback is here just as a reminder eventhough it's working.. 303 */ 304 if (!ret && fDynLoaded && pfnLxDllUnLoadCallback) 305 { 306 pfnLxDllUnLoadCallback(hinstanceOS2, hinstance); 307 } 308 309 if (ret == 0 && !fNoUnload) {//only set for kernel32.dll (fDisableUnload) 277 310 //DosFreeModule sends a termination message to the dll. 278 311 //The LX dll informs us when it's removed (UnregisterDll call) … … 280 313 if(rc) { 281 314 dprintf(("Win32LxDll::Release: DosFreeModule %x returned %d", hinst, rc)); 282 if(rc == ERROR_INVALID_ACCESS && !fExitProcess) 315 if(rc == ERROR_INVALID_ACCESS && !fExitProcess) 283 316 { 317 #ifndef HACK_NEVER_UNLOAD_LX_DLLS 318 #error @todo: call pfnLxDllLoadCallback and let it do the registering if it did that on the initial load.. 319 #endif 284 320 //Dll refused to unload because it has an active exitlist handler 285 321 //or depends on a dll that registered an exitlist handler … … 295 331 296 332 /* OS/2 dll, system dll, converted dll or win32k took care of it. */ 297 pModule = Win32LxDll::findModuleByOS2Handle(hinst);333 Win32LxDll *pModule = Win32LxDll::findModuleByOS2Handle(hinst); 298 334 if(pModule) 299 335 { … … 365 401 //****************************************************************************** 366 402 //****************************************************************************** 403 404 /** 405 * Custombuild API for registering a callback for LX Dll loading thru LoadLibrary*(). 406 * @returns Success indicator. 407 * @param pfn Pointer to callback. 408 * NULL if callback is deregistered. 409 */ 410 BOOL WIN32API ODIN_SetLxDllUnLoadCallback(PFNLXDLLUNLOAD pfn) 411 { 412 pfnLxDllUnLoadCallback = pfn; 413 return TRUE; 414 } 415 -
trunk/src/kernel32/wprocess.cpp
r9802 r9828 1 /* $Id: wprocess.cpp,v 1.18 0 2003-02-13 17:16:50sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.181 2003-02-20 09:47:01 sandervl Exp $ */ 2 2 3 3 /* … … 51 51 #include <win\ntddk.h> 52 52 53 #include <custombuild.h> 54 53 55 #define DBG_LOCALLOG DBG_wprocess 54 56 #include "dbglocal.h" … … 88 90 static TEB *threadList = 0; 89 91 static VMutex threadListMutex; 92 93 /** 94 * LoadLibraryExA callback for LX Dlls, it's call only on the initial load. 95 * Maintained by ODIN_SetLxDllLoadCallback(). 96 * Note! Because of some hacks it may also be called from Win32LxDll::Release(). 97 */ 98 PFNLXDLLLOAD pfnLxDllLoadCallback = NULL; 90 99 91 100 … … 451 460 //****************************************************************************** 452 461 // ODIN_SetTIBSwitch: override TIB switching 453 // 462 // 454 463 // Parameters: 455 464 // BOOL fSwitchTIB … … 743 752 fDisableLXDllLoading = TRUE; 744 753 } 754 755 756 /** 757 * Custombuild API for registering a callback for LX Dll loading thru LoadLibrary*(). 758 * @returns Success indicator. 759 * @param pfn Pointer to callback. 760 * NULL if callback is deregistered. 761 */ 762 BOOL WIN32API ODIN_SetLxDllLoadCallback(PFNLXDLLLOAD pfn) 763 { 764 pfnLxDllLoadCallback = pfn; 765 return TRUE; 766 } 767 745 768 746 769 /** … … 942 965 * Try load the executable using LoadLibrary 943 966 * IF successfully loaded THEN 944 * IF LX dll and is using the PE Loader THEN 945 * Set Load library. 946 * Inc reference count. 967 * Try find registered/pe2lx object. 968 * IF callback Then 969 * If callback give green light Then 970 * Find registered lx object. 971 * Else 972 * Unload it if loaded. 973 * Endif 947 974 * Endif 948 * Inc dynamic reference count. 949 * RETURN successfully. 975 * IF module object found Then 976 * IF LX dll and is using the PE Loader THEN 977 * Set Load library. 978 * Inc reference count. 979 * Endif 980 * Inc dynamic reference count. 981 * RETURN successfully. 982 * Else 983 * fail. 984 * Endif 950 985 * Endif 951 986 * Endif … … 959 994 /* OS/2 dll, system dll, converted dll or win32k took care of it. */ 960 995 pModule = Win32DllBase::findModuleByOS2Handle(hDll); 996 /* Custombuild customizing may take care of it too. */ 997 if (pfnLxDllLoadCallback) 998 { 999 /* If callback says yes, continue load it, else fail. */ 1000 if (pfnLxDllLoadCallback(hDll, pModule ? pModule->getInstanceHandle() : NULL)) 1001 pModule = Win32DllBase::findModuleByOS2Handle(hDll); 1002 else if (pModule) 1003 { 1004 pModule->Release(); 1005 pModule = NULL; 1006 } 1007 } 961 1008 if (pModule) 962 1009 { … … 1835 1882 #endif 1836 1883 1837 if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) 1884 if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) 1838 1885 { 1839 1886 //Translate standard handles if the child needs to inherit them … … 1845 1892 retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdError, &startinfo.hStdError); 1846 1893 1847 if(retcode) { 1894 if(retcode) { 1848 1895 SetLastError(ERROR_INVALID_HANDLE); 1849 1896 return FALSE; … … 2321 2368 //****************************************************************************** 2322 2369 // ODIN_SetProcAddress: Override a dll export 2323 // 2370 // 2324 2371 // Parameters: 2325 2372 // HMODULE hModule Module handle … … 2331 2378 // 2332 2379 //****************************************************************************** 2333 FARPROC WIN32API ODIN_SetProcAddress(HMODULE hModule, LPCSTR lpszProc, 2380 FARPROC WIN32API ODIN_SetProcAddress(HMODULE hModule, LPCSTR lpszProc, 2334 2381 FARPROC pfnNewProc) 2335 2382 {
Note:
See TracChangeset
for help on using the changeset viewer.