Changeset 3993 for trunk/src


Ignore:
Timestamp:
Aug 11, 2000, 12:56:27 PM (25 years ago)
Author:
sandervl
Message:

Updates for fake system dll headers

Location:
trunk/src
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.9 2000-02-05 02:05:00 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.10 2000-08-11 10:56:11 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748BOOL WINAPI NTDLL_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
     
    9192         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9293
    93          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     94         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     95         if(dllHandle == 0)
    9496                return 0UL;
    9597
    9698         break;
    9799      case 1 :
    98          UnregisterLxDll(hModule);
     100         if(dllHandle) {
     101                UnregisterLxDll(dllHandle);
     102         }
    99103         break;
     104
    100105      default  :
    101106         return 0UL;
  • trunk/src/Odin32API/odindll.cpp

    r976 r3993  
    1 /* $Id: odindll.cpp,v 1.1 1999-09-18 17:46:28 sandervl Exp $ */
     1/* $Id: odindll.cpp,v 1.2 2000-08-11 10:56:12 sandervl Exp $ */
    22
    33/*
     
    4343extern DWORD _Resource_PEResTab;
    4444}
     45static HMODULE dllHandle = 0;
    4546
    4647BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
     
    8687         /*******************************************************************/
    8788
    88          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    89                 return 0UL;
     89         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     90         if(dllHandle == 0)
     91                return 0UL;
    9092
    9193         rc = DosExitList(0x0000F000|EXLST_ADD, cleanup);
     
    9597         break;
    9698      case 1 :
    97          UnregisterLxDll(hModule);
     99         if(dllHandle) {
     100                UnregisterLxDll(dllHandle);
     101         }
    98102         break;
    99103      default  :
  • trunk/src/comctl32/initterm.cpp

    r2647 r3993  
    1 /* $Id: initterm.cpp,v 1.9 2000-02-05 01:53:54 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.10 2000-08-11 10:56:12 sandervl Exp $ */
    22/*
    33 * COMCTL32 DLL entry point
     
    4343 extern DWORD _Resource_PEResTab;
    4444}
     45
     46static HMODULE dllHandle = 0;
    4547
    4648void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL);
     
    98100         /*******************************************************************/
    99101
    100          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     102         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab,
     103                                   COMCTL32_MAJORIMAGE_VERSION, COMCTL32_MINORIMAGE_VERSION,
     104                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
     105         if(dllHandle == 0)
    101106                return 0UL;
    102107
     
    104109
    105110         /* register Win32 window classes implemented in this DLL */
    106          RegisterCOMCTL32WindowClasses(hModule);
     111         RegisterCOMCTL32WindowClasses(dllHandle);
    107112
    108113         break;
    109114      case 1 :
    110          UnregisterLxDll(hModule);
     115         if(dllHandle) {
     116                UnregisterLxDll(dllHandle);
     117         }
    111118         break;
    112119      default  :
  • trunk/src/comctl32/propsheet.cpp

    r3912 r3993  
    1 /* $Id: propsheet.cpp,v 1.5 2000-08-01 23:19:49 sandervl Exp $ */
     1/* $Id: propsheet.cpp,v 1.6 2000-08-11 10:56:12 sandervl Exp $ */
    22/*
    33 * Property Sheets
     
    10681068}
    10691069
    1070 #if 1
     1070#if 0
    10711071/******************************************************************************
    10721072 *            PROPSHEET_ShowPage
  • trunk/src/comdlg32/initterm.cpp

    r2647 r3993  
    1 /* $Id: initterm.cpp,v 1.9 2000-02-05 01:54:33 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.10 2000-08-11 10:56:13 sandervl Exp $ */
    22
    33/*
     
    4646 BOOL WINAPI COMDLG32_DllEntryPoint(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved);
    4747}
     48
     49static HMODULE dllHandle = 0;
     50
    4851//******************************************************************************
    4952//******************************************************************************
     
    9598         /*******************************************************************/
    9699
    97          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     100         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab,
     101                                   COMDLG32_MAJORIMAGE_VERSION, COMDLG32_MINORIMAGE_VERSION,
     102                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
     103         if(dllHandle == 0)
    98104                return 0UL;
    99105
    100106         break;
    101107      case 1 :
    102          UnregisterLxDll(hModule);
     108         if(dllHandle) {
     109                UnregisterLxDll(dllHandle);
     110         }
    103111         break;
    104112      default  :
  • trunk/src/crtdll/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.3 2000-02-05 01:55:11 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.4 2000-08-11 10:56:13 sandervl Exp $ */
    22
    33/*
     
    4747BOOL WIN32API CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
    4848
     49static HMODULE dllHandle = 0;
     50
    4951//******************************************************************************
    5052//******************************************************************************
     
    9193         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9294
    93          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     95         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     96         if(dllHandle == 0)
    9497                return 0UL;
    9598
    9699         break;
    97100      case 1 :
    98          UnregisterLxDll(hModule);
     101         if(dllHandle) {
     102                UnregisterLxDll(dllHandle);
     103         }
    99104         break;
    100105
  • trunk/src/ddraw/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.12 2000-02-05 01:55:52 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.13 2000-08-11 10:56:14 sandervl Exp $ */
    22
    33/*
     
    4646
    4747char ddrawPath[CCHMAXPATH] = "";
     48static HMODULE dllHandle = 0;
    4849
    4950//******************************************************************************
     
    9798         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9899
    99          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     100         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab,
     101                                   DDRAW_MAJORIMAGE_VERSION, DDRAW_MINORIMAGE_VERSION,
     102                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
     103         if(dllHandle == 0)
    100104                return 0UL;
    101105
     
    103107      }
    104108      case 1 :
    105          UnregisterLxDll(hModule);
     109         if(dllHandle) {
     110                UnregisterLxDll(dllHandle);
     111         }
    106112         break;
    107113      default  :
  • trunk/src/dllentry/dllentry.cpp

    r2644 r3993  
    1 /* $Id: dllentry.cpp,v 1.1 2000-02-05 01:49:48 sandervl Exp $ */
     1/* $Id: dllentry.cpp,v 1.2 2000-08-11 10:56:14 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46
     47static HMODULE dllHandle = 0;
     48
    4649//******************************************************************************
    4750//******************************************************************************
     
    8487
    8588   switch (ulFlag) {
    86       case 0 :
     89      case 0:
    8790         _ctordtorInit();
    8891
    8992         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9093
    91          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     94         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     95         if(dllHandle == 0)
    9296                return 0UL;
    9397
    9498         break;
    95       case 1 :
    96          UnregisterLxDll(hModule);
     99      case 1:
     100         if(dllHandle) {
     101                UnregisterLxDll(dllHandle);
     102         }
    97103         break;
    98       default  :
     104      default:
    99105         return 0UL;
    100106   }
  • trunk/src/dsound/initterm.cpp

    r3099 r3993  
    1 /* $Id: initterm.cpp,v 1.10 2000-03-13 12:47:52 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.11 2000-08-11 10:56:15 sandervl Exp $ */
    22
    33/*
     
    4646
    4747char dsoundPath[CCHMAXPATH] = "";
     48static char dllHandle = 0;
    4849
    4950//******************************************************************************
     
    9697         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9798
    98          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     99         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     100         if(dllHandle == 0)
    99101                return 0UL;
    100102
    101103         break;
    102104      }
     105
    103106      case 1 :
    104          UnregisterLxDll(hModule);
     107         if(dllHandle) {
     108                UnregisterLxDll(dllHandle);
     109         }
    105110         break;
    106111      default  :
  • trunk/src/gdi32/initterm.cpp

    r3705 r3993  
    1 /* $Id: initterm.cpp,v 1.11 2000-06-14 13:17:50 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.12 2000-08-11 10:56:15 sandervl Exp $ */
    22
    33/*
     
    4747 extern DWORD _Resource_PEResTab;
    4848}
     49static HMODULE dllHandle = 0;
    4950//******************************************************************************
    5051//******************************************************************************
     
    100101         if(InitRegionSpace() == FALSE) {
    101102                return 0UL;
    102          }
    103          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     103         }
     104         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab,
     105                                   GDI32_MAJORIMAGE_VERSION, GDI32_MINORIMAGE_VERSION,
     106                                   IMAGE_SUBSYSTEM_NATIVE);
     107         if(dllHandle == 0)
    104108                return 0UL;
    105109
    106110         break;
    107111      case 1 :
    108          UnregisterLxDll(hModule);
     112         if(dllHandle) {
     113                UnregisterLxDll(dllHandle);
     114         }
    109115         break;
    110116      default  :
  • trunk/src/imagehlp/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.3 2000-02-05 02:00:05 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.4 2000-08-11 10:56:15 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748BOOL WINAPI IMAGEHLP_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
     
    9192         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9293
    93          /*******************************************************************/
    94          /* A DosExitList routine must be used to clean up if runtime calls */
    95          /* are required and the runtime is dynamically linked.             */
    96          /*******************************************************************/
    97 
    98          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     94         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     95         if(dllHandle == 0)
    9996                return 0UL;
    10097
    10198         break;
    10299      case 1 :
    103          UnregisterLxDll(hModule);
     100         if(dllHandle) {
     101                UnregisterLxDll(dllHandle);
     102         }
    104103         break;
    105104
  • trunk/src/kernel32/KERNEL32.DEF

    r3846 r3993  
    1 ; $Id: KERNEL32.DEF,v 1.84 2000-07-18 17:34:07 bird Exp $
     1; $Id: KERNEL32.DEF,v 1.85 2000-08-11 10:56:16 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    10351035
    10361036    _RegisterLxExe@8                                              @1237
    1037     _RegisterLxDll@12                                             @1238
     1037    _RegisterLxDll@24                                             @1238
    10381038    _UnregisterLxDll@4                                            @1239
    10391039
  • trunk/src/kernel32/initterm.cpp

    r3740 r3993  
    1 /* $Id: initterm.cpp,v 1.43 2000-06-21 20:51:52 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.44 2000-08-11 10:56:16 sandervl Exp $ */
    22
    33/*
     
    8181int   loadNr = 0;
    8282char  kernel32Path[CCHMAXPATH] = "";
     83static HMODULE dllHandle = 0;
    8384
    8485/****************************************************************************/
     
    128129
    129130            PROFILE_LoadOdinIni();
    130             if(RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab) == FALSE)
     131            dllHandle = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab);
     132            if(dllHandle == 0)
    131133                return 0UL;
    132134
    133135            //SvL: Kernel32 is a special case; pe.exe loads it, so increase
    134136            //     the reference count here
    135             Win32DllBase *module = Win32DllBase::findModule(hModule);
     137            Win32DllBase *module = Win32DllBase::findModule(dllHandle);
    136138            if(module) {
    137139                module->AddRef();
     
    178180        }
    179181        case 1 :
    180             UnregisterLxDll(hModule);
     182            if(dllHandle) {
     183                UnregisterLxDll(dllHandle);
     184            }
    181185            break;
    182186        default  :
  • trunk/src/kernel32/misc.cpp

    r3889 r3993  
    1 /* $Id: misc.cpp,v 1.24 2000-07-22 12:52:45 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.25 2000-08-11 10:56:16 sandervl Exp $ */
    22
    33/*
     
    3030#include "logging.h"
    3131#include <wprocess.h>
     32#include <versionos2.h>
    3233
    3334/*****************************************************************************
  • trunk/src/kernel32/oslibdos.cpp

    r3976 r3993  
    1 /* $Id: oslibdos.cpp,v 1.36 2000-08-10 02:19:58 phaller Exp $ */
     1/* $Id: oslibdos.cpp,v 1.37 2000-08-11 10:56:17 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    930930        rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL,
    931931                                  (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
     932        //SvL: 64 bits values are only supported by JFS
     933        //     Try the 32 bits DosSetFileLocks if it fails
     934        //     (TODO: should check the partition type instead)
     935        if(rc == ERROR_INVALID_PARAMETER && (OffsetHigh || nNumberOfBytesToLockHigh)) {
     936                goto oldlock;
     937        }
    932938   }
    933939   else
    934940   {
     941oldlock:
    935942    FILELOCK lockRange = { OffsetLow, nNumberOfBytesToLockLow };
    936943
     
    969976
    970977        rc = OdinDosSetFileLocksL(hFile, &unlockRangeL, NULL, 5000, 0);
     978        //SvL: 64 bits values are only supported by JFS
     979        //     Try the 32 bits DosSetFileLocks if it fails
     980        //     (TODO: should check the partition type instead)
     981        if(rc == ERROR_INVALID_PARAMETER && (OffsetHigh || nNumberOfBytesToLockHigh)) {
     982                goto oldlock;
     983        }
    971984   }
    972985   else
    973986   {
     987oldlock:
    974988    FILELOCK unlockRange = { OffsetLow, nNumberOfBytesToLockLow };
    975989
  • trunk/src/kernel32/oslibmisc.cpp

    r3501 r3993  
    1 /* $Id: oslibmisc.cpp,v 1.9 2000-05-09 18:56:09 sandervl Exp $ */
     1/* $Id: oslibmisc.cpp,v 1.10 2000-08-11 10:56:18 sandervl Exp $ */
    22/*
    33 * Misc OS/2 util. procedures
     
    4040}
    4141//******************************************************************************
    42 /*****************************************************************************
     42//******************************************************************************
     43BOOL OSLibGetDllName(ULONG hModule, char *name, int length)
     44{
     45  return DosQueryModuleName(hModule, length, name) == 0;
     46}
     47//******************************************************************************
     48/******************************************************************************
    4349 * Name      : ULONG OSLibiGetModuleHandleA
    4450 * Purpose   : replacement for IBM Open32's GetModuleHandle
  • trunk/src/kernel32/oslibmisc.h

    r3746 r3993  
    1 /* $Id: oslibmisc.h,v 1.5 2000-06-23 19:02:38 sandervl Exp $ */
     1/* $Id: oslibmisc.h,v 1.6 2000-08-11 10:56:18 sandervl Exp $ */
    22/*
    33 * Misc util. procedures
     
    1212
    1313char *OSLibGetDllName(ULONG hModule);
     14BOOL  OSLibGetDllName(ULONG hModule, char *name, int length);
    1415
    1516char *OSLibStripPath(char *path);
  • trunk/src/kernel32/windllbase.cpp

    r3854 r3993  
    1 /* $Id: windllbase.cpp,v 1.15 2000-07-18 18:37:29 sandervl Exp $ */
     1/* $Id: windllbase.cpp,v 1.16 2000-08-11 10:56:18 sandervl Exp $ */
    22
    33/*
     
    5353                   referenced(0), fSkipThreadEntryCalls(FALSE), next(NULL), fInserted(FALSE),
    5454                   fAttachedToProcess(FALSE), fUnloaded(FALSE),
    55                    nrDynamicLibRef(0), fLoadLibrary(FALSE), fDisableUnload(FALSE)
     55                   nrDynamicLibRef(0), fDisableUnload(FALSE)
    5656{
    5757  dllEntryPoint = DllEntryPoint;
     
    8989  }
    9090  dlllistmutex.leave();
    91 }
    92 //******************************************************************************
    93 //******************************************************************************
    94 void Win32DllBase::loadLibrary()
    95 {
    96   //dummy
    9791}
    9892//******************************************************************************
  • trunk/src/kernel32/windllbase.h

    r3854 r3993  
    1 /* $Id: windllbase.h,v 1.4 2000-07-18 18:37:29 sandervl Exp $ */
     1/* $Id: windllbase.h,v 1.5 2000-08-11 10:56:18 sandervl Exp $ */
    22
    33/*
     
    8686        BOOL      RemoveCircularDependency(Win32DllBase *parent);
    8787
    88         // Loaded by DosLoadModule
    89 virtual void      setLoadLibrary() { fLoadLibrary = TRUE; };
    90 
    91         // isLoaded returns TRUE when a dll has been loaded with DosLoadModule
    92 virtual BOOL      isLoaded()       { return fLoadLibrary; };
    93 
    94         //Should only be called to make sure DosLoadModule is called at least
    95         //once for a dll (to make sure OS/2 doesn't unload the dll when it's
    96         //still needed)
    97 virtual void      loadLibrary();
    98 
    9988        //Only called for kernel32
    10089        void      DisableUnload()  { fDisableUnload = TRUE; };
     
    138127
    139128        //This flag is set when a dll has been loaded with DosLoadModule
    140         BOOL          fLoadLibrary;
    141129        BOOL          fDisableUnload;
    142  
     130
     131static  Win32DllBase *head;
     132        Win32DllBase *next;
    143133private:
    144134static  Queue         loadLibDlls;
    145 static  Win32DllBase *head;
    146         Win32DllBase *next;
    147135};
    148136
  • trunk/src/kernel32/windlllx.cpp

    r3854 r3993  
    1 /* $Id: windlllx.cpp,v 1.11 2000-07-18 18:37:29 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.12 2000-08-11 10:56:18 sandervl Exp $ */
    22
    33/*
     
    4242//Create LX Dll object and send process attach message
    4343//System dlls set EntryPoint to 0
     44//Parameters:
     45//  HINSTANCE hInstance         - OS/2 module handle
     46//  WIN32DLLENTRY EntryPoint    - Win32 dll entrypoint address
     47//  PVOID pResData              - pointer to win32 resource data
     48//  DWORD MajorImageVersion     - major image/os version (for fake win32 header)
     49//  DWORD MinorImageVersion     - minor image/os version (for fake win32 header)
     50//  DWORD Subsystem             - subsystem type (for fake win32 header)
     51//                                (IMAGE_SUBSYSTEM_WINDOWS_CUI/IMAGE_SUBSYSTEM_WINDOWS_GUI)
     52//
    4453//Returns: Odin32 module handle
    4554//******************************************************************************
    4655DWORD WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint,
    47                              PVOID pResData)
    48 {
    49  Win32LxDll *windll;
     56                             PVOID pResData,
     57                             DWORD MajorImageVersion,
     58                             DWORD MinorImageVersion,
     59                             DWORD Subsystem)
     60{
     61 APIRET        rc;
     62 Win32LxDll    *windll;
    5063 Win32DllBase *windlldep;
    51 
    52    windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
    53    if(windll) {
    54         char *name = OSLibGetDllName(hInstance);
    55         dprintf(("RegisterLxDll: Register existing dll %x %s", hInstance, name));
    56         return FALSE;
    57    }
    58    windll = new Win32LxDll(hInstance, EntryPoint, pResData);
     64 char          szFileName[CCHMAXPATH], szErrName[CCHMAXPATH];
     65
     66   if(OSLibGetDllName(hInstance, szFileName, sizeof(szFileName)) == FALSE) {
     67        dprintf(("ERROR: RegisterLxDll: OSLibGetDllName %x failed!!", hInstance));
     68        return 0;
     69   }
     70   //Make sure DosLoadModule is called at least
     71   //once for a dll (to make sure OS/2 doesn't unload the dll when it's
     72   //still needed)
     73   rc = DosLoadModule(szErrName, sizeof(szErrName), szFileName, &hInstance);
     74   if(rc != 0) {
     75        dprintf(("ERROR: RegisterLxDll: DosLoadModule %s failed (rc=%d)!!", szFileName, rc));
     76        return 0;
     77   }
     78   windll = new Win32LxDll(hInstance, EntryPoint, pResData, MajorImageVersion,
     79                           MinorImageVersion, Subsystem);
    5980   if(windll == NULL) {
    6081        dprintf(("RegisterLxDll: windll == NULL!!!"));
    61         return FALSE;
     82        return 0;
    6283   }
    6384   if(!fPeLoader) {
     
    7495   char             modulename[CCHMAXPATH];
    7596   char             modsize;
    76    APIRET           rc;
    7797   int              i;
    7898
     
    118138BOOL WIN32API UnregisterLxDll(HINSTANCE hInstance)
    119139{
    120  Win32LxDll *windll;
     140 Win32DllBase *windll;
    121141
    122142   //Don't proceed for pe2lx/win32k (os/2 dll unload dependency bug)
     
    125145        return TRUE;
    126146
    127    windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
     147   windll = Win32DllBase::findModule(hInstance);
    128148   if(!windll) {
    129149        dprintf(("UnregisterLxDll: Can't find dll with handle %x (already deleted)", hInstance));
     
    137157//******************************************************************************
    138158//******************************************************************************
    139 Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData)
     159Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData,
     160                       DWORD MajorImageVersion, DWORD MinorImageVersion,
     161                       DWORD Subsystem)
    140162                : Win32ImageBase(hInstance),
    141163                  Win32LxImage(hInstance, pResData),
     
    146168        fAttachedToProcess = TRUE;
    147169  }
     170  hinstanceOS2 = hInstance;
     171  //new win32 instance handle must be pointer to PE header
     172  hinstance = (HINSTANCE)buildHeader(MajorImageVersion, MinorImageVersion,
     173                                     Subsystem);
    148174}
    149175//******************************************************************************
     
    151177Win32LxDll::~Win32LxDll()
    152178{
    153 }
    154 //******************************************************************************
    155 //Load it again so OS/2 takes care of the reference count (to make sure
    156 //a dll isn't unloaded when the win32 app still needs it)
    157 //******************************************************************************
    158 void Win32LxDll::loadLibrary()
    159 {
    160  char   szModuleFailure[CCHMAXPATH] = "";
    161  ULONG  hInstanceNewDll;
    162  APIRET rc;
    163 
    164   if(fLoadLibrary) {
    165         DebugInt3();
    166         return;
    167   }
    168 
    169   dprintf(("Win32LxDll::loadLibrary %s", getModuleName()));
    170   rc = DosLoadModule(szModuleFailure, sizeof(szModuleFailure), getFullPath(), (HMODULE *)&hInstanceNewDll);
    171   if(rc) {
    172         dprintf(("DosLoadModule returned %X for %s\n", rc, szModuleFailure));
    173         DebugInt3(); //should NEVER happen
    174         return;
    175   }
    176   //only do this once, so set the fLoadLibrary flag to true
    177   setLoadLibrary();
    178179}
    179180//******************************************************************************
     
    227228 ULONG     ret;
    228229 APIRET    rc;
    229  BOOL      fLoadLib = fLoadLibrary;
    230 
    231   if(fDisableUnload) {//only set for kernel32.dll
    232         fLoadLib = FALSE;
    233   }
    234   hinst = hinstance;
     230
     231  hinst = hinstanceOS2;
    235232  ret = Win32DllBase::Release();
    236   if(ret == 0 && fLoadLib) {
     233  if(ret == 0 && !fDisableUnload) {//only set for kernel32.dll (fDisableUnload)
    237234        //DosFreeModule sends a termination message to the dll.
    238235        //The LX dll informs us when it's removed (UnregisterDll call)
     
    252249//******************************************************************************
    253250//******************************************************************************
     251void Win32LxDll::setDllHandleOS2(HINSTANCE hInstanceOS2)
     252{
     253  //Loaded with LoadLibrary(Ex); no need for a 2nd DosLoadModule
     254  //Dlls that are indirectly loaded (i.e. GDI32->KERNEL32 dependancy) need
     255  //this additional DosLoadModule (and setDllHandleOS2 isn't called for those)
     256  if(this->hinstanceOS2) {
     257        DosFreeModule(this->hinstanceOS2);
     258  }
     259  this->hinstanceOS2 = hInstanceOS2;
     260}
     261//******************************************************************************
     262//******************************************************************************
     263Win32LxDll *Win32LxDll::findModuleByOS2Handle(HINSTANCE hinstance)
     264{
     265   dlllistmutex.enter();
     266
     267   Win32LxDll *mod = (Win32LxDll*)Win32DllBase::head;
     268   while(mod != NULL) {
     269        dbgCheckObj(mod);
     270        if(mod->isLxDll() && mod->hinstanceOS2 == hinstance) {
     271                dlllistmutex.leave();
     272                return(mod);
     273        }
     274        mod = (Win32LxDll*)mod->next;
     275   }
     276   dlllistmutex.leave();
     277   return(NULL);
     278}
     279//******************************************************************************
     280//******************************************************************************
  • trunk/src/kernel32/windlllx.h

    r3059 r3993  
    1 /* $Id: windlllx.h,v 1.1 2000-03-09 19:03:21 sandervl Exp $ */
     1/* $Id: windlllx.h,v 1.2 2000-08-11 10:56:19 sandervl Exp $ */
    22
    33/*
     
    1919{
    2020public:
    21         Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, PVOID pResData);
     21        Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, PVOID pResData,
     22                   DWORD MajorImageVersion, DWORD MinorImageVersion,
     23                   DWORD Subsystem);
    2224virtual ~Win32LxDll();
    2325
     
    2931virtual ULONG     Release();
    3032
    31         // Loaded by DosLoadModule (only relevant for LX dlls)
    32 virtual void      setLoadLibrary() { fLoadLibrary = TRUE; };
    33 
    34         // isLoaded returns TRUE when a dll has been loaded with DosLoadModule
    35 virtual BOOL      isLoaded()       { return fLoadLibrary; };
    36 
    37         //Should only be called to make sure DosLoadModule is called at least
    38         //once for a dll (to make sure OS/2 doesn't unload the dll when it's
    39         //still needed)
    40 virtual void      loadLibrary();
     33        void      setDllHandleOS2(HINSTANCE hInstanceOS2);
    4134
    4235virtual BOOL      isLxDll();
     36
     37static  Win32LxDll *findModuleByOS2Handle(HINSTANCE hinstance);
    4338   
    4439protected:
  • trunk/src/kernel32/windllpe2lx.cpp

    r3059 r3993  
    1 /* $Id: windllpe2lx.cpp,v 1.7 2000-03-09 19:03:21 sandervl Exp $ */
     1/* $Id: windllpe2lx.cpp,v 1.8 2000-08-11 10:56:19 sandervl Exp $ */
    22
    33/*
     
    116116    else
    117117    {   /* process detach */
    118         if (pWinMod != NULL && !fFreeLibrary)
     118        if (pWinMod != NULL)
    119119            return 0;   /* don't unload (OS/2 dll unload bug) - see OS2.bugs in root dir. */
    120120    }
  • trunk/src/kernel32/winimagelx.cpp

    r3765 r3993  
    1 /* $Id: winimagelx.cpp,v 1.8 2000-06-28 18:08:35 sandervl Exp $ */
     1/* $Id: winimagelx.cpp,v 1.9 2000-08-11 10:56:19 sandervl Exp $ */
    22
    33/*
    44 * Win32 LX Image base class
    55 *
    6  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1999-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 *
     8 * TODO: headers not complete
     9 *
    810 * Project Odin Software License can be found in LICENSE.TXT
    911 *
     
    4042#include "dbglocal.h"
    4143
     44static BYTE dosHeader[] = {
     45 0x4D, 0x5A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0B, 0x00,
     46 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     47 0x6A, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00,
     49 0xB4, 0x30, 0xCD, 0x21, 0x86, 0xC4, 0x3D, 0x0A, 0x14, 0x72, 0x42, 0xBE, 0x80, 0x00, 0x8A, 0x1C,
     50 0x32, 0xFF, 0x46, 0x88, 0x38, 0x2E, 0x8C, 0x1E, 0x6E, 0x00, 0x8E, 0x06, 0x2C, 0x00, 0x33, 0xC0,
     51 0x8B, 0xF8, 0xB9, 0x00, 0x80, 0xFC, 0xF2, 0xAE, 0x75, 0x23, 0x49, 0x78, 0x20, 0xAE, 0x75, 0xF6,
     52 0x47, 0x47, 0x0E, 0x1F, 0x2E, 0x89, 0x3E, 0x68, 0x00, 0x2E, 0x8C, 0x06, 0x6A, 0x00, 0xBE, 0x5C,
     53 0x00, 0xB9, 0x6C, 0x63, 0xBB, 0x25, 0x00, 0xB4, 0x64, 0xCD, 0x21, 0x73, 0x0B, 0xBA, 0x7C, 0x00,
     54 0x0E, 0x1F, 0xB4, 0x09, 0xCD, 0x21, 0xB0, 0x01, 0xB4, 0x4C, 0xCD, 0x21, 0x20, 0x00, 0x01, 0x00,
     55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00,
     56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x54, 0x68, 0x69, 0x73,
     57 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x20, 0x6D, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65,
     58 0x20, 0x72, 0x75, 0x6E, 0x20, 0x75, 0x6E, 0x64, 0x65, 0x72, 0x20, 0x57, 0x69, 0x6E, 0x33, 0x32,
     59 0x2E, 0x0D, 0x0A, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     60};
     61
    4262//******************************************************************************
    4363//******************************************************************************
    4464Win32LxImage::Win32LxImage(HINSTANCE hInstance, PVOID pResData)
    45                : Win32ImageBase(hInstance)
     65               : Win32ImageBase(hInstance), header(0)
    4666{
    4767 APIRET rc;
     
    6787Win32LxImage::~Win32LxImage()
    6888{
     89  if(header) {
     90        DosFreeMem(header);
     91  }
    6992}
    7093//******************************************************************************
     
    7598  ULONG       apiaddr;
    7699
    77   rc = DosQueryProcAddr(hinstance, 0, name, (PFN *)&apiaddr);
     100  rc = DosQueryProcAddr(hinstanceOS2, 0, name, (PFN *)&apiaddr);
    78101  if(rc)
    79102  {
    80         if(rc == ERROR_INVALID_HANDLE)
    81         {//handle invalid for some silly reason, so load module again (initterm entrypoint not called twice)
    82                 char szErrName[CCHMAXPATH];
    83 
    84                 rc = DosLoadModule(szErrName, sizeof(szErrName), szFileName, &hinstance);
    85                 if(!rc)
    86                         rc = DosQueryProcAddr(hinstance, 0, name, (PFN *)&apiaddr);
    87         }
    88         if(rc)  return(0);
     103        dprintf(("Win32LxImage::getApi -> rc = %d", rc));
     104        return(0);
    89105  }
    90106  return(apiaddr);
     
    97113 ULONG       apiaddr;
    98114
    99   rc = DosQueryProcAddr(hinstance, ordinal, NULL, (PFN *)&apiaddr);
     115  rc = DosQueryProcAddr(hinstanceOS2, ordinal, NULL, (PFN *)&apiaddr);
    100116  if(rc) {
    101         if(rc == ERROR_INVALID_HANDLE)
    102         {//SvL(?): handle invalid for some silly reason, so load module again (initterm entrypoint not called twice)
    103          //KSO: AFAIK you'll have to load the module calling DosLoadModule to use it's handle in API calls.
    104          //     CPREF->DosGetResource->hmod: ... A value other than zero is a module handle that was returned by DosLoadModule.
    105          //     You may consider adding a DosLoadModule call during RegisterLxDll or somewhere.
    106                 char szErrName[CCHMAXPATH];
    107 
    108                 rc = DosLoadModule(szErrName, sizeof(szErrName), szFileName, &hinstance);
    109                 if(!rc)
    110                         rc = DosQueryProcAddr(hinstance, ordinal, NULL, (PFN *)&apiaddr);
    111         }
    112         if(rc)  return(0);
     117        dprintf(("Win32LxImage::getApi -> rc = %d", rc));
     118        return(0);
    113119  }
    114120  return(apiaddr);
     
    116122//******************************************************************************
    117123//******************************************************************************
     124LPVOID Win32LxImage::buildHeader(DWORD MajorImageVersion, DWORD MinorImageVersion,
     125                                 DWORD Subsystem)
     126{
     127 APIRET rc;
     128 IMAGE_DOS_HEADER *pdosheader;
     129 PIMAGE_OPTIONAL_HEADER poh;
     130 PIMAGE_FILE_HEADER     pfh;
     131 DWORD *ntsig;
    118132
     133  rc = DosAllocMem(&header, 4096, PAG_READ | PAG_WRITE | PAG_COMMIT);
     134  if(rc) {
     135        dprintf(("ERROR: buildHeader DosAllocMem failed!! (rc=%x)", rc));
     136        DebugInt3();
     137        return NULL;
     138  }
     139  memcpy(header, dosHeader, sizeof(dosHeader));
     140  ntsig  = (DWORD *)((LPBYTE)header + sizeof(dosHeader));
     141  *ntsig = IMAGE_NT_SIGNATURE;
     142  pfh    = (PIMAGE_FILE_HEADER)(ntsig+1);
     143  pfh->Machine              = IMAGE_FILE_MACHINE_I386;
     144  pfh->NumberOfSections     = 0;
     145  pfh->TimeDateStamp        = 0x3794f60f;
     146  pfh->PointerToSymbolTable = 0;
     147  pfh->NumberOfSymbols      = 0;
     148  pfh->SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER);
     149  pfh->Characteristics      = IMAGE_FILE_DLL | IMAGE_FILE_32BIT_MACHINE |
     150                              IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE |
     151                              IMAGE_FILE_RELOCS_STRIPPED;
     152  poh    = (PIMAGE_OPTIONAL_HEADER)(pfh+1);
     153  poh->Magic                       = IMAGE_NT_OPTIONAL_HDR_MAGIC;
     154  poh->MajorLinkerVersion          = 0x3;
     155  poh->MinorLinkerVersion          = 0xA;
     156  poh->SizeOfCode                  = 0;
     157  poh->SizeOfInitializedData       = 0;
     158  poh->SizeOfUninitializedData     = 0;
     159  poh->AddressOfEntryPoint         = 0;
     160  poh->BaseOfCode                  = 0;
     161  poh->BaseOfData                  = 0;
     162  poh->ImageBase                   = 0;
     163  poh->SectionAlignment            = 4096;
     164  poh->FileAlignment               = 512;
     165  poh->MajorOperatingSystemVersion = MajorImageVersion;
     166  poh->MinorOperatingSystemVersion = MinorImageVersion;
     167  poh->MajorImageVersion           = MajorImageVersion;
     168  poh->MinorImageVersion           = MinorImageVersion;
     169  poh->MajorSubsystemVersion       = ODINNT_MAJOR_VERSION;
     170  poh->MinorSubsystemVersion       = ODINNT_MINOR_VERSION;
     171  poh->Reserved1                   = 0;
     172  poh->SizeOfImage                 = 0;
     173  poh->SizeOfHeaders               = 1024;
     174  poh->CheckSum                    = 0;
     175  poh->Subsystem                   = Subsystem;
     176  poh->DllCharacteristics          = 0;
     177  poh->SizeOfStackReserve          = 1*1024*1024;
     178  poh->SizeOfStackCommit           = 4096;
     179  poh->SizeOfHeapReserve           = 1*1024*1024;
     180  poh->SizeOfHeapCommit            = 4096;
     181  poh->LoaderFlags                 = 0;
     182  poh->NumberOfRvaAndSizes         = 0;
     183//  poh->DataDirectory[0]
     184
     185  return header;
     186}
     187//******************************************************************************
     188//******************************************************************************
  • trunk/src/kernel32/winimagelx.h

    r3074 r3993  
    1 /* $Id: winimagelx.h,v 1.1 2000-03-10 16:12:03 sandervl Exp $ */
     1/* $Id: winimagelx.h,v 1.2 2000-08-11 10:56:19 sandervl Exp $ */
    22
    33/*
     
    2424virtual ULONG     getApi(int ordinal);
    2525
     26        LPVOID    buildHeader(DWORD MajorImageVersion, DWORD MinorImageVersion,
     27                              DWORD Subsystem);
     28
    2629protected:
     30  LPVOID header;
     31  HINSTANCE hinstanceOS2;
    2732private:
    2833};
  • trunk/src/kernel32/winimagepeldr.cpp

    r3948 r3993  
    1 /* $Id: winimagepeldr.cpp,v 1.51 2000-08-04 21:12:10 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.52 2000-08-11 10:56:19 sandervl Exp $ */
    22
    33/*
     
    4242#include "winimagepeldr.h"
    4343#include "windllpeldr.h"
     44#include "windlllx.h"
    4445#include <pefile.h>
    4546#include <unicode.h>
     
    12181219 ULONG  ulCurFixup;
    12191220 int    Size;
    1220  Win32PeLdrDll *WinDll;
     1221 Win32DllBase *WinDll;
    12211222 Section *section;
    12221223
     
    13351336    dprintf((LOG, "************** Import Module %s ", pszCurModule ));
    13361337    dprintf((LOG, "**********************************************************************" ));
    1337     WinDll = (Win32PeLdrDll *)Win32DllBase::findModule(pszCurModule);
     1338    WinDll = Win32DllBase::findModule(pszCurModule);
    13381339
    13391340    if(WinDll == NULL)
     
    13501351                char   szModuleFailure[CCHMAXPATH] = "";
    13511352                ULONG  hInstanceNewDll;
     1353                Win32LxDll *lxdll;
    13521354
    13531355                char *dot = strchr(modname, '.');
     
    13631365                        return(FALSE);
    13641366                }
    1365                 WinDll = (Win32PeLdrDll *)Win32DllBase::findModule(hInstanceNewDll);
    1366                 if(WinDll == NULL) {//shouldn't happen!
     1367                lxdll = Win32LxDll::findModuleByOS2Handle(hInstanceNewDll);
     1368                if(lxdll == NULL) {//shouldn't happen!
    13671369                        dprintf((LOG, "Just loaded the dll, but can't find it anywhere?!!?"));
    13681370                        errorState = ERROR_INTERNAL;
    13691371                        return(FALSE);
    13701372                }
    1371                 //Mark this dll as loaded by DosLoadModule
    1372                 WinDll->setLoadLibrary();
    1373                 WinDll->AddRef();
     1373                lxdll->setDllHandleOS2(hInstanceNewDll);
     1374                lxdll->AddRef();
     1375                WinDll = (Win32DllBase*)lxdll;
    13741376        }
    13751377        else {
    1376                 WinDll = new Win32PeLdrDll(modname, this);
    1377 
    1378                 if(WinDll == NULL) {
    1379                     dprintf((LOG, "WinDll: Error allocating memory" ));
     1378         Win32PeLdrDll *pedll;
     1379
     1380                pedll = new Win32PeLdrDll(modname, this);
     1381                if(pedll == NULL) {
     1382                    dprintf((LOG, "pedll: Error allocating memory" ));
    13801383                    WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMemErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
    13811384                    errorState = ERROR_INTERNAL;
     
    13851388                dprintf((LOG, "**********************     Loading Module        *********************" ));
    13861389                dprintf((LOG, "**********************************************************************" ));
    1387                 if(WinDll->init(0) == FALSE) {
    1388                     dprintf((LOG, "Internal WinDll error ", WinDll->getError() ));
     1390                if(pedll->init(0) == FALSE) {
     1391                    dprintf((LOG, "Internal WinDll error ", pedll->getError() ));
    13891392                    return(FALSE);
    13901393                }
    13911394#ifdef DEBUG
    1392                 WinDll->AddRef(getModuleName());
     1395                pedll->AddRef(getModuleName());
    13931396#else
    1394                 WinDll->AddRef();
     1397                pedll->AddRef();
    13951398#endif
    1396                 if(WinDll->attachProcess() == FALSE) {
     1399                if(pedll->attachProcess() == FALSE) {
    13971400                    dprintf((LOG, "attachProcess failed!" ));
    1398                     delete WinDll;
     1401                    delete pedll;
    13991402                    errorState = ERROR_INTERNAL;
    14001403                    return(FALSE);
    14011404                }
     1405                WinDll = (Win32DllBase*)pedll;
    14021406        }
    14031407
     
    14071411    }
    14081412    else {
    1409         if(WinDll->isLxDll() && !WinDll->isLoaded()) {
    1410                 //can happen with i.e. wininet
    1411                 //wininet depends on wsock32; when the app loads wsock32 afterwards
    1412                 //with LoadLibrary or as a child of another dll, we need to make
    1413                 //sure it's loaded once with DosLoadModule
    1414                 WinDll->loadLibrary();
    1415         }
    14161413        WinDll->AddRef();
    14171414       
     
    14191416    }
    14201417    //add the dll we just loaded to dependency list for this image
    1421     addDependency((Win32DllBase *)WinDll);
     1418    addDependency(WinDll);
    14221419
    14231420    //Make sure the dependency list is correct (already done
  • trunk/src/kernel32/wprocess.cpp

    r3975 r3993  
    1 /* $Id: wprocess.cpp,v 1.85 2000-08-09 18:59:03 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.86 2000-08-11 10:56:20 sandervl Exp $ */
    22
    33/*
     
    2525#include "winexepeldr.h"
    2626#include "winfakepeldr.h"
     27#include "windlllx.h"
    2728#include <vmutex.h>
    2829#include <handlemanager.h>
     
    5152//******************************************************************************
    5253//******************************************************************************
    53 BOOL      fFreeLibrary = FALSE;
    5454BOOL      fIsOS2Image = FALSE;  //TRUE  -> Odin32 OS/2 application (not converted!)
    5555                            //FALSE -> otherwise
     
    448448        return(TRUE);
    449449    }
    450     dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance));
    451 
    452     //TODO: Not thread safe
    453     fFreeLibrary  = TRUE; //ditch dll
    454     rc = O32_FreeLibrary(hinstance);
    455     fFreeLibrary = FALSE;
    456     dprintf(("FreeLibrary returned %X\n", rc));
     450    dprintf(("WARNING: KERNEL32: FreeLibrary %s %x NOT FOUND!", OSLibGetDllName(hinstance), hinstance));
    457451    return(TRUE);
    458452}
     
    707701    if (pModule)
    708702    {
    709         if (pModule->isLxDll() && !pModule->isLoaded() && fPeLoader)
    710         {
    711             //can happen with i.e. wininet
    712             //wininet depends on wsock32; when the app loads wsock32 afterwards
    713             //with LoadLibrary or as a child of another dll, we need to make
    714             //sure it's loaded once with DosLoadModule
    715             pModule->setLoadLibrary();
    716         }
    717703        pModule->incDynamicLib();
    718704        pModule->AddRef();
     
    771757        {
    772758            /* OS/2 dll, system dll, converted dll or win32k took care of it.*/
    773             pModule = Win32DllBase::findModule(hDll);
    774             if (pModule)
     759            pModule = (Win32DllBase *)Win32LxDll::findModuleByOS2Handle(hDll);
     760            if(pModule)
    775761            {
    776                 if (pModule->isLxDll() && fPeLoader)
     762               
     763                if(pModule->isLxDll())
    777764                {
    778                     pModule->setLoadLibrary();
    779                     pModule->AddRef();
     765                        ((Win32LxDll *)pModule)->setDllHandleOS2(hDll);
     766                        if(fPeLoader) {
     767                                pModule->AddRef();
     768                        }
    780769                }
    781770                pModule->incDynamicLib();
    782771            }
     772            else {
     773                return hDll; //happens when LoadLibrary is called in kernel32's initterm (nor harmful)
     774            }
    783775            dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): returns 0x%x. Loaded %s using O32_LoadLibrary.",
    784776                     lpszLibFile, hFile, dwFlags, hDll, szModname));
    785             return hDll;
     777            return pModule->getInstanceHandle();
    786778        }
    787779        dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): O32_LoadLibrary(%s) failed. LastError=%d",
     
    10991091        lpszPath[rc-1] = 0;
    11001092  }
     1093  //only needed for call inside kernel32's initterm (profile init)
    11011094  else  rc = O32_GetModuleFileName(hinstModule, lpszPath, cchPath);
    11021095
    11031096  if(rc) {
    1104     dprintf(("KERNEL32: GetModuleFileName %s %d\n", lpszPath, hinstModule));
    1105   }
     1097        dprintf(("KERNEL32: GetModuleFileName %s %d\n", lpszPath, hinstModule));
     1098  }
     1099  else  dprintf(("KERNEL32: WARNING: GetModuleFileName %x not found!", hinstModule));
    11061100  return(rc);
    11071101}
     
    11321126  if(lpszModule == NULL) {
    11331127    if(WinExe)
    1134         hMod = WinExe->getInstanceHandle();
     1128            hMod = WinExe->getInstanceHandle();
    11351129    else    hMod = -1;
    11361130  }
    1137   else {
     1131  else
     1132  {
    11381133    strcpy(szModule, OSLibStripPath((char *)lpszModule));
    11391134    strupr(szModule);
     
    11581153        windll = Win32DllBase::findModule(szModule);
    11591154        if(windll) {
    1160             hMod = windll->getInstanceHandle();
    1161         }
    1162         else    hMod = OSLibiGetModuleHandleA((char *)lpszModule);
     1155              hMod = windll->getInstanceHandle();
     1156        }
    11631157    }
    11641158  }
  • trunk/src/msacm32/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.3 2000-02-05 02:02:34 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.4 2000-08-11 10:56:21 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748BOOL WINAPI MSACM32_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
     
    9192         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9293
    93          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     94         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     95         if(dllHandle == 0)
    9496                return 0UL;
    9597
    9698         break;
    9799      case 1 :
    98          UnregisterLxDll(hModule);
     100         if(dllHandle) {
     101                UnregisterLxDll(dllHandle);
     102         }
    99103         break;
    100104
  • trunk/src/oleaut32/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.6 2000-02-05 02:07:03 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.7 2000-08-11 10:56:22 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748//Global DLL Data
     
    108109         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    109110
    110          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     111         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     112         if(dllHandle == 0)
    111113                return 0UL;
    112114
     
    123125      }
    124126      case 1 :
    125          UnregisterLxDll(hModule);
     127         if(dllHandle) {
     128                UnregisterLxDll(dllHandle);
     129         }
    126130         break;
     131
    127132      default  :
    128133         return 0UL;
  • trunk/src/opengl/glide/cvg/initterm.cpp

    r2888 r3993  
    1 /* $Id: initterm.cpp,v 1.1 2000-02-25 00:37:33 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.2 2000-08-11 10:56:22 sandervl Exp $ */
    22
    33/*
     
    4242 extern DWORD _Resource_PEResTab;
    4343}
     44static HMODULE dllHandle = 0;
    4445
    4546BOOL WINAPI DllMain(HANDLE hInst, ULONG  ul_reason_for_call, LPVOID lpReserved);
     
    8990         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9091
    91          /*******************************************************************/
    92          /* A DosExitList routine must be used to clean up if runtime calls */
    93          /* are required and the runtime is dynamically linked.             */
    94          /*******************************************************************/
    95 
    96          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    97                 return 0UL;
     92         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     93         if(dllHandle == 0)
     94                return 0UL;
    9895
    9996         break;
    100 
    10197      case 1 :
    102          UnregisterLxDll(hModule);
     98         if(dllHandle) {
     99                UnregisterLxDll(dllHandle);
     100         }
    103101         break;
    104102
  • trunk/src/opengl/glide/sst1/initterm.cpp

    r2885 r3993  
    1 /* $Id: initterm.cpp,v 1.1 2000-02-25 00:31:06 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.2 2000-08-11 10:56:22 sandervl Exp $ */
    22
    33/*
     
    4242 extern DWORD _Resource_PEResTab;
    4343}
     44static HMODULE dllHandle = 0;
    4445
    4546BOOL WINAPI DllMain(HANDLE hInst, ULONG  ul_reason_for_call, LPVOID lpReserved);
     
    8990         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9091
    91          /*******************************************************************/
    92          /* A DosExitList routine must be used to clean up if runtime calls */
    93          /* are required and the runtime is dynamically linked.             */
    94          /*******************************************************************/
    95 
    96          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    97                 return 0UL;
     92         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     93         if(dllHandle == 0)
     94                return 0UL;
    9895
    9996         break;
    100 
    10197      case 1 :
    102          UnregisterLxDll(hModule);
     98         if(dllHandle) {
     99                UnregisterLxDll(dllHandle);
     100         }
    103101         break;
    104102
  • trunk/src/opengl/glu/initterm.cpp

    r2996 r3993  
    1 /* $Id: initterm.cpp,v 1.7 2000-03-04 19:10:12 jeroen Exp $ */
     1/* $Id: initterm.cpp,v 1.8 2000-08-11 10:56:22 sandervl Exp $ */
    22
    33/*
     
    4343 extern DWORD _Resource_PEResTab;
    4444}
     45static HMODULE dllHandle = 0;
    4546
    4647//******************************************************************************
     
    8687         _ctordtorInit();
    8788
    88          /*******************************************************************/
    89          /* A DosExitList routine must be used to clean up if runtime calls */
    90          /* are required and the runtime is dynamically linked.             */
    91          /*******************************************************************/
    92 
    93          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    94                 return 0UL;
    95 
    9689         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9790
     91         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     92         if(dllHandle == 0)
     93                return 0UL;
     94
    9895         break;
    99 
    10096      case 1 :
    101          UnregisterLxDll(hModule);
     97         if(dllHandle) {
     98                UnregisterLxDll(dllHandle);
     99         }
    102100         break;
    103101
  • trunk/src/opengl/glut/initterm.cpp

    r2996 r3993  
    1 /* $Id: initterm.cpp,v 1.8 2000-03-04 19:10:16 jeroen Exp $ */
     1/* $Id: initterm.cpp,v 1.9 2000-08-11 10:56:23 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748void CDECL Glut32Terminate(void);
     
    8889         _ctordtorInit();
    8990
    90          /*******************************************************************/
    91          /* A DosExitList routine must be used to clean up if runtime calls */
    92          /* are required and the runtime is dynamically linked.             */
    93          /*******************************************************************/
    94 
    95          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    96                 return 0UL;
    97 
    9891         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9992
     93         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     94         if(dllHandle == 0)
     95                return 0UL;
     96
    10097         break;
    101 
    10298      case 1 :
    103          UnregisterLxDll(hModule);
     99         if(dllHandle) {
     100                UnregisterLxDll(dllHandle);
     101         }
    104102         break;
    105103
  • trunk/src/opengl/mesa/3dfx/initterm.cpp

    r2938 r3993  
    1 /* $Id: initterm.cpp,v 1.1 2000-02-29 00:46:18 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.2 2000-08-11 10:56:23 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748int cleangraphics(void);
     
    9293         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9394
    94          /*******************************************************************/
    95          /* A DosExitList routine must be used to clean up if runtime calls */
    96          /* are required and the runtime is dynamically linked.             */
    97          /*******************************************************************/
    98 
    99          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    100                 return 0UL;
     95         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     96         if(dllHandle == 0)
     97                return 0UL;
    10198
    10299         break;
    103100
    104101      case 1 :
    105          UnregisterLxDll(hModule);
     102         if(dllHandle) {
     103                UnregisterLxDll(dllHandle);
     104         }
    106105         break;
    107106
  • trunk/src/opengl/mesa/initterm.cpp

    r3598 r3993  
    1 /* $Id: initterm.cpp,v 1.4 2000-05-23 20:40:38 jeroen Exp $ */
     1/* $Id: initterm.cpp,v 1.5 2000-08-11 10:56:23 sandervl Exp $ */
    22
    33/*
     
    4444 extern DWORD _Resource_PEResTab;
    4545}
     46static HMODULE dllHandle = 0;
    4647
    4748#ifdef DIVE
     
    9798         CheckVersionFromHMOD(PE2LX_VERSION, hModule);/* PLF Wed  98-03-18 05:28:48*/
    9899
    99          /*******************************************************************/
    100          /* A DosExitList routine must be used to clean up if runtime calls */
    101          /* are required and the runtime is dynamically linked.             */
    102          /*******************************************************************/
    103 
    104          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    105                 return 0UL;
     100         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     101         if(dllHandle == 0)
     102                return 0UL;
    106103
    107104#ifdef DIVE
     
    112109
    113110      case 1 :
    114          UnregisterLxDll(hModule);
     111         if(dllHandle) {
     112                UnregisterLxDll(dllHandle);
     113         }
    115114         break;
    116115
  • trunk/src/riched32/initterm.cpp

    r3515 r3993  
    1 /* $Id: initterm.cpp,v 1.1 2000-05-10 13:17:27 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.2 2000-08-11 10:56:24 sandervl Exp $ */
    22
    33/*
     
    4747BOOL WINAPI RICHED32_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
    4848}
     49static HMODULE dllHandle = 0;
     50
    4951//******************************************************************************
    5052//******************************************************************************
     
    9395         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9496
    95          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     97         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     98         if(dllHandle == 0)
    9699                return 0UL;
    97100
    98101         break;
    99102      case 1 :
    100          UnregisterLxDll(hModule);
     103         if(dllHandle) {
     104                UnregisterLxDll(dllHandle);
     105         }
    101106         break;
     107
    102108      default  :
    103109         return 0UL;
  • trunk/src/rpcrt4/initterm.cpp

    r3313 r3993  
    1 /* $Id: initterm.cpp,v 1.2 2000-04-03 07:53:26 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.3 2000-08-11 10:56:24 sandervl Exp $ */
    22
    33/*
     
    4545 extern DWORD _Resource_PEResTab;
    4646}
     47static HMODULE dllHandle = 0;
    4748
    4849//******************************************************************************
     
    9192         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9293
    93          /*******************************************************************/
    94          /* A DosExitList routine must be used to clean up if runtime calls */
    95          /* are required and the runtime is dynamically linked.             */
    96          /*******************************************************************/
    97 
    98          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     94         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     95         if(dllHandle == 0)
    9996                return 0UL;
    10097
     
    104101
    105102         break;
     103
    106104      case 1 :
    107          UnregisterLxDll(hModule);
     105         if(dllHandle) {
     106                UnregisterLxDll(dllHandle);
     107         }
    108108         break;
    109109      default  :
  • trunk/src/shell32/initterm.cpp

    r2649 r3993  
    1 /* $Id: initterm.cpp,v 1.10 2000-02-05 02:10:15 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.11 2000-08-11 10:56:25 sandervl Exp $ */
    22
    33/*
     
    4646 extern DWORD _Resource_PEResTab;
    4747}
     48static HMODULE dllHandle = 0;
    4849
    4950BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad);
     
    9394         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9495
    95          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     96         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab,
     97                                   SHELL32_MAJORIMAGE_VERSION, SHELL32_MINORIMAGE_VERSION,
     98                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
     99         if(dllHandle == 0)
    96100                return 0UL;
    97101
    98102         break;
    99103      case 1 :
    100          UnregisterLxDll(hModule);
     104         if(dllHandle) {
     105                UnregisterLxDll(dllHandle);
     106         }
    101107         break;
    102108      default  :
  • trunk/src/twain_32/initterm.cpp

    r2649 r3993  
    1 /* $Id: initterm.cpp,v 1.8 2000-02-05 02:11:41 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.9 2000-08-11 10:56:25 sandervl Exp $ */
    22
    33/*
     
    5454
    5555}
     56static HMODULE dllHandle = 0;
     57
    5658//******************************************************************************
    5759//******************************************************************************
     
    143145         }
    144146        }
    145          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     147
     148         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     149         if(dllHandle == 0)
    146150                return 0UL;
    147151
     
    151155                FreeLibrary(hTWAIN);
    152156         hTWAIN = 0;
    153          UnregisterLxDll(hModule);
     157         if(dllHandle) {
     158                UnregisterLxDll(dllHandle);
     159         }
    154160         break;
    155161      default  :
  • trunk/src/user32/initterm.cpp

    r3101 r3993  
    1 /* $Id: initterm.cpp,v 1.22 2000-03-13 13:10:45 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.23 2000-08-11 10:56:26 sandervl Exp $ */
    22
    33/*
     
    6363 extern DWORD _Resource_PEResTab;
    6464}
    65 
    6665DWORD hInstanceUser32 = 0;
    6766
     
    9392         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9493
    95          hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab);
     94         hInstanceUser32 = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab,
     95                                         USER32_MAJORIMAGE_VERSION, USER32_MINORIMAGE_VERSION,
     96                                         IMAGE_SUBSYSTEM_WINDOWS_GUI);
    9697         if(hInstanceUser32 == 0)
    9798                return 0UL;
     
    123124         break;
    124125      case 1 :
    125          UnregisterLxDll(hModule);
     126         if(hInstanceUser32) {
     127                UnregisterLxDll(hInstanceUser32);
     128         }
    126129         break;
    127130      default  :
  • trunk/src/version/version.cpp

    r2347 r3993  
    1 /* $Id: version.cpp,v 1.9 2000-01-06 20:10:07 sandervl Exp $ */
     1/* $Id: version.cpp,v 1.10 2000-08-11 10:56:26 sandervl Exp $ */
    22
    33/*
     
    2222#include <heapstring.h>
    2323#include <version.h>
     24#include <versionos2.h>
    2425
    2526ODINDEBUGCHANNEL(VERSION)
  • trunk/src/wing32/initterm.cpp

    r2650 r3993  
    1 /* $Id: initterm.cpp,v 1.2 2000-02-05 02:13:34 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.3 2000-08-11 10:56:27 sandervl Exp $ */
    22
    33/*
     
    4545 extern DWORD _Resource_PEResTab;
    4646}
     47static HMODULE dllHandle = 0;
     48
    4749//******************************************************************************
    4850//******************************************************************************
     
    9597          return 0UL;
    9698
    97         if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
    98           return 0UL;
     99         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     100         if(dllHandle == 0)
     101                return 0UL;
    99102
    100         break;
     103         break;
    101104      }
    102105      case 1 :
    103         UnregisterLxDll(hModule);
    104         break;
     106         if(dllHandle) {
     107                UnregisterLxDll(dllHandle);
     108         }
     109         break;
    105110      default  :
    106111         return 0UL;
  • trunk/src/winmm/initterm.cpp

    r2812 r3993  
    1 /* $Id: initterm.cpp,v 1.9 2000-02-17 14:09:30 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.10 2000-08-11 10:56:27 sandervl Exp $ */
    22
    33/*
     
    5050 extern DWORD _Resource_PEResTab;
    5151}
     52static HMODULE dllHandle = 0;
     53
    5254//******************************************************************************
    5355//******************************************************************************
     
    99101         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    100102
    101          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     103         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     104         if(dllHandle == 0)
    102105                return 0UL;
    103106
     
    105108      case 1 :
    106109         auxOS2Close(); /* SvL: Close aux device if necessary */
    107          UnregisterLxDll(hModule);
     110         if(dllHandle) {
     111                UnregisterLxDll(dllHandle);
     112         }
    108113         break;
    109114      default  :
  • trunk/src/wsock32/initterm.cpp

    r3229 r3993  
    1 /* $Id: initterm.cpp,v 1.11 2000-03-24 19:28:05 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.12 2000-08-11 10:56:27 sandervl Exp $ */
    22
    33/*
     
    4646 extern DWORD _Resource_PEResTab;
    4747}
     48static HMODULE dllHandle = 0;
     49
    4850//******************************************************************************
    4951//******************************************************************************
     
    9395         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9496
    95          if(RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab) == FALSE)
     97         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     98         if(dllHandle == 0)
    9699                return 0UL;
    97100
    98101         break;
    99102      case 1 :
    100          UnregisterLxDll(hModule);
     103         if(dllHandle) {
     104                UnregisterLxDll(dllHandle);
     105         }
    101106         break;
    102107      default  :
Note: See TracChangeset for help on using the changeset viewer.