Changeset 4474 for trunk/src


Ignore:
Timestamp:
Oct 10, 2000, 7:14:09 PM (25 years ago)
Author:
sandervl
Message:

pe loader fixes, add system32\drivers dir during installation, add build date + time during kernel32 load

Location:
trunk/src/kernel32
Files:
2 deleted
14 edited

Legend:

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

    r4372 r4474  
    1 /* $Id: dbglocal.cpp,v 1.11 2000-10-02 13:38:55 sandervl Exp $ */
     1/* $Id: dbglocal.cpp,v 1.12 2000-10-10 17:14:02 sandervl Exp $ */
    22
    33/*
     
    9898"cvtbitmap",
    9999"hmmmap",
    100 "winfakepeldr",
    101100"cvtaccel",
    102101"cvticon",
  • trunk/src/kernel32/dbglocal.h

    r4372 r4474  
    1 /* $Id: dbglocal.h,v 1.11 2000-10-02 13:38:56 sandervl Exp $ */
     1/* $Id: dbglocal.h,v 1.12 2000-10-10 17:14:03 sandervl Exp $ */
    22
    33/*
     
    9797#define DBG_cvtbitmap      75
    9898#define DBG_hmmmap         76
    99 #define DBG_winfakepeldr   77
    100 #define DBG_cvtaccel       78
    101 #define DBG_cvticon        79
    102 #define DBG_cvticongrp     80
    103 #define DBG_oslibexcept    81
    104 #define DBG_cpu            82
    105 #define DBG_process        83
    106 #define DBG_cvtcursor      84
    107 #define DBG_cvtcursorgrp   85
    108 #define DBG_stubs          86
    109 #define DBG_interlock      87
    110 #define DBG_toolhelp       88
    111 #define DBG_codepage       89
    112 #define DBG_debug          90
    113 #define DBG_oslibdebug     91
    114 #define DBG_registry       92
    115 #define DBG_queue          93
    116 #define DBG_hmthread       94
    117 #define DBG_hmprocess      95
    118 #define DBG_VSemaphore     96
    119 #define DBG_exceptstackdump 97
    120 #define DBG_hmfile         98
    121 #define DBG_hmnpipe        99
    122 #define DBG_hmdisk         100
    123 #define DBG_version        101
    124 #define DBG_MAXFILES       102
     99#define DBG_cvtaccel       77
     100#define DBG_cvticon        78
     101#define DBG_cvticongrp     79
     102#define DBG_oslibexcept    80
     103#define DBG_cpu            81
     104#define DBG_process        82
     105#define DBG_cvtcursor      83
     106#define DBG_cvtcursorgrp   84
     107#define DBG_stubs          85
     108#define DBG_interlock      86
     109#define DBG_toolhelp       87
     110#define DBG_codepage       88
     111#define DBG_debug          89
     112#define DBG_oslibdebug     90
     113#define DBG_registry       91
     114#define DBG_queue          92
     115#define DBG_hmthread       93
     116#define DBG_hmprocess      94
     117#define DBG_VSemaphore     95
     118#define DBG_exceptstackdump 96
     119#define DBG_hmfile         97
     120#define DBG_hmnpipe        98
     121#define DBG_hmdisk         99
     122#define DBG_version        100
     123#define DBG_MAXFILES       101
    125124
    126125extern USHORT DbgEnabled[DBG_MAXFILES];
  • trunk/src/kernel32/hmfile.cpp

    r4256 r4474  
    1 /* $Id: hmfile.cpp,v 1.21 2000-09-13 21:10:59 sandervl Exp $ */
     1/* $Id: hmfile.cpp,v 1.22 2000-10-10 17:14:03 sandervl Exp $ */
    22
    33/*
     
    597597//  }
    598598
     599//testestest!!!!
     600    dprintf(("%s", lpRealBuf));
     601//testestest!!!!
     602
     603
    599604  dprintf(("KERNEL32: HMDeviceFileClass::WriteFile returned %08xh\n",
    600605           bRC));
  • trunk/src/kernel32/initsystem.cpp

    r4407 r4474  
    1 /* $Id: initsystem.cpp,v 1.17 2000-10-03 17:28:30 sandervl Exp $ */
     1/* $Id: initsystem.cpp,v 1.18 2000-10-10 17:14:04 sandervl Exp $ */
    22/*
    33 * Odin system initialization (registry, directories & environment)
     
    77 *
    88 * InitSystemAndRegistry creates:
     9 *      - SYSTEMDIR\drivers
    910 *      - WINDOWSDIR\SYSTEM
    1011 *      - WINDOWSDIR\AppData
     
    192193//   if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
    193194//   {
     195        //system32\drivers dir
     196        strcpy(shellpath, InternalGetSystemDirectoryA());
     197        strcat(shellpath, "\\Drivers");
     198        CreateDirectoryA(shellpath, NULL);
     199
    194200        //SYSTEM dir
    195201        strcpy(shellpath, InternalGetWindowsDirectoryA());
  • trunk/src/kernel32/initterm.cpp

    r4396 r4474  
    1 /* $Id: initterm.cpp,v 1.47 2000-10-02 21:40:57 phaller Exp $ */
     1/* $Id: initterm.cpp,v 1.48 2000-10-10 17:14:04 sandervl Exp $ */
    22
    33/*
     
    120120            char *endofpath = strrchr(kernel32Path, '\\');
    121121            *(endofpath+1) = 0;
    122             dprintf(("kernel32 init\n"));
     122            dprintf(("kernel32 init %s %s", __DATE__, __TIME__));
    123123            _ctordtorInit();
    124124
  • trunk/src/kernel32/makefile

    r4372 r4474  
    1 # $Id: makefile,v 1.102 2000-10-02 13:38:56 sandervl Exp $
     1# $Id: makefile,v 1.103 2000-10-10 17:14:04 sandervl Exp $
    22
    33#
     
    107107$(OBJDIR)\cvtbitmap.obj \
    108108$(OBJDIR)\hmmmap.obj \
    109 $(OBJDIR)\winfakepeldr.obj \
    110109$(OBJDIR)\cvtaccel.obj \
    111110$(OBJDIR)\cvticon.obj \
  • trunk/src/kernel32/oslibdos.cpp

    r4473 r4474  
    1 /* $Id: oslibdos.cpp,v 1.48 2000-10-09 22:51:18 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.49 2000-10-10 17:14:04 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    17441744        DosFindClose(hDir);
    17451745        SetLastError(error2WinError(rc));
    1746   return INVALID_HANDLE_VALUE_W;
     1746        return INVALID_HANDLE_VALUE_W;
    17471747  }
    17481748  translateFindResults(&result,lpFindFileData);
     1749  SetLastError(ERROR_SUCCESS_W);
    17491750  return hDir;
    17501751}
     
    17831784  *count = searchCount;
    17841785
     1786  SetLastError(ERROR_SUCCESS_W);
    17851787  return hDir;
    17861788}
     
    18011803
    18021804  translateFindResults(&result,lpFindFileData);
    1803 
     1805  SetLastError(ERROR_SUCCESS_W);
    18041806  return TRUE;
    18051807}
     
    18311833  *count = searchCount;
    18321834
     1835  SetLastError(ERROR_SUCCESS_W);
    18331836  return TRUE;
    18341837}
     
    18411844  {
    18421845    SetLastError(error2WinError(rc));
    1843 
    18441846    return FALSE;
    18451847  }
    18461848
     1849  SetLastError(ERROR_SUCCESS_W);
    18471850  return TRUE;
    18481851}
     
    18591862
    18601863   if(lpFileSystemNameBuffer == NULL) {
    1861   DebugInt3();
    1862   return ERROR_INVALID_PARAMETER_W;
     1864        DebugInt3();
     1865        return ERROR_INVALID_PARAMETER_W;
    18631866   }
    18641867   drv[0] = (char)('A' + drive - 1);
     
    18701873   switch(rc) {
    18711874   case ERROR_INVALID_DRIVE:
    1872   return ERROR_INVALID_DRIVE_W;
     1875        return ERROR_INVALID_DRIVE_W;
    18731876   case ERROR_NO_VOLUME_LABEL:
    1874   return ERROR_NO_VOLUME_LABEL_W;
     1877        return ERROR_NO_VOLUME_LABEL_W;
    18751878   case NO_ERROR:
    1876   break;
     1879        break;
    18771880   default:
    1878   return ERROR_NOT_ENOUGH_MEMORY; //whatever
     1881        return ERROR_NOT_ENOUGH_MEMORY; //whatever
    18791882   }
    18801883
     
    18891892  /*
    18901893   if(strlen(fsname) < nFileSystemNameSize) {
    1891   strcpy(lpFileSystemNameBuffer, fsname);
     1894        strcpy(lpFileSystemNameBuffer, fsname);
    18921895   }
    18931896   else return ERROR_BUFFER_OVERFLOW_W;
     
    20002003    return -1; // INVALID_HANDLE_VALUE
    20012004  }
     2005  SetLastError(ERROR_SUCCESS_W);
    20022006  return NO_ERROR;
    20032007}
     
    20752079   }
    20762080   else len += 3;   // + 3 since DosQueryCurDir doesn't include drive
     2081
     2082   SetLastError(ERROR_SUCCESS_W);
    20772083   return len;
    20782084}
  • trunk/src/kernel32/windllbase.cpp

    r4387 r4474  
    1 /* $Id: windllbase.cpp,v 1.17 2000-10-02 18:39:36 sandervl Exp $ */
     1/* $Id: windllbase.cpp,v 1.18 2000-10-10 17:14:06 sandervl Exp $ */
    22
    33/*
     
    5353                   referenced(0), fSkipThreadEntryCalls(FALSE), next(NULL), fInserted(FALSE),
    5454                   fAttachedToProcess(FALSE), fUnloaded(FALSE),
    55                    nrDynamicLibRef(0), fDisableUnload(FALSE)
     55                   nrDynamicLibRef(0), fDisableUnload(FALSE), fSkipEntryCalls(FALSE)
    5656{
    5757  dllEntryPoint = DllEntryPoint;
     
    395395 BOOL rc, fSetExceptionHandler;
    396396
    397   if(fAttachedToProcess)
     397  if(fAttachedToProcess || fSkipEntryCalls)
    398398        return TRUE;
    399399
     
    460460 USHORT sel;
    461461 BOOL rc;
     462
     463  if(fSkipEntryCalls) {
     464        fUnloaded = TRUE;
     465        return TRUE;
     466  }
    462467
    463468  if(dllEntryPoint == NULL) {
  • trunk/src/kernel32/windllbase.h

    r3993 r4474  
    1 /* $Id: windllbase.h,v 1.5 2000-08-11 10:56:18 sandervl Exp $ */
     1/* $Id: windllbase.h,v 1.6 2000-10-10 17:14:06 sandervl Exp $ */
    22
    33/*
     
    5353        //do not call the ATTACH_THREAD, DETACH_THREAD functions
    5454        void      disableThreadLibraryCalls()  { fSkipThreadEntryCalls = TRUE; };
     55        void      disableLibraryCalls()        { fSkipEntryCalls = fSkipThreadEntryCalls = TRUE; };
    5556
    5657        Win32DllBase *getNext()  { return next; };
     
    114115#endif
    115116
    116         BOOL          fSkipThreadEntryCalls, fUnloaded, fAttachedToProcess;
     117        BOOL          fSkipThreadEntryCalls, fUnloaded, fAttachedToProcess, fSkipEntryCalls;
    117118
    118119        WIN32DLLENTRY dllEntryPoint;
  • trunk/src/kernel32/winimagebase.cpp

    r4440 r4474  
    1 /* $Id: winimagebase.cpp,v 1.28 2000-10-06 11:04:02 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.29 2000-10-10 17:14:07 sandervl Exp $ */
    22
    33/*
     
    202202
    203203//******************************************************************************
    204 //returns ERROR_SUCCESS or error code
    205 //******************************************************************************
    206 ULONG Win32ImageBase::isPEImage(char *szFileName)
     204//returns ERROR_SUCCESS or error code (Characteristics will contain
     205//the Characteristics member of the file header structure)
     206//******************************************************************************
     207ULONG Win32ImageBase::isPEImage(char *szFileName, DWORD *Characteristics)
    207208{
    208209 char   filename[CCHMAXPATH];
     
    291292  if(fh.Characteristics & IMAGE_FILE_SYSTEM) {
    292293        goto failure;
     294  }
     295  if(Characteristics) {
     296        *Characteristics = fh.Characteristics;
    293297  }
    294298  DosClose(win32handle);
  • trunk/src/kernel32/winimagebase.h

    r4249 r4474  
    1 /* $Id: winimagebase.h,v 1.16 2000-09-12 22:45:19 bird Exp $ */
     1/* $Id: winimagebase.h,v 1.17 2000-10-10 17:14:07 sandervl Exp $ */
    22
    33/*
     
    9595    ULONG getResourceSize(HRSRC hResource);
    9696
    97     //returns ERROR_SUCCESS or error code
    98 static  ULONG isPEImage(char *szFileName);
     97//returns ERROR_SUCCESS or error code (Characteristics will contain
     98//the Characteristics member of the file header structure)
     99static  ULONG isPEImage(char *szFileName, DWORD *Characteristics = NULL);
    99100static  BOOL  findDll(const char *pszFileName, char *pszFullName,
    100101                      int cchFullName, const char *pszAltPath = NULL);
  • trunk/src/kernel32/winimagepeldr.cpp

    r4471 r4474  
    1 /* $Id: winimagepeldr.cpp,v 1.59 2000-10-09 18:35:26 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.60 2000-10-10 17:14:08 sandervl Exp $ */
    22
    33/*
     
    1414 *       (circular dependencies; have to check what NT does)
    1515 *
    16  * NOTE: RSRC_LOAD is a special flag to only load the resource directory
     16 * NOTE: FLAG_PELDR_LOADASDATAFILE is a special flag to only load the resource directory
    1717 *       of a PE image. Processing imports, sections etc is not done.
    18  *       Nor is it put into the linked list of dlls (if it's a dll).
    1918 *       This is useful for GetVersionSize/Resource in case it wants to
    2019 *       get version info of an image that is not loaded.
     
    103102//******************************************************************************
    104103//******************************************************************************
    105 Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe, int loadtype) :
     104Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe) :
    106105    Win32ImageBase(-1),
    107     nrsections(0), imageSize(0),
     106    nrsections(0), imageSize(0), dwFlags(0),
    108107    imageVirtBase(-1), realBaseAddress(0), imageVirtEnd(0),
    109108    nrNameExports(0), nrOrdExports(0), nameexports(NULL), ordexports(NULL),
     
    111110{
    112111 HFILE  dllfile;
    113 
    114   loadType = loadtype;
    115112
    116113  strcpy(szFileName, pszFileName);
     
    282279  nSections = NR_SECTIONS(win32file);
    283280
    284   if(loadType == REAL_LOAD)
     281  if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE))
    285282  {
    286283   imageSize = 0;
     
    307304        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_EXPORT))
    308305        {
    309             dprintf((LOG, ".edata" ));
    310             addSection(SECTION_EXPORT, psh[i].PointerToRawData,
    311                    psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase,
    312                    psh[i].Misc.VirtualSize, psh[i].Characteristics);
    313             continue;
     306            //SvL: Angus.exe has empty export section that's really an
     307            //     uninitialized data section
     308            if(psh[i].SizeOfRawData) {
     309                 dprintf((LOG, ".edata" ));
     310                 addSection(SECTION_EXPORT, psh[i].PointerToRawData,
     311                      psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase,
     312                      psh[i].Misc.VirtualSize, psh[i].Characteristics);
     313                 continue;
     314            }
    314315        }
    315316        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_RESOURCE))
     
    439440  }
    440441
    441   if(loadType == REAL_LOAD)
     442  if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE))
    442443  {
    443444   if(tlsDir = (IMAGE_TLS_DIRECTORY *)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_TLS))
     
    554555  }
    555556
    556   if (loadType == REAL_LOAD)
     557  if(!(dwFlags & (FLAG_PELDR_LOADASDATAFILE | FLAG_PELDR_SKIPIMPORTS)))
    557558  {
    558    if(processImports((char *)win32file) == FALSE) {
    559         dprintf((LOG, "Failed to process imports!" ));
    560         goto failure;
    561    }
    562   }
    563 
     559        if(processImports((char *)win32file) == FALSE) {
     560             dprintf((LOG, "Failed to process imports!" ));
     561             goto failure;
     562        }
     563  }
    564564  return(TRUE);
     565
    565566failure:
    566567  if(memmap) {
     
    730731
    731732  //SvL: We don't care where the image is loaded for resource lookup
    732   if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && loadType == REAL_LOAD) {
     733  if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && !(dwFlags & FLAG_PELDR_LOADASDATAFILE)) {
    733734        return allocFixedMem(reservedMem);
    734735  }
     
    898899
    899900        case SECTION_READONLYDATA:
     901        case SECTION_EXPORT:
    900902        default:
    901903                section[i].pageflags = PAG_READ;
    902904                break;
    903905        }
     906        if(section[i].flags & (IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
     907                //SvL: sometimes i.e. import/export sections also contain data
     908                //     must make them read/write
     909                section[i].pageflags = PAG_WRITE;
     910        }
     911
    904912  }
    905913  return(TRUE);
     
    14861494  {
    14871495    dprintf((LOG, "Module %s", pszCurModule ));
    1488     dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain));
     1496    if(pID[i].ForwarderChain) {
     1497        dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain));
     1498    }
    14891499    //  a) check that OriginalFirstThunk not is 0 and look for Borland-styled PE
    14901500    if (i == 0)
  • trunk/src/kernel32/winimagepeldr.h

    r4422 r4474  
    1 /* $Id: winimagepeldr.h,v 1.5 2000-10-04 19:36:25 sandervl Exp $ */
     1/* $Id: winimagepeldr.h,v 1.6 2000-10-10 17:14:09 sandervl Exp $ */
    22
    33/*
     
    2222
    2323//SvL: To load a dll/exe for i.e. getting a single resource (GetVersionSize/Resource)
    24 #define REAL_LOAD               0
    25 #define RSRC_LOAD               1
     24#define FLAG_PELDR_LOADASDATAFILE       1  //also implies FLAG_PELDR_SKIPIMPORTS
     25#define FLAG_PELDR_SKIPIMPORTS          2
    2626
    2727//SvL: Amount of memory the peldr dll reserves for win32 exes without fixups
     
    7575{
    7676public:
    77          Win32PeLdrImage(char *szFileName, BOOL isExe, int loadtype = REAL_LOAD);
     77         Win32PeLdrImage(char *szFileName, BOOL isExe);
    7878virtual ~Win32PeLdrImage();
    7979
     
    9393    //Returns required OS version for this image
    9494    virtual ULONG getVersion();
     95
     96        //tell loader to only process resources and ignore the rest
     97        void  setLoadAsDataFile()     { dwFlags |= FLAG_PELDR_LOADASDATAFILE; };
     98        void  disableImportHandling() { dwFlags |= FLAG_PELDR_SKIPIMPORTS; };
    9599
    96100        //commits image page(s) when an access violation exception is dispatched
     
    137141        Section               section[MAX_SECTION];
    138142
    139         ULONG                 loadType;
     143        //internal flags (see FLAGS_PELDR_*)
     144        DWORD                 dwFlags;
    140145
    141146        HFILE                 hFile;
  • trunk/src/kernel32/wprocess.cpp

    r4445 r4474  
    1 /* $Id: wprocess.cpp,v 1.102 2000-10-06 15:16:07 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.103 2000-10-10 17:14:09 sandervl Exp $ */
    22
    33/*
     
    99 * NOTE: Even though Odin32 OS/2 apps don't switch FS selectors,
    1010 *       we still allocate a TEB to store misc information.
     11 *
     12 * TODO: What happens when a dll is first loaded as LOAD_LIBRARY_AS_DATAFILE
     13 *       and then for real? (first one not freed of course)
    1114 *
    1215 * Project Odin Software License can be found in LICENSE.TXT
     
    2528#include "windllpeldr.h"
    2629#include "winexepeldr.h"
    27 #include "winfakepeldr.h"
    2830#include "windlllx.h"
    2931#include <vmutex.h>
     
    443445 BOOL rc;
    444446
     447    SetLastError(ERROR_SUCCESS);
    445448    //SvL: Ignore FreeLibary for executable
    446449    if(WinExe && hinstance == WinExe->getInstanceHandle()) {
     
    633636 *                      by the module).
    634637 *
    635  *                  partially implemented yet - imports are resolved it seems.
    636638 *
    637639 *                  LOAD_LIBRARY_AS_DATAFILE
     
    648650 *                      LoadCursor, LoadIcon, LoadImage, LoadMenu.)
    649651 *
    650  *                  not implemented yet.
    651652 *
    652653 *                  LOAD_WITH_ALTERED_SEARCH_PATH
     
    677678                                        /* lpszLibFile contains a path. */
    678679    ULONG           fPE;                /* isPEImage return value. */
     680    DWORD           Characteristics;    //file header's Characteristics
    679681
    680682    /** @sketch
     
    720722    if (WinExe != NULL && WinExe->matchModName(lpszLibFile))
    721723        return WinExe->getInstanceHandle();
     724
    722725    pModule = Win32DllBase::findModule((LPSTR)lpszLibFile);
    723726    if (pModule)
     
    760763
    761764    //test if dll is in PE or LX format
    762     fPE = Win32ImageBase::isPEImage(szModname);
     765    fPE = Win32ImageBase::isPEImage(szModname, &Characteristics);
    763766
    764767    /** @sketch
     
    785788            if(pModule)
    786789            {
    787 
    788790                if(pModule->isLxDll())
    789791                {
     
    829831    if(fPE == ERROR_SUCCESS)
    830832    {
    831         Win32PeLdrDll * peldrDll;
    832         /* TODO!
    833          * We might use the fake loader class to do the LOAD_LIBRARY_AS_DATAFILE and
    834          * executable image loading. These are both loaded for accessing resource.
    835          * But this requires that they behaves like Dlls...
    836         if (dwFlags & LOAD_LIBRARY_AS_DATAFILE || fPE == 2)
    837         {
    838             peldrDll = new Win32PeLdrRsrcImg(szModname);
    839         }
    840         else
    841         */
     833        Win32PeLdrDll *peldrDll;
     834
     835        //SvL: If executable -> load as data file (only resources)
     836        if(!(Characteristics & IMAGE_FILE_DLL))
     837        {
     838            dwFlags |= (LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES);
     839        }
    842840
    843841        peldrDll = new Win32PeLdrDll(szModname);
     
    853851         * Process dwFlags
    854852         */
    855         if (dwFlags & (DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE))
    856         {
    857             peldrDll->disableThreadLibraryCalls();
    858             //peldrDll->setDontProcessImports(); not implemented?
     853        if (dwFlags & LOAD_LIBRARY_AS_DATAFILE)
     854        {
     855            dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): LOAD_LIBRARY_AS_DATAFILE",
     856                      lpszLibFile, hFile, dwFlags));
     857            peldrDll->setLoadAsDataFile();
     858            peldrDll->disableLibraryCalls();
     859        }
     860        if (dwFlags & DONT_RESOLVE_DLL_REFERENCES)
     861        {
     862            dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): DONT_RESOLVE_DLL_REFERENCES",
     863                      lpszLibFile, hFile, dwFlags));
     864            peldrDll->disableLibraryCalls();
     865            peldrDll->disableImportHandling();
    859866        }
    860867        if (dwFlags & LOAD_WITH_ALTERED_SEARCH_PATH)
     
    863870                      lpszLibFile, hFile, dwFlags));
    864871            //peldrDll->setLoadWithAlteredSearchPath();
    865         }
    866         if (dwFlags & LOAD_LIBRARY_AS_DATAFILE)
    867         {
    868             dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): Warning dwFlags LOAD_LIBRARY_AS_DATAFILE is not implemented.",
    869                      lpszLibFile, hFile, dwFlags));
    870             //peldrDll->setLoadAsDatafile();
    871872        }
    872873
     
    918919            SetLastError(ERROR_INVALID_EXE_SIGNATURE);
    919920            delete peldrDll;
    920                 return NULL;
     921            return NULL;
    921922        }
    922923    }
     
    18121813{
    18131814 Win32ImageBase *winimage;
    1814  Win32PeLdrRsrcImg *rsrcimg;
    1815 
    1816   dprintf(("GetVersionStruct of module %s", lpszModName));
     1815 HINSTANCE hDll;
     1816
     1817  dprintf(("GetVersionStruct of module %s %x %d", lpszModName, verstruct, bufLength));
     1818  if(verstruct == NULL) {
     1819        SetLastError(ERROR_INVALID_PARAMETER);
     1820        return FALSE;
     1821  }
     1822  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName))
     1823  {
     1824        winimage = (Win32ImageBase *)WinExe;
     1825  }
     1826  else
     1827  {
     1828        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
     1829        if(winimage == NULL)
     1830        {
     1831          char modname[CCHMAXPATH];
     1832
     1833          strcpy(modname, lpszModName);
     1834          //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
     1835          Win32DllBase::renameDll(modname);
     1836
     1837          if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
     1838          {
     1839            HINSTANCE hInstance;
     1840
     1841              //must be an LX dll, just load it (app will probably load it anyway)
     1842              hInstance = LoadLibraryA(modname);
     1843              if(hInstance == 0)
     1844                  return 0;
     1845
     1846              winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
     1847              if(winimage) {
     1848                   return winimage->getVersionStruct(verstruct, bufLength);
     1849              }
     1850              dprintf(("GetVersionStruct; just loaded dll %s, but can't find it now!", modname));
     1851              return 0;
     1852          }
     1853          BOOL rc = FALSE;
     1854
     1855          hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
     1856          if(hDll == 0)
     1857              return 0;
     1858
     1859          winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
     1860          if(winimage != NULL) {
     1861                rc = winimage->getVersionStruct(verstruct, bufLength);
     1862          }
     1863          else  dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName));
     1864          FreeLibrary(hDll);
     1865          return rc;
     1866        }
     1867  }
     1868  return winimage->getVersionStruct(verstruct, bufLength);
     1869}
     1870//******************************************************************************
     1871//******************************************************************************
     1872ULONG SYSTEM GetVersionSize(char *lpszModName)
     1873{
     1874 Win32ImageBase *winimage;
     1875 HINSTANCE hDll;
     1876
     1877  dprintf(("GetVersionSize of %s\n", lpszModName));
     1878
    18171879  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) {
    18181880        winimage = (Win32ImageBase *)WinExe;
     
    18221884        if(winimage == NULL)
    18231885        {
    1824         char modname[CCHMAXPATH];
    1825 
    1826         strcpy(modname, lpszModName);
    1827         //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
    1828         Win32DllBase::renameDll(modname);
    1829 
    1830         if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
    1831         {
    1832          HINSTANCE hInstance;
     1886          char modname[CCHMAXPATH];
     1887
     1888          strcpy(modname, lpszModName);
     1889          //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
     1890          Win32DllBase::renameDll(modname);
     1891
     1892          if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
     1893          {
     1894            HINSTANCE hInstance;
    18331895
    18341896            //must be an LX dll, just load it (app will probably load it anyway)
     
    18361898            if(hInstance == 0)
    18371899                return 0;
    1838                 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
    1839                 if(winimage) {
    1840                 return winimage->getVersionStruct(verstruct, bufLength);
    1841             }
    1842             return 0;
    1843         }
    1844         //SvL: Try to load it
    1845         rsrcimg = new Win32PeLdrRsrcImg(modname);
    1846         if(rsrcimg == NULL)
    1847             return 0;
    1848 
    1849             rsrcimg->init(0);
    1850         if(rsrcimg->getError() != NO_ERROR)
    1851         {
    1852                 dprintf(("GetVersionStruct can't load %s\n", modname));
    1853             delete rsrcimg;
    1854                 return(FALSE);
    1855         }
    1856         BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength);
    1857         delete rsrcimg;
    1858         return rc;
    1859         }
    1860   }
    1861   return winimage->getVersionStruct(verstruct, bufLength);
    1862 }
    1863 //******************************************************************************
    1864 //******************************************************************************
    1865 ULONG SYSTEM GetVersionSize(char *lpszModName)
    1866 {
    1867  Win32ImageBase *winimage;
    1868  Win32PeLdrRsrcImg *rsrcimg;
    1869 
    1870   dprintf(("GetVersionSize of %s\n", lpszModName));
    1871 
    1872   if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) {
    1873         winimage = (Win32ImageBase *)WinExe;
    1874   }
    1875   else {
    1876         winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
    1877         if(winimage == NULL)
    1878         {
    1879      char modname[CCHMAXPATH];
    1880 
    1881         strcpy(modname, lpszModName);
    1882         //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
    1883         Win32DllBase::renameDll(modname);
    1884 
    1885         if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
    1886         {
    1887          HINSTANCE hInstance;
    1888 
    1889             //must be an LX dll, just load it (app will probably load it anyway)
    1890             hInstance = LoadLibraryA(modname);
    1891             if(hInstance == 0)
    1892                 return 0;
    1893                 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
    1894                 if(winimage) {
     1900
     1901            winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
     1902            if(winimage) {
    18951903                return winimage->getVersionSize();
    18961904            }
     1905            dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", modname));
    18971906            return 0;
    18981907        }
    1899 
    1900         //SvL: Try to load it
    1901         rsrcimg = new Win32PeLdrRsrcImg(modname);
    1902         if(rsrcimg == NULL)
     1908        int size = 0;
     1909
     1910        hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
     1911        if(hDll == 0)
    19031912            return 0;
    19041913
    1905             rsrcimg->init(0);
    1906         if(rsrcimg->getError() != NO_ERROR)
    1907         {
    1908                 dprintf(("GetVersionSize can't load %s\n", modname));
    1909             delete rsrcimg;
    1910                 return(FALSE);
    1911         }
    1912         int size = rsrcimg->getVersionSize();
    1913         delete rsrcimg;
     1914        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
     1915        if(winimage != NULL) {
     1916                size = winimage->getVersionSize();
     1917        }
     1918        else    dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName));
     1919        FreeLibrary(hDll);
    19141920        return size;
    1915         }
     1921      }
    19161922  }
    19171923  return winimage->getVersionSize();
    19181924}
    19191925//******************************************************************************
    1920 //TODO:What does this do exactly??
    19211926//******************************************************************************
    19221927ODINFUNCTION1(BOOL,DisableThreadLibraryCalls,HMODULE,hModule)
Note: See TracChangeset for help on using the changeset viewer.