Changeset 1015 for trunk/src


Ignore:
Timestamp:
Sep 23, 1999, 3:54:37 PM (26 years ago)
Author:
phaller
Message:

Fix: WinImgRes:findResourceW erroneously tried to free numerical resource IDs

File:
1 edited

Legend:

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

    r978 r1015  
    1 /* $Id: winimgres.cpp,v 1.15 1999-09-18 17:47:10 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.16 1999-09-23 13:53:38 phaller Exp $ */
    22
    33/*
     
    1111 * TODO: Check created resource objects before loading the resource!
    1212 * TODO: Is the name id of the version resource always 1?
    13  * TODO: Once the resource handling in PE2LX/win32k is changed, 
     13 * TODO: Once the resource handling in PE2LX/win32k is changed,
    1414 *       getVersionStruct/Size can be moved into the Win32ImageBase class
    1515 *
     
    3636//PE spec says names & ids are sorted; keep on searching just to be sure
    3737//******************************************************************************
    38 PIMAGE_RESOURCE_DATA_ENTRY 
     38PIMAGE_RESOURCE_DATA_ENTRY
    3939 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
    4040{
     
    7373    prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData);
    7474
    75     if(i < pResDir->NumberOfNamedEntries) 
     75    if(i < pResDir->NumberOfNamedEntries)
    7676    {//name or id entry?
    7777        //SvL: 30-10-'97, high bit is set, so clear to get real offset
     
    8282        lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1);
    8383        typename[pstring->Length] = 0;
    84        
     84
    8585        if(!fNumType) {
    8686            if(stricmp(typename, (char *)type) == 0) {
     
    381381{
    382382 HRSRC hres;
    383  char *astring1 = NULL, *astring2 = NULL;
    384 
    385     if(HIWORD(lpszType) != 0) {
    386                 astring1 = UnicodeToAsciiString(lpszType);
    387     }
    388     else        astring1 = (char *)lpszType;
    389 
    390     if(HIWORD(lpszName) != 0) {
    391                 astring2 = UnicodeToAsciiString(lpszName);
    392     }
    393     else        astring2 = (char *)lpszName;
     383 char *astring1 = NULL,
     384      *astring2 = NULL;
     385
     386    if(HIWORD(lpszType) != 0) astring1 = UnicodeToAsciiString(lpszType);
     387    else                      astring1 = (char *)lpszType;
     388    if(HIWORD(lpszName) != 0) astring2 = UnicodeToAsciiString(lpszName);
     389    else                      astring2 = (char *)lpszName;
    394390
    395391    hres = (HRSRC) findResourceA(astring1, astring2);
    396     if(astring1) FreeAsciiString(astring1);
    397     if(astring2) FreeAsciiString(astring2);
     392
     393    /* do NOT free untranslated numerical Resource IDs */
     394    if(HIWORD(astring1)) FreeAsciiString(astring1);
     395    if(HIWORD(astring2)) FreeAsciiString(astring2);
    398396
    399397    return(hres);
     
    422420    if(HIWORD(lpszType) != 0) {
    423421                char *resname = UnicodeToAsciiString(lpszType);
    424     } 
     422    }
    425423    else        astring1 = (char *)lpszType;
    426424
Note: See TracChangeset for help on using the changeset viewer.