Changeset 6015 for trunk/src/kernel32


Ignore:
Timestamp:
Jun 15, 2001, 11:42:49 AM (24 years ago)
Author:
bird
Message:

Corrected Pe2Lx bug in LoadLibrary. Added isPe2LxDLL.

Location:
trunk/src/kernel32
Files:
11 edited

Legend:

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

    r5782 r6015  
    1 /* $Id: windllbase.cpp,v 1.25 2001-05-22 14:25:34 sandervl Exp $ */
     1/* $Id: windllbase.cpp,v 1.26 2001-06-15 09:42:47 bird Exp $ */
    22
    33/*
     
    3232#include <pefile.h>
    3333#include <windllbase.h>
     34#include <winimagepe2lx.h>
     35#include <windllpe2lx.h>
     36#include <winimagelx.h>
     37#include <windlllx.h>
    3438#include <wprocess.h>
    3539#include "exceptions.h"
     
    824828//******************************************************************************
    825829//******************************************************************************
     830Win32DllBase *Win32DllBase::findModuleByOS2Handle(HINSTANCE hinstance)
     831{
     832    dlllistmutex.enter();
     833
     834    for (Win32DllBase *pMod = Win32DllBase::getFirst(); pMod; pMod = pMod->getNext())
     835    {
     836        if (pMod->isLxDll())
     837        {
     838            if (((Win32LxDll *)pMod)->getHMOD() == hinstance)
     839            {
     840                dlllistmutex.leave();
     841                return(pMod);
     842            }
     843        }
     844        else if (pMod->isPe2LxDll())
     845        {
     846            if (((Win32Pe2LxDll *)pMod)->getHMOD() == hinstance)
     847            {
     848                dlllistmutex.leave();
     849                return(pMod);
     850            }
     851        }
     852    }
     853
     854    dlllistmutex.leave();
     855    return(NULL);
     856}
     857//******************************************************************************
     858//******************************************************************************
    826859BOOL Win32DllBase::isDll()
    827860{
  • trunk/src/kernel32/windllbase.h

    r4523 r6015  
    1 /* $Id: windllbase.h,v 1.7 2000-10-23 13:42:43 sandervl Exp $ */
     1/* $Id: windllbase.h,v 1.8 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    3030#define LOAD_WITH_ALTERED_SEARCH_PATH   0x00000008
    3131
    32 #define DLL_EXTENSION           ".DLL"
     32#define DLL_EXTENSION       ".DLL"
    3333
    3434//odin.ini section names to lookup renamed dlls
    3535//i.e. OLE32 -> OLE32OS2
    36 #define DLLRENAMEWIN_SECTION    "DLLRENAMEWIN"
     36#define DLLRENAMEWIN_SECTION    "DLLRENAMEWIN"
    3737//i.e. OLE32OS2 -> OLE32
    3838#define DLLRENAMEOS2_SECTION    "DLLRENAMEOS2"
     
    4545
    4646#ifdef DEBUG
    47 virtual ULONG     AddRef(char *parentname = NULL);
     47virtual ULONG     AddRef(char *parentname = NULL);
    4848#else
    4949virtual ULONG     AddRef();
    5050#endif
    51 virtual ULONG     Release();
     51virtual ULONG     Release();
    5252
    53         char     *getName()          { return szModule; };
     53    char     *getName()          { return szModule; };
    5454
    5555        //do not call the ATTACH_THREAD, DETACH_THREAD functions
    56         void      disableThreadLibraryCalls()  { fSkipThreadEntryCalls = TRUE; };
    57         void      disableLibraryCalls()        { fSkipEntryCalls = fSkipThreadEntryCalls = TRUE; };
     56    void      disableThreadLibraryCalls()  { fSkipThreadEntryCalls = TRUE; };
     57    void      disableLibraryCalls()        { fSkipEntryCalls = fSkipThreadEntryCalls = TRUE; };
    5858
    59         Win32DllBase *getNext()  { return next; };
    60 static  Win32DllBase *getFirst();
     59    Win32DllBase *getNext()  { return next; };
     60static  Win32DllBase *getFirst();
    6161
    6262//Send DLL_THREAD_ATTACH message to all dlls for a new thread
     
    7272static  void      tlsDetachThreadFromAllDlls();
    7373
    74         BOOL      attachProcess();
    75         BOOL      detachProcess();
    76         BOOL      attachThread();
    77         BOOL      detachThread();
     74    BOOL      attachProcess();
     75    BOOL      detachProcess();
     76    BOOL      attachThread();
     77    BOOL      detachThread();
    7878
    79         //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
     79    //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
    8080        //(== not loaded on behalf of another dll or the main exe)
    81         void      incDynamicLib();
    82         void      decDynamicLib();
    83         BOOL      isDynamicLib()   { return nrDynamicLibRef != 0; };
    84  
    85         void      setUnloadOrder(Win32ImageBase *parent);
     81    void      incDynamicLib();
     82    void      decDynamicLib();
     83    BOOL      isDynamicLib()   { return nrDynamicLibRef != 0; };
    8684
    87         void      updateDependencies();
     85    void      setUnloadOrder(Win32ImageBase *parent);
    8886
    89         BOOL      RemoveCircularDependency(Win32DllBase *parent);
     87    void      updateDependencies();
    9088
    91         //Only called for kernel32
    92         void      DisableUnload()  { fDisableUnload = TRUE; };
     89    BOOL      RemoveCircularDependency(Win32DllBase *parent);
     90
     91    //Only called for kernel32
     92    void      DisableUnload()  { fDisableUnload = TRUE; };
    9393
    9494static  void      deleteDynamicLibs();
    9595static  void      deleteAll();
    9696
    97 static  BOOL      isSystemDll(char *szFileName);
     97static  BOOL      isSystemDll(char *szFileName);
    9898
    99 virtual BOOL      isLxDll() = 0;
     99virtual BOOL      isPe2LxDll() const = 0;
     100virtual BOOL      isLxDll() const = 0;
    100101virtual BOOL      isDll();
    101102
     
    107108static  Win32DllBase *findModule(WIN32DLLENTRY DllEntryPoint);
    108109static  Win32DllBase *findModuleByAddr(ULONG address);
     110static  Win32DllBase *findModuleByOS2Handle(HINSTANCE hinstance);
    109111
    110112#ifdef DEBUG_ENABLELOG_LEVEL2
    111         void          printListOfDlls();
     113    void          printListOfDlls();
    112114#endif
    113115
    114116protected:
    115117#ifdef DEBUG
    116         void          printDependencies(char *parent);
     118    void          printDependencies(char *parent);
    117119#endif
    118120
    119         BOOL          fSkipThreadEntryCalls, fUnloaded, fAttachedToProcess, fSkipEntryCalls;
     121    BOOL          fSkipThreadEntryCalls, fUnloaded, fAttachedToProcess, fSkipEntryCalls;
    120122
    121         WIN32DLLENTRY dllEntryPoint;
     123    WIN32DLLENTRY dllEntryPoint;
    122124
    123         LONG          referenced;
     125    LONG          referenced;
    124126
    125         //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
     127    //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
    126128        //(== not loaded on behalf of another dll or the main exe)
    127         BOOL          nrDynamicLibRef;
     129    BOOL          nrDynamicLibRef;
    128130
    129         BOOL          fInserted; //inserted in dll list
     131    BOOL          fInserted; //inserted in dll list
    130132
    131         //This flag is set when a dll has been loaded with DosLoadModule
    132         BOOL          fDisableUnload;
     133    //This flag is set when a dll has been loaded with DosLoadModule
     134    BOOL          fDisableUnload;
    133135
    134136static  Win32DllBase *head;
    135         Win32DllBase *next;
     137    Win32DllBase *next;
    136138private:
    137139static  Queue         loadLibDlls;
  • trunk/src/kernel32/windlllx.cpp

    r5782 r6015  
    1 /* $Id: windlllx.cpp,v 1.19 2001-05-22 14:25:36 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.20 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    66 * Copyright 1999-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 *
    8  * TODO: Unloading of dlls probably needs to be fixed due to OS/2 bug 
     8 * TODO: Unloading of dlls probably needs to be fixed due to OS/2 bug
    99 *       (wrong unload order of dlls)
    1010 *
     
    1818#define INCL_DOSMISC             /* DOS Miscellanous values  */
    1919#define INCL_WIN
    20 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     20#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    2121#include <os2newapi.h>
    2222#include <stdio.h>
     
    3737#include <exe386.h>
    3838
    39 #define DBG_LOCALLOG    DBG_windlllx
     39#define DBG_LOCALLOG    DBG_windlllx
    4040#include "dbglocal.h"
    4141
     
    4444//System dlls set EntryPoint to 0
    4545//Parameters:
    46 //  HINSTANCE hInstance         - OS/2 module handle
     46//  HINSTANCE hInstance     - OS/2 module handle
    4747//  WIN32DLLENTRY EntryPoint    - Win32 dll entrypoint address
    4848//  PVOID pResData              - pointer to win32 resource data
     
    5454//Returns: Odin32 module handle
    5555//******************************************************************************
    56 DWORD WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, 
    57                              PVOID pResData, 
    58                              DWORD MajorImageVersion, 
     56DWORD WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint,
     57                             PVOID pResData,
     58                             DWORD MajorImageVersion,
    5959                             DWORD MinorImageVersion,
    6060                             DWORD Subsystem)
    61 { 
     61{
    6262 APIRET        rc;
    6363 Win32LxDll    *windll;
     
    6666
    6767   if(OSLibGetDllName(hInstance, szFileName, sizeof(szFileName)) == FALSE) {
    68         dprintf(("ERROR: RegisterLxDll: OSLibGetDllName %x failed!!", hInstance));
    69         return 0;
     68    dprintf(("ERROR: RegisterLxDll: OSLibGetDllName %x failed!!", hInstance));
     69    return 0;
    7070   }
    7171   dprintf(("RegisterLxDll %x %s", hInstance, szFileName));
    72    //Make sure DosLoadModule is called at least once for a dll (to make sure 
     72   //Make sure DosLoadModule is called at least once for a dll (to make sure
    7373   //OS/2 doesn't unload the dll when it's still needed)
    7474   rc = DosLoadModule(szErrName, sizeof(szErrName), szFileName, &hInstance);
    75    if(rc != 0) { 
    76         dprintf(("ERROR: RegisterLxDll: DosLoadModule %s failed (rc=%d)!!", szFileName, rc));
    77         return 0;
     75   if(rc != 0) {
     76    dprintf(("ERROR: RegisterLxDll: DosLoadModule %s failed (rc=%d)!!", szFileName, rc));
     77    return 0;
    7878   }
    7979
     
    8181                           MinorImageVersion, Subsystem);
    8282   if(windll == NULL) {
    83         dprintf(("RegisterLxDll: windll == NULL!!!"));
    84         return 0;
     83    dprintf(("RegisterLxDll: windll == NULL!!!"));
     84    return 0;
    8585   }
    8686   if(!fPeLoader) {
    87         windll->AddRef();
    88 
    89         if(windll->attachProcess() == 0)
    90                 return 0;
    91 
    92         return windll->getInstanceHandle();
     87    windll->AddRef();
     88
     89    if(windll->attachProcess() == 0)
     90        return 0;
     91
     92    return windll->getInstanceHandle();
    9393   }
    9494   IMAGE_DOS_HEADER doshdr;
     
    105105   rc = DosQueryHeaderInfo(hInstance, 0, &doshdr, sizeof(IMAGE_DOS_HEADER), QHINF_READFILE);
    106106   if(rc) {
    107         goto hdrerror;
     107    goto hdrerror;
    108108   }
    109109   rc = DosQueryHeaderInfo(hInstance, doshdr.e_lfanew, &lxhdr, sizeof(e32_exe), QHINF_READFILE);
    110110   if(rc) {
    111         goto hdrerror;
     111    goto hdrerror;
    112112   }
    113113   offset = doshdr.e_lfanew + lxhdr.e32_impmod;
    114114   for(i=0;i<lxhdr.e32_impmodcnt;i++) {
    115         rc = DosQueryHeaderInfo(hInstance, offset, &modsize, 1, QHINF_READFILE);
    116         if(rc) {
    117                 goto hdrerror;
    118         }
    119         rc = DosQueryHeaderInfo(hInstance, offset+1, &modulename, min(modsize, sizeof(modulename)), QHINF_READFILE);
    120         if(rc) {
    121                 goto hdrerror;
    122         }
    123         modulename[modsize] = 0;
    124         windlldep = Win32DllBase::findModule(modulename, TRUE);
    125         if(windlldep && strcmp(windlldep->getModuleName(), windll->getModuleName())) {
    126                 dprintf(("RegisterLxDll: Add dependency %s -> %s", windll->getModuleName(), modulename));
    127                 windll->addDependency(windlldep);
    128         }
     115    rc = DosQueryHeaderInfo(hInstance, offset, &modsize, 1, QHINF_READFILE);
     116    if(rc) {
     117        goto hdrerror;
     118    }
     119    rc = DosQueryHeaderInfo(hInstance, offset+1, &modulename, min(modsize, sizeof(modulename)), QHINF_READFILE);
     120    if(rc) {
     121        goto hdrerror;
     122    }
     123    modulename[modsize] = 0;
     124    windlldep = Win32DllBase::findModule(modulename, TRUE);
     125    if(windlldep && strcmp(windlldep->getModuleName(), windll->getModuleName())) {
     126        dprintf(("RegisterLxDll: Add dependency %s -> %s", windll->getModuleName(), modulename));
     127        windll->addDependency(windlldep);
     128    }
    129129        else    dprintf(("HARMLESS WARNING: Can't find dll %s referenced by %s", modulename, windll->getModuleName()));
    130         offset += modsize + 1;
     130    offset += modsize + 1;
    131131   }
    132132   return windll->getInstanceHandle();
     
    146146   //Don't do it either after ExitProcess has been called
    147147   if(!fPeLoader || WinExe == NULL)
    148         return TRUE;
     148    return TRUE;
    149149
    150150   windll = Win32DllBase::findModule(hInstance);
    151151   if(!windll) {
    152         dprintf(("UnregisterLxDll: Can't find dll with handle %x (already deleted)", hInstance));
    153         return TRUE; //already deleted by Win32LxDll::Release
     152    dprintf(("UnregisterLxDll: Can't find dll with handle %x (already deleted)", hInstance));
     153    return TRUE; //already deleted by Win32LxDll::Release
    154154   }
    155155   dprintf(("UnregisterLxDll %s", windll->getModuleName()));
     
    162162Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData,
    163163                       DWORD MajorImageVersion, DWORD MinorImageVersion,
    164                        DWORD Subsystem) 
     164                       DWORD Subsystem)
    165165                : Win32ImageBase(hInstance),
    166                   Win32LxImage(hInstance, pResData), 
     166                  Win32LxImage(hInstance, pResData),
    167167                  Win32DllBase(hInstance, EntryPoint)
    168168{
     
    170170  this->MinorImageVersion = MinorImageVersion;
    171171  this->Subsystem         = Subsystem;
    172  
     172
    173173  if(EntryPoint == NULL) {
    174         fSkipThreadEntryCalls    = TRUE;
    175         fAttachedToProcess = TRUE;
     174    fSkipThreadEntryCalls    = TRUE;
     175    fAttachedToProcess = TRUE;
    176176  }
    177177  hinstanceOS2 = hInstance;
     
    206206
    207207  if(!fPeLoader)
    208         return ret;
    209 
    210   if(referenced == 1) 
     208    return ret;
     209
     210  if(referenced == 1)
    211211  {
    212         item = loadedDlls.Head();
    213         while(item) {
    214                 dll = (Win32DllBase *)loadedDlls.getItem(item);
    215                 if(dll == NULL) {
    216                         dprintf(("ERROR: Win32DllBase::AddRef: dll item == NULL!!"));
    217                         DebugInt3();
    218                         return -1;
    219                 }
     212    item = loadedDlls.Head();
     213    while(item) {
     214        dll = (Win32DllBase *)loadedDlls.getItem(item);
     215        if(dll == NULL) {
     216            dprintf(("ERROR: Win32DllBase::AddRef: dll item == NULL!!"));
     217            DebugInt3();
     218            return -1;
     219        }
    220220#ifdef DEBUG
    221                 dll->AddRef(getModuleName());
     221        dll->AddRef(getModuleName());
    222222#else
    223                 dll->AddRef();
     223        dll->AddRef();
    224224#endif
    225                 item = loadedDlls.getNext(item);
    226         }
    227         if(attachProcess() == 0) {
    228                 dprintf(("WARNING: Dll %s refused to be loaded; aborting", getName()));
    229                 return -1;
    230         }
     225        item = loadedDlls.getNext(item);
     226    }
     227    if(attachProcess() == 0) {
     228        dprintf(("WARNING: Dll %s refused to be loaded; aborting", getName()));
     229        return -1;
     230    }
    231231  }
    232   return ret; 
     232  return ret;
    233233}
    234234//******************************************************************************
    235235//******************************************************************************
    236236ULONG Win32LxDll::Release()
    237 { 
     237{
    238238 HINSTANCE     hinst;
    239239 WIN32DLLENTRY EntryPointTmp        = dllEntryPoint;
     
    250250  ret = Win32DllBase::Release();
    251251  if(ret == 0 && !fNoUnload) {//only set for kernel32.dll (fDisableUnload)
    252         //DosFreeModule sends a termination message to the dll.
     252    //DosFreeModule sends a termination message to the dll.
    253253        //The LX dll informs us when it's removed (UnregisterDll call)
    254         rc = DosFreeModule(hinst);
    255         if(rc) {
     254    rc = DosFreeModule(hinst);
     255    if(rc) {
    256256            dprintf(("Win32LxDll::Release: DosFreeModule %x returned %d", hinst, rc));
    257257            if(rc == ERROR_INVALID_ACCESS && !fExitProcess) {
     
    263263                //            don't fail!
    264264                dprintf(("WORKAROUND: Re-register the dll so future LoadLibrary calls don't fail!"));
    265                 RegisterLxDll(hinst, EntryPointTmp, pResDataTmp, 
    266                               MajorImageVersionTmp, 
     265                RegisterLxDll(hinst, EntryPointTmp, pResDataTmp,
     266                              MajorImageVersionTmp,
    267267                              MinorImageVersionTmp,
    268268                              SubsystemTmp);
     
    286286                else    DebugInt3();
    287287            }
    288         }
     288    }
    289289  }
    290290  return(ret);
     
    292292//******************************************************************************
    293293//******************************************************************************
    294 BOOL Win32LxDll::isLxDll()
     294BOOL Win32LxDll::isPe2LxDll() const
     295{
     296  return FALSE;
     297}
     298//******************************************************************************
     299//******************************************************************************
     300BOOL Win32LxDll::isLxDll() const
    295301{
    296302  return TRUE;
     
    298304//******************************************************************************
    299305//******************************************************************************
    300 void Win32LxDll::setDllHandleOS2(HINSTANCE hInstanceOS2) 
    301 { 
     306void Win32LxDll::setDllHandleOS2(HINSTANCE hInstanceOS2)
     307{
    302308  //Loaded with LoadLibrary(Ex); no need for a 2nd DosLoadModule
    303309  //Dlls that are indirectly loaded (i.e. GDI32->KERNEL32 dependancy) need
    304310  //this additional DosLoadModule (and setDllHandleOS2 isn't called for those)
    305311  if(this->hinstanceOS2) {
    306         DosFreeModule(this->hinstanceOS2);
     312    DosFreeModule(this->hinstanceOS2);
    307313  }
    308314  this->hinstanceOS2 = hInstanceOS2;
     
    312318Win32LxDll *Win32LxDll::findModuleByOS2Handle(HINSTANCE hinstance)
    313319{
    314    dlllistmutex.enter();
    315 
    316    Win32DllBase *mod = Win32DllBase::getFirst();
    317    while(mod != NULL) {
    318         if(mod->isLxDll()) {
    319                 Win32LxDll *lxdll = (Win32LxDll *)mod;
    320                 if(lxdll->hinstanceOS2 == hinstance) {
    321                         dlllistmutex.leave();
    322                         return(lxdll);
    323                 }
     320    dlllistmutex.enter();
     321
     322    Win32DllBase *mod = Win32DllBase::getFirst();
     323    while (mod != NULL)
     324    {
     325        if (mod->isLxDll())
     326        {
     327            Win32LxDll *lxdll = (Win32LxDll *)mod;
     328            if (lxdll->hinstanceOS2 == hinstance)
     329            {
     330                dlllistmutex.leave();
     331                return(lxdll);
     332            }
    324333        }
    325         mod = mod->getNext();
    326    }
    327    dlllistmutex.leave();
    328    return(NULL);
    329 }
    330 //******************************************************************************
    331 //******************************************************************************
     334        mod = mod->getNext();
     335    }
     336    dlllistmutex.leave();
     337    return(NULL);
     338}
     339//******************************************************************************
     340//******************************************************************************
  • trunk/src/kernel32/windlllx.h

    r5075 r6015  
    1 /* $Id: windlllx.h,v 1.3 2001-02-09 18:31:05 sandervl Exp $ */
     1/* $Id: windlllx.h,v 1.4 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    1919{
    2020public:
    21         Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, PVOID pResData,
     21    Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, PVOID pResData,
    2222                   DWORD MajorImageVersion, DWORD MinorImageVersion,
    2323                   DWORD Subsystem);
     
    2525
    2626#ifdef DEBUG
    27 virtual ULONG     AddRef(char *parentname = NULL);
     27virtual ULONG     AddRef(char *parentname = NULL);
    2828#else
    2929virtual ULONG     AddRef();
    3030#endif
    31 virtual ULONG     Release();
     31virtual ULONG     Release();
    3232
    3333        void      setDllHandleOS2(HINSTANCE hInstanceOS2);
    3434
    35 virtual BOOL      isLxDll();
     35virtual BOOL      isPe2LxDll() const;
     36virtual BOOL      isLxDll() const;
    3637
    3738static  Win32LxDll *findModuleByOS2Handle(HINSTANCE hinstance);
    38    
     39
    3940protected:
    4041        DWORD     MajorImageVersion;
  • trunk/src/kernel32/windllpe2lx.cpp

    r3993 r6015  
    1 /* $Id: windllpe2lx.cpp,v 1.8 2000-08-11 10:56:19 sandervl Exp $ */
     1/* $Id: windllpe2lx.cpp,v 1.9 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    3535#include "console.h"
    3636
    37 #define DBG_LOCALLOG    DBG_windllpe2lx
     37#define DBG_LOCALLOG    DBG_windllpe2lx
    3838#include "dbglocal.h"
    3939
     
    173173}
    174174
     175
     176/**
     177 * Simple question: Pe2Lx DLL? Yes!
     178 * @returns   TRUE.
     179 * @status    completely implemented.
     180 * @author    knut st. osmundsen
     181 */
     182BOOL Win32Pe2LxDll::isPe2LxDll() const
     183{
     184    return TRUE;
     185}
     186
     187
    175188/**
    176189 * Simple question: -Native LX dll?
     
    180193 * @author    Sander van Leeuwen
    181194 */
    182 BOOL Win32Pe2LxDll::isLxDll()
     195BOOL Win32Pe2LxDll::isLxDll() const
    183196{
    184197    return FALSE;
    185198}
    186199
     200
     201
  • trunk/src/kernel32/windllpe2lx.h

    r3074 r6015  
    1 /* $Id: windllpe2lx.h,v 1.1 2000-03-10 16:12:02 sandervl Exp $ */
     1/* $Id: windllpe2lx.h,v 1.2 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    2626    /** @cat Constructor/Destructor */
    2727    Win32Pe2LxDll(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG);
    28     virtual ~Win32Pe2LxDll();
    29     BOOL     init();
     28    virtual     ~Win32Pe2LxDll();
     29    BOOL        init();
    3030
    3131    /** @cat Query */
    32     virtual BOOL  isLxDll();
     32    BOOL        isPe2LxDll() const;
     33    BOOL        isLxDll() const;
    3334};
    3435
  • trunk/src/kernel32/windllpeldr.cpp

    r4523 r6015  
    1 /* $Id: windllpeldr.cpp,v 1.8 2000-10-23 13:42:44 sandervl Exp $ */
     1/* $Id: windllpeldr.cpp,v 1.9 2001-06-15 09:42:48 bird Exp $ */
    22
    33/*
     
    1616#define INCL_DOSMISC             /* DOS Miscellanous values  */
    1717#define INCL_WIN
    18 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     18#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    1919#include <stdio.h>
    2020#include <string.h>
     
    3131#include "oslibdos.h"
    3232
    33 #define DBG_LOCALLOG    DBG_windllpeldr
     33#define DBG_LOCALLOG    DBG_windllpeldr
    3434#include "dbglocal.h"
    3535
     
    3737//******************************************************************************
    3838//******************************************************************************
    39 Win32PeLdrDll::Win32PeLdrDll(char *szDllName, Win32ImageBase *parentImage) 
    40                 : Win32ImageBase(-1), 
    41                   Win32DllBase(-1, 0, parentImage), 
     39Win32PeLdrDll::Win32PeLdrDll(char *szDllName, Win32ImageBase *parentImage)
     40                : Win32ImageBase(-1),
     41                  Win32DllBase(-1, 0, parentImage),
    4242                  Win32PeLdrImage(szDllName, FALSE)
    4343{
     
    6363  strupr(szFileName);
    6464  if(!strchr(szFileName, (int)'.')) {
    65         strcat(szFileName, DLL_EXTENSION);
     65    strcat(szFileName, DLL_EXTENSION);
    6666  }
    6767  dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    6868  if(dllfile == NULL) {//search in libpath for dll
    69         syspath = getenv("WIN32LIBPATH");
    70         if(syspath) {
    71                 strcpy(modname, syspath);
    72                 if(modname[strlen(modname)-1] != '\\') {
    73                         strcat(modname, "\\");
    74                 }
    75                 strcat(modname, szFileName);
    76                 strcpy(szFileName, modname);
    77         }
     69    syspath = getenv("WIN32LIBPATH");
     70    if(syspath) {
     71        strcpy(modname, syspath);
     72        if(modname[strlen(modname)-1] != '\\') {
     73            strcat(modname, "\\");
     74        }
     75        strcat(modname, szFileName);
     76        strcpy(szFileName, modname);
     77    }
    7878  }
    79   else  OSLibDosClose(dllfile);
     79  else  OSLibDosClose(dllfile);
    8080  fRet = Win32PeLdrImage::init(0);
    8181  dllEntryPoint = (WIN32DLLENTRY)entryPoint;
    8282
    8383  if(!(fh.Characteristics & IMAGE_FILE_DLL)) {
    84         //executable loaded as dll; don't call entrypoint
    85         dprintf(("WARNING: Exe %s loaded as dll; entrypoint not called", szFileName));
    86         dllEntryPoint = NULL;
     84    //executable loaded as dll; don't call entrypoint
     85    dprintf(("WARNING: Exe %s loaded as dll; entrypoint not called", szFileName));
     86    dllEntryPoint = NULL;
    8787  }
    8888  return fRet;
     
    9090//******************************************************************************
    9191//******************************************************************************
    92 BOOL Win32PeLdrDll::isLxDll()
     92BOOL Win32PeLdrDll::isPe2LxDll() const
    9393{
    9494  return FALSE;
     
    9696//******************************************************************************
    9797//******************************************************************************
     98BOOL Win32PeLdrDll::isLxDll() const
     99{
     100  return FALSE;
     101}
     102//******************************************************************************
     103//******************************************************************************
  • trunk/src/kernel32/windllpeldr.h

    r3074 r6015  
    1 /* $Id: windllpeldr.h,v 1.1 2000-03-10 16:12:02 sandervl Exp $ */
     1/* $Id: windllpeldr.h,v 1.2 2001-06-15 09:42:49 bird Exp $ */
    22
    33/*
     
    1919{
    2020public:
    21         Win32PeLdrDll(char *szDllName, Win32ImageBase *parentImage = NULL);
     21    Win32PeLdrDll(char *szDllName, Win32ImageBase *parentImage = NULL);
    2222virtual ~Win32PeLdrDll();
    2323
    2424virtual BOOL  init(ULONG reservedMem);
    2525
    26 virtual BOOL  isLxDll();
     26        BOOL  isLxDll() const;
     27        BOOL  isPe2LxDll() const;
    2728
    2829protected:
  • trunk/src/kernel32/winimagelx.h

    r3993 r6015  
    1 /* $Id: winimagelx.h,v 1.2 2000-08-11 10:56:19 sandervl Exp $ */
     1/* $Id: winimagelx.h,v 1.3 2001-06-15 09:42:49 bird Exp $ */
    22
    33/*
     
    2121virtual ~Win32LxImage();
    2222
    23 virtual ULONG     getApi(char *name);
     23virtual ULONG     getApi(char *name);
    2424virtual ULONG     getApi(int ordinal);
    2525
    2626        LPVOID    buildHeader(DWORD MajorImageVersion, DWORD MinorImageVersion,
    2727                              DWORD Subsystem);
    28 
     28        /** Get the OS/2 module handle.
     29         * @returns OS/2 module handle. */
     30        HINSTANCE   getHMOD() const { return hinstance; }
    2931protected:
    3032  LPVOID header;
  • trunk/src/kernel32/winimagepe2lx.h

    r4368 r6015  
    1 /* $Id: winimagepe2lx.h,v 1.6 2000-10-02 13:35:23 bird Exp $ */
     1/* $Id: winimagepe2lx.h,v 1.7 2001-06-15 09:42:49 bird Exp $ */
    22
    33/*
     
    4040    /** @cat constructor and destructor */
    4141    Win32Pe2LxImage(HINSTANCE hinstance, BOOL fWin32k);
    42     virtual ~Win32Pe2LxImage();
    43     virtual BOOL init();
     42    virtual         ~Win32Pe2LxImage();
     43    virtual BOOL    init();
    4444
    4545    /** @cat Exports */
    46     virtual ULONG getApi(char *name);
    47     virtual ULONG getApi(int ordinal);
     46    virtual ULONG   getApi(char *name);
     47    virtual ULONG   getApi(int ordinal);
     48
     49    /** @cat Queries */
     50    /** Get the OS/2 module handle.
     51     * @returns OS/2 module handle. */
     52    HINSTANCE       getHMOD() const { return hmod; }
    4853
    4954private:
    5055    /** @cat constructor helpers */
    51     ULONG    getSections();
    52     ULONG    setSectionRVAs();
    53     VOID     cleanup();
     56    ULONG           getSections();
     57    ULONG           setSectionRVAs();
     58    VOID            cleanup();
    5459
    5560protected:
    5661    /** @cat RVA -> pointer */
    5762    /* these should be moved to winimagebase some day... */
    58     PVOID    getPointerFromRVA(ULONG ulRVA);
    59     PVOID    getPointerFromPointer(PVOID pv);
    60     LONG     getSectionIndexFromRVA(ULONG ulRVA);
    61     BOOL     validateRealPointer(PVOID pv);
     63    PVOID           getPointerFromRVA(ULONG ulRVA);
     64    PVOID           getPointerFromPointer(PVOID pv);
     65    LONG            getSectionIndexFromRVA(ULONG ulRVA);
     66    BOOL            validateRealPointer(PVOID pv);
    6267
    6368    PSECTION            paSections; /* Used by getPointerFromRVA and created by getSections and
     
    6974    BOOL                fWin32k;    /* flag which indicates wether this is a Win32k loaded
    7075                                     * module (TRUE) or and Pe2Lx module (FALSE). */
    71     HMODULE hmod;                   /* OS/2 handle of the module. */
     76    HMODULE             hmod;       /* OS/2 handle of the module. */
    7277};
    7378
  • trunk/src/kernel32/wprocess.cpp

    r5974 r6015  
    1 /* $Id: wprocess.cpp,v 1.124 2001-06-12 17:03:34 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.125 2001-06-15 09:42:49 bird Exp $ */
    22
    33/*
     
    789789
    790790    /** @sketch
    791      *  IF dwFlags == 0 && (!fPeLoader || !fPE) THEN
     791     *  IF (!fPeLoader || fPE == failure) THEN
    792792     *      Try load the executable using LoadLibrary
    793793     *      IF successfully loaded THEN
     
    802802     */
    803803    //only call OS/2 if LX binary or win32k process
    804     if(!fPeLoader || fPE != ERROR_SUCCESS)
     804    if (!fPeLoader || fPE != ERROR_SUCCESS)
    805805    {
    806806        hDll = OSLibDosLoadModule(szModname);
     
    808808        {
    809809            /* OS/2 dll, system dll, converted dll or win32k took care of it. */
    810             pModule = (Win32DllBase *)Win32LxDll::findModuleByOS2Handle(hDll);
    811             if(pModule)
     810            pModule = Win32DllBase::findModuleByOS2Handle(hDll);
     811            if (pModule)
    812812            {
    813                 if(pModule->isLxDll())
     813                if (pModule->isLxDll())
    814814                {
    815                         ((Win32LxDll *)pModule)->setDllHandleOS2(hDll);
    816                         if(fPeLoader)
    817                         {
    818                             if(pModule->AddRef() == -1) {//-1 -> load failed (attachProcess)
    819                                 dprintf(("Dll %s refused to be loaded; aborting", szModname));
    820                                 delete pModule;
    821                                 return 0;
    822                             }
    823                         }
     815                    ((Win32LxDll *)pModule)->setDllHandleOS2(hDll);
     816                    if (fPeLoader && pModule->AddRef() == -1)
     817                    {   //-1 -> load failed (attachProcess)
     818                        delete pModule;
     819                        SetLastError(ERROR_INVALID_EXE_SIGNATURE);
     820                        dprintf(("Dll %s refused to be loaded; aborting", szModname));
     821                        return 0;
     822                    }
     823
    824824                }
    825825                pModule->incDynamicLib();
    826826            }
    827             else
    828             if(fExeStarted) {
     827            else if (fExeStarted) {
    829828                OSLibDosFreeModule(hDll);
    830829                SetLastError(ERROR_INVALID_EXE_SIGNATURE);
     
    15651564#ifdef DEBUG
    15661565    if(lpStartupInfo) {
    1567         dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
    1568         dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
    1569         dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
    1570         dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
    1571         dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
    1572         dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
    1573         dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
    1574         dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
    1575         dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
    1576         dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
    1577         dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
    1578         dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
    1579         dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
    1580         dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
    1581         dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
     1566    dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
     1567    dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
     1568    dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
     1569    dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
     1570    dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
     1571    dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
     1572    dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
     1573    dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
     1574    dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
     1575    dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
     1576    dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
     1577    dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
     1578    dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
     1579    dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
     1580    dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
    15821581    }
    15831582#endif
     
    17011700
    17021701    dprintf(("KERNEL32: CreateProcess %s\n", cmdline));
    1703    
     1702
    17041703    DWORD Characteristics, SubSystem, fNEExe;
    17051704    if(Win32ImageBase::isPEImage(exename, &Characteristics, &SubSystem, &fNEExe) == 0) {
     
    17091708        }
    17101709        else lpszPE = "PE.EXE";
    1711    
     1710
    17121711        //SvL: Allright. Before we call O32_CreateProcess, we must take care of
    17131712        //     lpCurrentDirectory ourselves. (Open32 ignores it!)
    17141713        if(lpCurrentDirectory) {
    17151714            char *newcmdline;
    1716    
     1715
    17171716            newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32);
    17181717            sprintf(newcmdline, "%s /OPT:[CURDIR=%s] %s", lpszPE, lpCurrentDirectory, cmdline);
     
    17331732                               lpProcessInfo);
    17341733    }
    1735     else 
     1734    else
    17361735    if(fNEExe) {//16 bits windows app
    17371736        char *newcmdline;
    1738        
     1737
    17391738        newcmdline = (char *)malloc(strlen(cmdline) + 16);
    17401739        sprintf(newcmdline, "w16odin.exe %s", cmdline);
Note: See TracChangeset for help on using the changeset viewer.