Changeset 1118 for trunk/src/kernel32/winimgres.cpp
- Timestamp:
- Oct 4, 1999, 11:56:04 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimgres.cpp
r1016 r1118 1 /* $Id: winimgres.cpp,v 1.1 7 1999-09-23 14:12:14 phallerExp $ */1 /* $Id: winimgres.cpp,v 1.18 1999-10-04 09:55:57 sandervl Exp $ */ 2 2 3 3 /* … … 11 11 * TODO: Check created resource objects before loading the resource! 12 12 * 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, 14 14 * getVersionStruct/Size can be moved into the Win32ImageBase class 15 15 * … … 36 36 //PE spec says names & ids are sorted; keep on searching just to be sure 37 37 //****************************************************************************** 38 PIMAGE_RESOURCE_DATA_ENTRY 38 PIMAGE_RESOURCE_DATA_ENTRY 39 39 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang) 40 40 { … … 73 73 prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData); 74 74 75 if(i < pResDir->NumberOfNamedEntries) 75 if(i < pResDir->NumberOfNamedEntries) 76 76 {//name or id entry? 77 77 //SvL: 30-10-'97, high bit is set, so clear to get real offset … … 82 82 lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1); 83 83 typename[pstring->Length] = 0; 84 84 85 85 if(!fNumType) { 86 86 if(stricmp(typename, (char *)type) == 0) { … … 380 380 HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang) 381 381 { 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); 410 401 } 411 402 //****************************************************************************** … … 427 418 ULONG Win32ImageBase::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang) 428 419 { 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); 458 439 } 459 440 //****************************************************************************** … … 489 470 PIMAGE_RESOURCE_DATA_ENTRY pData = NULL; 490 471 472 if(verstruct == NULL || bufLength == 0) { 473 SetLastError(ERROR_INVALID_PARAMETER); 474 return FALSE; 475 } 491 476 pData = getPEResourceEntry(1, NTRT_VERSION); 492 477 if(pData == NULL) { … … 494 479 return 0; 495 480 } 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.