Ignore:
Timestamp:
May 22, 2000, 9:08:01 PM (25 years ago)
Author:
sandervl
Message:

GetFileTime bugfix + FindResource(Ex)A/W changes + setup thread security objects during creation

File:
1 edited

Legend:

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

    r3547 r3588  
    1 /* $Id: winimgres.cpp,v 1.36 2000-05-18 09:08:38 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.37 2000-05-22 19:08:00 sandervl Exp $ */
    22
    33/*
     
    3535#define BITMAP_TYPENAME2    "DIB"
    3636
     37#define RESERR_SUCCESS          0
     38#define RESERR_IDNOTFOUND       1
     39#define RESERR_TYPENOTFOUND     2
     40#define RESERR_LANGNOTFOUND     3
     41
    3742//******************************************************************************
    3843//Assuming names are case insensitive
     
    4045//******************************************************************************
    4146PIMAGE_RESOURCE_DATA_ENTRY
    42  Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
     47 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang, int *error)
    4348{
    4449 PIMAGE_RESOURCE_DIRECTORY       prdType;
     
    4853 ULONG  nodeData[3], i, j, nameOffset;
    4954 BOOL  fFound = FALSE, fNumType;
     55
     56  *error = RESERR_TYPENOTFOUND;
    5057
    5158  //PH: our system LX DLLs might not have a resource segment
     
    120127    if(fFound) {
    121128        if((ULONG)prdType & 0x80000000) {//subdirectory?
    122             pData = ProcessResSubDir(prdType, &nodeData[0], 2);
     129            pData = ProcessResSubDir(prdType, &nodeData[0], 2, error);
    123130        }
    124131        else {
     
    131138    prde++;
    132139  }
     140  if(pData) {
     141        *error = RESERR_SUCCESS; //found it
     142  }
    133143  return pData;
    134144}
     
    139149PIMAGE_RESOURCE_DATA_ENTRY
    140150    Win32ImageBase::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
    141                                      ULONG *nodeData, int level)
     151                                     ULONG *nodeData, int level, int *error)
    142152{
    143153 PIMAGE_RESOURCE_DIRECTORY       prdType2;
     
    158168  prde    = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((DWORD)prdType + sizeof(IMAGE_RESOURCE_DIRECTORY));
    159169
     170  if(level == 2) {
     171        *error = RESERR_IDNOTFOUND;
     172  }
     173  else {
     174        *error = RESERR_LANGNOTFOUND;
     175  }
    160176  //level 2 (id)   -> get first id?
    161177  //level 3 (lang) -> get first language?
     
    204220        if(fFound) {
    205221            if((ULONG)prdType2 & 0x80000000) {//subdirectory?
    206                     return ProcessResSubDir(prdType2, nodeData+1, 3);
     222                    return ProcessResSubDir(prdType2, nodeData+1, 3, error);
    207223            }
    208224            else {
     
    222238ULONG Win32ImageBase::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
    223239{
    224  PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     240 PIMAGE_RESOURCE_DATA_ENTRY pData = NULL;
     241 int                        error;
    225242
    226243    switch(lang) {
     
    237254    }
    238255
    239     pData = getPEResourceEntry(id, type, lang);
     256    pData = getPEResourceEntry(id, type, lang, &error);
    240257    if(pData == NULL) {
    241258        dprintf(("Win32ImageBase::getPEResourceSize: couldn't find resource %d (type %d, lang %x)", id, type, lang));
     
    246263//******************************************************************************
    247264//******************************************************************************
    248 HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     265HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG langid)
    249266{
    250267 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    252269 BOOL   fNumType;
    253270 char  *winres = NULL;
    254  ULONG  id, type;
    255  int    i, j;
     271 ULONG  id, type, lang;
     272 int    i, j, error;
    256273
    257274    fNumType = TRUE;    //assume numeric
     
    275292    else  type = (ULONG)lpszType;
    276293
    277     switch(lang) {
     294    switch(langid) {
    278295    case LOCALE_SYSTEM_DEFAULT:
    279296        lang = GetSystemDefaultLangID();
     
    285302        //TODO: Not correct; should take language associated with current thread
    286303        lang = IDLANG_GETFIRST;
    287         break;   
     304        break;
     305    case IDLANG_GETFIRST:
     306        lang = GetUserDefaultLangID();
     307        break;   
    288308    }
    289309    id = (ULONG)lpszName;
    290310
    291     pData = getPEResourceEntry(id, type, lang);
     311    pData = getPEResourceEntry(id, type, lang, &error);
    292312    if(pData == NULL) {
    293         if(HIWORD(id)) {
    294                 dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %s (type %d, lang %x)", szModule, id, type, lang));
    295         }
    296         else    dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %d (type %d, lang %x)", szModule, id, type, lang));
    297         return 0;
     313        //TODO: Optimize this; check if language wasn't found
     314        //try system default language
     315        if(error == RESERR_LANGNOTFOUND) {
     316                pData = getPEResourceEntry(id, type, GetSystemDefaultLangID(), &error);
     317        }
     318        if(pData == NULL) {
     319                //finally try first available language
     320                if(error == RESERR_LANGNOTFOUND) {
     321                        pData = getPEResourceEntry(id, type, IDLANG_GETFIRST, &error);
     322                }
     323                if(pData == NULL) {
     324                        if(HIWORD(id)) {
     325                                dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %s (type %d, lang %x)", szModule, id, type, lang));
     326                        }
     327                        else    dprintf(("Win32ImageBase::getPEResource %s: couldn't find resource %d (type %d, lang %x)", szModule, id, type, lang));
     328                        return 0;
     329                }
     330        }
    298331    }
    299332    if(HIWORD(id)) {
     
    374407{
    375408 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     409 int                             error;
    376410
    377411    if(verstruct == NULL || bufLength == 0) {
     
    379413        return FALSE;
    380414    }
    381     pData = getPEResourceEntry(ID_GETFIRST, NTRT_VERSION);
     415    pData = getPEResourceEntry(ID_GETFIRST, NTRT_VERSION, IDLANG_GETFIRST, &error);
    382416    if(pData == NULL) {
    383417        dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
Note: See TracChangeset for help on using the changeset viewer.