Ignore:
Timestamp:
Feb 9, 2001, 7:31:06 PM (25 years ago)
Author:
sandervl
Message:

heap (shared+code) changes + lx dll unload workaround

File:
1 edited

Legend:

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

    r4433 r5075  
    1 /* $Id: windlllx.cpp,v 1.16 2000-10-05 18:36:49 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.17 2001-02-09 18:31:05 sandervl Exp $ */
    22
    33/*
     
    3232#include "winexepeldr.h"
    3333#include <odinlx.h>
     34#include <wprocess.h>
    3435#include "oslibmisc.h"
    3536
     
    7172   //once for a dll (to make sure OS/2 doesn't unload the dll when it's
    7273   //still needed)
     74//testestest
    7375   rc = DosLoadModule(szErrName, sizeof(szErrName), szFileName, &hInstance);
    7476   if(rc != 0) {
     
    7678        return 0;
    7779   }
     80//testestest
    7881   windll = new Win32LxDll(hInstance, EntryPoint, pResData, MajorImageVersion,
    7982                           MinorImageVersion, Subsystem);
     
    125128                windll->addDependency(windlldep);
    126129        }
     130        else    dprintf(("WARNING: Can't find dll %s referenced by %s", modulename, windll->getModuleName()));
    127131        offset += modsize + 1;
    128132   }
     
    164168                  Win32DllBase(hInstance, EntryPoint)
    165169{
     170  this->MajorImageVersion = MajorImageVersion;
     171  this->MinorImageVersion = MinorImageVersion;
     172  this->Subsystem         = Subsystem;
     173 
    166174  if(EntryPoint == NULL) {
    167175        fSkipThreadEntryCalls    = TRUE;
     
    229237ULONG Win32LxDll::Release()
    230238{
    231  HINSTANCE hinst;
    232  ULONG     ret;
    233  APIRET    rc;
    234  BOOL      fNoUnload = fDisableUnload; //only set for kernel32.dll
     239 HINSTANCE     hinst;
     240 WIN32DLLENTRY EntryPointTmp        = dllEntryPoint;
     241 PVOID         pResDataTmp          = (PVOID)pResRootDir;
     242 DWORD         MajorImageVersionTmp = MajorImageVersion;
     243 DWORD         MinorImageVersionTmp = MinorImageVersion;
     244 DWORD         SubsystemTmp         = Subsystem;
     245 ULONG         ret;
     246 APIRET        rc;
     247 BOOL          fNoUnload = fDisableUnload; //only set for kernel32.dll
     248 Win32LxDll   *pModule;
    235249
    236250  hinst = hinstanceOS2;
     
    241255        rc = DosFreeModule(hinst);
    242256        if(rc) {
    243                 dprintf(("Win32LxDll::Release: DosFreeModule %x returned %d", hinst, rc));
     257            dprintf(("Win32LxDll::Release: DosFreeModule %x returned %d", hinst, rc));
     258            if(rc == ERROR_INVALID_ACCESS && !fExitProcess) {
     259                //Dll refused to unload because it has an active exitlist handler
     260                //or depends on a dll that registered an exitlist handler
     261                //In this case the handle remains valid and the entrypoint of
     262                //the dll is NOT called for DLL_PROCESS_DETACH
     263                //WORKAROUND: Re-register the dll so future LoadLibrary calls
     264                //            don't fail!
     265                dprintf(("WORKAROUND: Re-register the dll so future LoadLibrary calls don't fail!"));
     266                RegisterLxDll(hinst, EntryPointTmp, pResDataTmp,
     267                              MajorImageVersionTmp,
     268                              MinorImageVersionTmp,
     269                              SubsystemTmp);
     270
     271                /* OS/2 dll, system dll, converted dll or win32k took care of it. */
     272                pModule = Win32LxDll::findModuleByOS2Handle(hinst);
     273                if(pModule)
     274                {
     275                        pModule->setDllHandleOS2(hinst);
     276                        if(fPeLoader)
     277                        {
     278                            if(pModule->AddRef() == -1) {//-1 -> load failed (attachProcess)
     279                                dprintf(("ERROR Dll refused to be loaded; aborting"));
     280                                DebugInt3();
     281                                delete pModule;
     282                                return 0;
     283                            }
     284                        }
     285                        pModule->incDynamicLib();
     286                }
     287                else    DebugInt3();
     288            }
    244289        }
    245290  }
Note: See TracChangeset for help on using the changeset viewer.