Changeset 4474 for trunk/src/kernel32/winimagepeldr.cpp
- Timestamp:
- Oct 10, 2000, 7:14:09 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimagepeldr.cpp
r4471 r4474 1 /* $Id: winimagepeldr.cpp,v 1. 59 2000-10-09 18:35:26sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.60 2000-10-10 17:14:08 sandervl Exp $ */ 2 2 3 3 /* … … 14 14 * (circular dependencies; have to check what NT does) 15 15 * 16 * NOTE: RSRC_LOADis a special flag to only load the resource directory16 * NOTE: FLAG_PELDR_LOADASDATAFILE is a special flag to only load the resource directory 17 17 * of a PE image. Processing imports, sections etc is not done. 18 * Nor is it put into the linked list of dlls (if it's a dll).19 18 * This is useful for GetVersionSize/Resource in case it wants to 20 19 * get version info of an image that is not loaded. … … 103 102 //****************************************************************************** 104 103 //****************************************************************************** 105 Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe , int loadtype) :104 Win32PeLdrImage::Win32PeLdrImage(char *pszFileName, BOOL isExe) : 106 105 Win32ImageBase(-1), 107 nrsections(0), imageSize(0), 106 nrsections(0), imageSize(0), dwFlags(0), 108 107 imageVirtBase(-1), realBaseAddress(0), imageVirtEnd(0), 109 108 nrNameExports(0), nrOrdExports(0), nameexports(NULL), ordexports(NULL), … … 111 110 { 112 111 HFILE dllfile; 113 114 loadType = loadtype;115 112 116 113 strcpy(szFileName, pszFileName); … … 282 279 nSections = NR_SECTIONS(win32file); 283 280 284 if( loadType == REAL_LOAD)281 if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE)) 285 282 { 286 283 imageSize = 0; … … 307 304 if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_EXPORT)) 308 305 { 309 dprintf((LOG, ".edata" )); 310 addSection(SECTION_EXPORT, psh[i].PointerToRawData, 311 psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase, 312 psh[i].Misc.VirtualSize, psh[i].Characteristics); 313 continue; 306 //SvL: Angus.exe has empty export section that's really an 307 // uninitialized data section 308 if(psh[i].SizeOfRawData) { 309 dprintf((LOG, ".edata" )); 310 addSection(SECTION_EXPORT, psh[i].PointerToRawData, 311 psh[i].SizeOfRawData, psh[i].VirtualAddress + oh.ImageBase, 312 psh[i].Misc.VirtualSize, psh[i].Characteristics); 313 continue; 314 } 314 315 } 315 316 if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_RESOURCE)) … … 439 440 } 440 441 441 if( loadType == REAL_LOAD)442 if(!(dwFlags & FLAG_PELDR_LOADASDATAFILE)) 442 443 { 443 444 if(tlsDir = (IMAGE_TLS_DIRECTORY *)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_TLS)) … … 554 555 } 555 556 556 if (loadType == REAL_LOAD)557 if(!(dwFlags & (FLAG_PELDR_LOADASDATAFILE | FLAG_PELDR_SKIPIMPORTS))) 557 558 { 558 if(processImports((char *)win32file) == FALSE) { 559 dprintf((LOG, "Failed to process imports!" )); 560 goto failure; 561 } 562 } 563 559 if(processImports((char *)win32file) == FALSE) { 560 dprintf((LOG, "Failed to process imports!" )); 561 goto failure; 562 } 563 } 564 564 return(TRUE); 565 565 566 failure: 566 567 if(memmap) { … … 730 731 731 732 //SvL: We don't care where the image is loaded for resource lookup 732 if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && loadType == REAL_LOAD) {733 if(fh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED && !(dwFlags & FLAG_PELDR_LOADASDATAFILE)) { 733 734 return allocFixedMem(reservedMem); 734 735 } … … 898 899 899 900 case SECTION_READONLYDATA: 901 case SECTION_EXPORT: 900 902 default: 901 903 section[i].pageflags = PAG_READ; 902 904 break; 903 905 } 906 if(section[i].flags & (IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { 907 //SvL: sometimes i.e. import/export sections also contain data 908 // must make them read/write 909 section[i].pageflags = PAG_WRITE; 910 } 911 904 912 } 905 913 return(TRUE); … … 1486 1494 { 1487 1495 dprintf((LOG, "Module %s", pszCurModule )); 1488 dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain)); 1496 if(pID[i].ForwarderChain) { 1497 dprintf((LOG, "ForwarderChain: %x", pID[i].ForwarderChain)); 1498 } 1489 1499 // a) check that OriginalFirstThunk not is 0 and look for Borland-styled PE 1490 1500 if (i == 0)
Note:
See TracChangeset
for help on using the changeset viewer.