Ignore:
Timestamp:
Feb 20, 2003, 10:47:01 AM (23 years ago)
Author:
sandervl
Message:

Added custombuild API for registering a callback for LX Dll loading thru LoadLibrary*()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/windlllx.cpp

    r9411 r9828  
    1 /* $Id: windlllx.cpp,v 1.26 2002-11-18 13:53:54 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.27 2003-02-20 09:47:01 sandervl Exp $ */
    22
    33/*
     
    3434#include <wprocess.h>
    3535#include "oslibmisc.h"
     36#include <custombuild.h>
    3637
    3738#include <exe386.h>
     
    4041#include "dbglocal.h"
    4142
     43/*******************************************************************************
     44*   Global Variables                                                           *
     45*******************************************************************************/
    4246char *lpszCustomDllName      = NULL;
    4347char *lpszCustomExportPrefix = NULL;
    4448ULONG dwOrdinalBase          = 0;
    4549
     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 */
     55PFNLXDLLUNLOAD pfnLxDllUnLoadCallback = NULL;
     56
    4657//******************************************************************************
    4758//******************************************************************************
    4859void WIN32API SetCustomBuildName(char *lpszName, DWORD ordinalbase,
    49                                  char *lpszExportPrefix) 
     60                                 char *lpszExportPrefix)
    5061{
    5162    lpszCustomDllName      = lpszName;
     
    261272ULONG Win32LxDll::Release()
    262273{
    263  HINSTANCE     hinst;
     274 HINSTANCE     hinst                = hinstanceOS2;
     275 HINSTANCE     hinstOdin            = hinstance;
    264276 WIN32DLLENTRY EntryPointTmp        = dllEntryPoint;
    265277 PVOID         pResDataTmp          = (PVOID)pResRootDir;
     
    267279 DWORD         MinorImageVersionTmp = MinorImageVersion;
    268280 DWORD         SubsystemTmp         = Subsystem;
     281 BOOL          fNoUnload            = fDisableUnload; //only set for kernel32.dll
     282 BOOL          fDynLoaded           = isDynamicLib();
    269283 ULONG         ret;
    270284 APIRET        rc;
    271  BOOL          fNoUnload = fDisableUnload; //only set for kernel32.dll
    272  Win32LxDll   *pModule;
    273 
    274   hinst = hinstanceOS2;
     285
    275286  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)
    277310    //DosFreeModule sends a termination message to the dll.
    278311    //The LX dll informs us when it's removed (UnregisterDll call)
     
    280313    if(rc) {
    281314            dprintf(("Win32LxDll::Release: DosFreeModule %x returned %d", hinst, rc));
    282             if(rc == ERROR_INVALID_ACCESS && !fExitProcess) 
     315            if(rc == ERROR_INVALID_ACCESS && !fExitProcess)
    283316            {
     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
    284320                //Dll refused to unload because it has an active exitlist handler
    285321                //or depends on a dll that registered an exitlist handler
     
    295331
    296332                /* OS/2 dll, system dll, converted dll or win32k took care of it. */
    297                 pModule = Win32LxDll::findModuleByOS2Handle(hinst);
     333                Win32LxDll *pModule = Win32LxDll::findModuleByOS2Handle(hinst);
    298334                if(pModule)
    299335                {
     
    365401//******************************************************************************
    366402//******************************************************************************
     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 */
     410BOOL WIN32API ODIN_SetLxDllUnLoadCallback(PFNLXDLLUNLOAD pfn)
     411{
     412    pfnLxDllUnLoadCallback = pfn;
     413    return TRUE;
     414}
     415
Note: See TracChangeset for help on using the changeset viewer.