Ignore:
Timestamp:
Oct 4, 1999, 11:56:04 AM (26 years ago)
Author:
sandervl
Message:

Lots of changes by several people (see changelog for 4 October

File:
1 edited

Legend:

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

    r1016 r1118  
    1 /* $Id: winimgres.cpp,v 1.17 1999-09-23 14:12:14 phaller Exp $ */
     1/* $Id: winimgres.cpp,v 1.18 1999-10-04 09:55:57 sandervl 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) {
     
    380380HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang)
    381381{
    382   HRSRC hres;
    383   char *astring1 = NULL,
    384        *astring2 = NULL;
    385   BOOL fAllocated1 = FALSE;
    386   BOOL fAllocated2 = FALSE;
    387 
    388   if(HIWORD(lpszName) != 0)
    389   {
    390     astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
    391     fAllocated1 = TRUE;
    392   }
    393   else
    394     astring1 = (char *)lpszName;
    395 
    396   if(HIWORD(lpszType) != 0)
    397   {
    398     astring2 = UnicodeToAsciiString(lpszType);
    399     fAllocated2 = TRUE;
    400   }
    401   else
    402     astring2 = (char *)lpszType;
    403   hres = (HRSRC) findResourceA(astring1, astring2);
    404 
    405    /* do NOT free untranslated numerical Resource IDs */
    406   if(fAllocated1) FreeAsciiString(astring1);
    407   if(fAllocated2) FreeAsciiString(astring2);
    408 
    409   return(hres);
     382 HRSRC hres;
     383 char *astring1 = NULL, *astring2 = NULL;
     384
     385    if(HIWORD(lpszName) != 0) {
     386                astring1 = UnicodeToAsciiString(lpszName);
     387    }
     388    else        astring1 = (char *)lpszName;
     389
     390    if(HIWORD(lpszType) != 0) {
     391                astring2 = UnicodeToAsciiString(lpszType);
     392    }
     393    else        astring2 = (char *)lpszType;
     394
     395    hres = (HRSRC) findResourceA(astring1, astring2);
     396
     397    if(HIWORD(astring1)) FreeAsciiString(astring1);
     398    if(HIWORD(astring2)) FreeAsciiString(astring2);
     399
     400    return(hres);
    410401}
    411402//******************************************************************************
     
    427418ULONG Win32ImageBase::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang)
    428419{
    429   char *astring1 = NULL,
    430        *astring2 = NULL;
    431   ULONG ressize;
    432   BOOL fAllocated1 = FALSE;
    433   BOOL fAllocated2 = FALSE;
    434 
    435   if(HIWORD(lpszName) != 0)
    436   {
    437     astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
    438     fAllocated1 = TRUE;
    439   }
    440   else
    441     astring1 = (char *)lpszName;
    442 
    443   if(HIWORD(lpszType) != 0)
    444   {
    445     astring2 = UnicodeToAsciiString(lpszType);
    446     fAllocated2 = TRUE;
    447   }
    448   else
    449     astring2 = (char *)lpszType;
    450 
    451   ressize =  getResourceSizeA(astring1, astring2, lang);
    452 
    453   /* do NOT free untranslated numerical Resource IDs */
    454   if(fAllocated1) FreeAsciiString(astring1);
    455   if(fAllocated2) FreeAsciiString(astring2);
    456 
    457   return(ressize);
     420 char *astring1 = NULL, *astring2 = NULL;
     421 ULONG ressize;
     422
     423    if(HIWORD(lpszName) != 0) {
     424                astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
     425    }
     426    else        astring1 = (char *)lpszName;
     427
     428    if(HIWORD(lpszType) != 0) {
     429                astring2 = UnicodeToAsciiString(lpszType);
     430    }
     431    else        astring2 = (char *)lpszType;
     432
     433    ressize =  getResourceSizeA(astring2, astring1, lang);
     434
     435    if(HIWORD(astring1)) FreeAsciiString(astring1);
     436    if(HIWORD(astring2)) FreeAsciiString(astring2);
     437
     438    return(ressize);
    458439}
    459440//******************************************************************************
     
    489470 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
    490471
     472  if(verstruct == NULL || bufLength == 0) {
     473        SetLastError(ERROR_INVALID_PARAMETER);
     474        return FALSE;
     475  }
    491476  pData = getPEResourceEntry(1, NTRT_VERSION);
    492477  if(pData == NULL) {
     
    494479        return 0;
    495480  }
    496   return pData->Size;
    497 }
    498 //******************************************************************************
    499 //******************************************************************************
     481  char *resdata = (char *)((char *)pResDir + pData->OffsetToData - pResourceSectionStart);
     482  memcpy(verstruct, resdata, min(bufLength, pData->Size));
     483  return TRUE;
     484}
     485//******************************************************************************
     486//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.