Changeset 978


Ignore:
Timestamp:
Sep 18, 1999, 7:47:10 PM (26 years ago)
Author:
sandervl
Message:

Changes for LX image resource support

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/odinlx.h

    r970 r978  
    1 /* $Id: odinlx.h,v 1.2 1999-09-18 15:55:45 sandervl Exp $ */
     1/* $Id: odinlx.h,v 1.3 1999-09-18 17:45:22 sandervl Exp $ */
    22
    33/*
     
    2222//System dlls set EntryPoint to 0
    2323//******************************************************************************
    24 BOOL WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID unused);
     24BOOL WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData);
    2525
    2626//******************************************************************************
     
    3333//System dlls set EntryPoint to 0
    3434//******************************************************************************
    35 BOOL WIN32API RegisterLxExe(WINMAIN EntryPoint, PVOID unused);
     35BOOL WIN32API RegisterLxExe(WINMAIN EntryPoint, PVOID pResData);
    3636
    3737#ifdef __cplusplus
  • trunk/include/windlllx.h

    r953 r978  
    1 /* $Id: windlllx.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
     1/* $Id: windlllx.h,v 1.2 1999-09-18 17:45:23 sandervl Exp $ */
    22
    33/*
     
    1919{
    2020public:
    21         Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint);
     21        Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, PVOID pResData);
    2222virtual ~Win32LxDll();
    2323
  • trunk/include/winexelx.h

    r953 r978  
    1 /* $Id: winexelx.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
     1/* $Id: winexelx.h,v 1.2 1999-09-18 17:45:23 sandervl Exp $ */
    22
    33/*
     
    2121{
    2222public:
    23         Win32LxExe(HINSTANCE hInstance);
     23        Win32LxExe(HINSTANCE hInstance, PVOID pResData);
    2424virtual ~Win32LxExe();
    2525
  • trunk/include/winimagebase.h

    r953 r978  
    1 /* $Id: winimagebase.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.2 1999-09-18 17:45:23 sandervl Exp $ */
    22
    33/*
     
    5555        char *getModuleName()         { return szModule; };
    5656
    57 virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST) = 0;
     57virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    5858        HRSRC findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
    59 virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST) = 0;
     59virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    6060        ULONG getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
    6161
    62 virtual ULONG getVersionSize() = 0;
    63 virtual BOOL  getVersionStruct(char *verstruct, ULONG bufLength) = 0;
     62virtual ULONG getVersionSize();
     63virtual BOOL  getVersionStruct(char *verstruct, ULONG bufLength);
    6464
    6565static  BOOL  isPEImage(char *szFileName);
     
    102102        ULONG                 tlsIndex;         //module TLS index
    103103
     104        ULONG getPEResourceSize(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
     105
     106        PIMAGE_RESOURCE_DATA_ENTRY getPEResourceEntry(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
     107        PIMAGE_RESOURCE_DATA_ENTRY ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
     108                                                    ULONG *nodeData, int level);
     109        PIMAGE_RESOURCE_DIRECTORY pResDir;
     110
     111        //substracted from RVA data offsets
     112        ULONG                     pResourceSectionStart;
     113
    104114private:
    105115
  • trunk/include/winimagelx.h

    r953 r978  
    1 /* $Id: winimagelx.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
     1/* $Id: winimagelx.h,v 1.2 1999-09-18 17:45:23 sandervl Exp $ */
    22
    33/*
     
    1818{
    1919public:
    20          Win32LxImage(HINSTANCE hInstance);
     20         Win32LxImage(HINSTANCE hInstance, PVOID pResData);
    2121virtual ~Win32LxImage();
    22 
    23 virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    24 virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    25 
    26 virtual ULONG getVersionSize();
    27 virtual BOOL  getVersionStruct(char *verstruct, ULONG bufLength);
    2822
    2923protected:
  • trunk/include/winimagepeldr.h

    r953 r978  
    1 /* $Id: winimagepeldr.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
     1/* $Id: winimagepeldr.h,v 1.2 1999-09-18 17:45:23 sandervl Exp $ */
    22
    33/*
     
    7070virtual BOOL  init(ULONG reservedMem);
    7171
    72 virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    73 virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    74 
    75 virtual ULONG getVersionSize();
    76 virtual BOOL  getVersionStruct(char *verstruct, ULONG bufLength);
    77 
    7872protected:
    7973        void StoreImportByOrd(Win32DllBase *WinDll, ULONG ordinal, ULONG impaddr);
     
    9892        void  AddOrdExport(ULONG virtaddr, ULONG ordinal);
    9993
    100 
    101         ULONG getPEResourceSize(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
    102 
    103         PIMAGE_RESOURCE_DATA_ENTRY getPEResourceEntry(ULONG id, ULONG type, ULONG lang = LANG_GETFIRST);
    104         PIMAGE_RESOURCE_DATA_ENTRY ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
    105                                                     ULONG *nodeData, int level);
    106         PIMAGE_RESOURCE_DIRECTORY pResDir;
    10794        Section                  *pResSection;
    10895
  • trunk/src/kernel32/makefile

    r956 r978  
    1 # $Id: makefile,v 1.41 1999-09-15 23:38:01 sandervl Exp $
     1# $Id: makefile,v 1.42 1999-09-18 17:47:10 sandervl Exp $
    22
    33#
     
    319319pefile.OBJ:    pefile.cpp $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winres.h
    320320
    321 winimagebase.obj:  winimagebase.cpp $(PDWIN32_INCLUDE)\winimagebase.h
     321winimagebase.obj:  winimagebase.cpp $(PDWIN32_INCLUDE)\winimagebase.h 
    322322winimagepe2lx.obj: winimagepe2lx.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
    323323winimagepeldr.obj: winimagepeldr.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagepeldr.h
    324324winimagelx.obj:    winimagelx.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagelx.h
    325325windllbase.obj:    windllbase.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\winimagebase.h
    326 windllpe2lx.obj:   windllpe2lx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpe2lx.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
    327 windlllx.obj:      windlllx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windlllx.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h
    328 windllpeldr.obj:   windllpeldr.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h
     326windllpe2lx.obj:   windllpe2lx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpe2lx.h \
     327                   $(PDWIN32_INCLUDE)\winimagepe2lx.h $(PDWIN32_INCLUDE)\winimagebase.h
     328windlllx.obj:      windlllx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windlllx.h \
     329                   $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h \
     330                   $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagelx.h
     331windllpeldr.obj:   windllpeldr.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h $(PDWIN32_INCLUDE)\winimagebase.h
    329332winexebase.obj:    winexebase.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winimagebase.h
    330 winexepe2lx.obj:   winexepe2lx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepe2lx.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
    331 winexelx.obj:      winexelx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexelx.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h
    332 winexepeldr.obj:   winexepeldr.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h
     333winexepe2lx.obj:   winexepe2lx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepe2lx.h $(PDWIN32_INCLUDE)\winimagepe2lx.h $(PDWIN32_INCLUDE)\winimagebase.h
     334winexelx.obj:      winexelx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexelx.h \
     335                   $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagelx.h
     336winexepeldr.obj:   winexepeldr.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h $(PDWIN32_INCLUDE)\winimagebase.h
    333337
    334338winimgres.OBJ: winimgres.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winimagepe2lx.h $(PDWIN32_INCLUDE)\winimagepeldr.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\winres.h
  • trunk/src/kernel32/windlllx.cpp

    r956 r978  
    1 /* $Id: windlllx.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.2 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    3636//System dlls set EntryPoint to 0
    3737//******************************************************************************
    38 BOOL WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID unused)
     38BOOL WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint,
     39                            PVOID pResData)
    3940{
    4041 Win32LxDll *windll;
     
    4647        return FALSE;
    4748   }
    48    windll = new Win32LxDll(hInstance, EntryPoint);
     49   windll = new Win32LxDll(hInstance, EntryPoint, pResData);
    4950   if(windll == NULL) {
    5051        dprintf(("RegisterLxDll: windll == NULL!!!"));
     
    5859BOOL WIN32API UnregisterLxDll(HINSTANCE hInstance)
    5960{
     61#if 1
     62   return TRUE;
     63#else
    6064 Win32LxDll *windll;
    6165
     
    6872   delete windll;
    6973   return TRUE;
     74#endif
    7075}
    7176//******************************************************************************
    7277//******************************************************************************
    73 Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint)
     78Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData)
    7479                : Win32ImageBase(hInstance),
    75                   Win32LxImage(hInstance),
     80                  Win32LxImage(hInstance, pResData),
    7681                  Win32DllBase(hInstance, EntryPoint)
    7782{
  • trunk/src/kernel32/winexelx.cpp

    r956 r978  
    1 /* $Id: winexelx.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
     1/* $Id: winexelx.cpp,v 1.2 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    3636//System dlls set EntryPoint to 0
    3737//******************************************************************************
    38 BOOL WIN32API RegisterLxExe(WINMAIN EntryPoint, PVOID unused)
     38BOOL WIN32API RegisterLxExe(WINMAIN EntryPoint, PVOID pResData)
    3939{
    4040 APIRET  rc;
     
    5656  Win32LxExe *winexe;
    5757
    58   winexe = new Win32LxExe(ppib->pib_hmte);
     58  winexe = new Win32LxExe(ppib->pib_hmte, pResData);
    5959
    6060  if(winexe) {
     
    7272//******************************************************************************
    7373//******************************************************************************
    74 Win32LxExe::Win32LxExe(HINSTANCE hInstance)
     74Win32LxExe::Win32LxExe(HINSTANCE hInstance, PVOID pResData)
    7575                 : Win32ImageBase(hInstance),
    76                    Win32LxImage(hInstance),
     76                   Win32LxImage(hInstance, pResData),
    7777                   Win32ExeBase(hInstance)
    7878{
  • trunk/src/kernel32/winimagebase.cpp

    r956 r978  
    1 /* $Id: winimagebase.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.2 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    4343    errorState(NO_ERROR), entryPoint(0), fullpath(NULL),
    4444    tlsAddress(0), tlsIndexAddr(0), tlsInitSize(0), tlsTotalSize(0),
    45     tlsCallBackAddr(0), tlsIndex(-1), winres(NULL)
     45    tlsCallBackAddr(0), tlsIndex(-1), winres(NULL), pResDir(NULL),
     46    pResourceSectionStart(0)
    4647{
    4748#ifdef DEBUG
  • trunk/src/kernel32/winimagelx.cpp

    r956 r978  
    1 /* $Id: winimagelx.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
     1/* $Id: winimagelx.cpp,v 1.2 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    4040//******************************************************************************
    4141//******************************************************************************
    42 Win32LxImage::Win32LxImage(HINSTANCE hInstance)
     42Win32LxImage::Win32LxImage(HINSTANCE hInstance, PVOID pResData)
    4343               : Win32ImageBase(hInstance)
    4444{
     
    5050  strcpy(szFileName, name);
    5151  strupr(szFileName);
     52
     53  //Pointer to PE resource tree generates by wrc (or NULL for system dlls)
     54  pResDir = (PIMAGE_RESOURCE_DIRECTORY)pResData;
     55
     56  //pResourceSectionStart contains the virtual address of the imagebase in the PE header
     57  //for the resource section (images loaded by the pe.exe)
     58  //For LX images, this is 0 as OffsetToData contains a relative offset
     59  pResourceSectionStart = 0;
    5260}
    5361//******************************************************************************
  • trunk/src/kernel32/winimagepeldr.cpp

    r956 r978  
    1 /* $Id: winimagepeldr.cpp,v 1.1 1999-09-15 23:39:08 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.2 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    6464    imageVirtBase(-1), realBaseAddress(0), imageVirtEnd(0),
    6565    nrNameExports(0), nrOrdExports(0), nameexports(NULL), ordexports(NULL),
    66     pResSection(NULL), pResDir(NULL)
     66    pResSection(NULL)
    6767{
    6868  strcpy(this->szFileName, szFileName);
     
    359359  if(GetSectionHdrByName (win32file, &sh, ".rsrc")) {
    360360        //get offset in resource object of directory entry
    361 //      pResDir = (PIMAGE_RESOURCE_DIRECTORY)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_RESOURCE);
    362361        pResDir = (PIMAGE_RESOURCE_DIRECTORY)(sh.VirtualAddress + realBaseAddress);
     362        pResourceSectionStart = (ULONG)pResSection->virtaddr - oh.ImageBase;
    363363  }
    364364
  • trunk/src/kernel32/winimgres.cpp

    r956 r978  
    1 /* $Id: winimgres.cpp,v 1.14 1999-09-15 23:38:02 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.15 1999-09-18 17:47:10 sandervl Exp $ */
    22
    33/*
     
    3737//******************************************************************************
    3838PIMAGE_RESOURCE_DATA_ENTRY
    39  Win32PeLdrImage::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
     39 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
    4040{
    4141 PIMAGE_RESOURCE_DIRECTORY       prdType;
     
    124124//******************************************************************************
    125125PIMAGE_RESOURCE_DATA_ENTRY
    126     Win32PeLdrImage::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
    127                                  ULONG *nodeData, int level)
     126    Win32ImageBase::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
     127                                     ULONG *nodeData, int level)
    128128{
    129129 PIMAGE_RESOURCE_DIRECTORY       prdType2;
     
    201201//******************************************************************************
    202202//******************************************************************************
    203 ULONG Win32PeLdrImage::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
     203ULONG Win32ImageBase::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
    204204{
    205205 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    214214//******************************************************************************
    215215//******************************************************************************
    216 HRSRC Win32PeLdrImage::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     216HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    217217{
    218218 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    263263        return 0;
    264264  }
    265 
    266   char *resdata = (char *)((char *)pResDir + pData->OffsetToData - (pResSection->virtaddr - oh.ImageBase));
     265  //pResourceSectionStart contains the virtual address of the imagebase in the PE header
     266  //for the resource section (images loaded by the pe.exe)
     267  //For LX images, this is 0 as OffsetToData contains a relative offset
     268  char *resdata = (char *)((char *)pResDir + pData->OffsetToData - pResourceSectionStart);
    267269  if(stringid != -1) {//search for string in table
    268270        USHORT *unicodestr = (USHORT *)resdata;
     
    375377}
    376378//******************************************************************************
    377 //TODO:
    378 //******************************************************************************
    379 HRSRC Win32LxImage::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    380 {
    381     return 0;
    382 }
    383 //******************************************************************************
    384379//******************************************************************************
    385380HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang)
     
    413408}
    414409//******************************************************************************
    415 //TODO:
    416 //******************************************************************************
    417 ULONG Win32LxImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    418 {
    419     DebugInt3();
    420     return 0;
    421 }
    422 //******************************************************************************
    423 //******************************************************************************
    424 ULONG Win32PeLdrImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     410//******************************************************************************
     411ULONG Win32ImageBase::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    425412{
    426413    return getPEResourceSize((ULONG)lpszName, (ULONG)lpszType, lang);
     
    471458//******************************************************************************
    472459//******************************************************************************
    473 ULONG Win32PeLdrImage::getVersionSize()
     460ULONG Win32ImageBase::getVersionSize()
    474461{
    475462    return getResourceSizeA((LPCSTR)1, (LPSTR)NTRT_VERSION);
     
    477464//******************************************************************************
    478465//******************************************************************************
    479 BOOL Win32PeLdrImage::getVersionStruct(char *verstruct, ULONG bufLength)
     466BOOL Win32ImageBase::getVersionStruct(char *verstruct, ULONG bufLength)
    480467{
    481468 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    490477//******************************************************************************
    491478//******************************************************************************
    492 ULONG Win32LxImage::getVersionSize()
    493 {
    494 //    return getResourceSizeA((LPCSTR)1, (LPSTR)NTRT_VERSION);
    495   return 0;
    496 }
    497 //******************************************************************************
    498 //******************************************************************************
    499 BOOL Win32LxImage::getVersionStruct(char *verstruct, ULONG bufLength)
    500 {
    501  PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
    502 
    503 //  pData = getPEResourceEntry(1, NTRT_VERSION);
    504   if(pData == NULL) {
    505         dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
    506         return 0;
    507   }
    508   return pData->Size;
    509 }
    510 //******************************************************************************
    511 //******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.