Changeset 1708 for trunk/src/kernel32/winimagepeldr.cpp
- Timestamp:
- Nov 11, 1999, 8:10:09 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimagepeldr.cpp
r1663 r1708 1 /* $Id: winimagepeldr.cpp,v 1.1 1 1999-11-09 14:19:47sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.12 1999-11-11 19:10:09 sandervl Exp $ */ 2 2 3 3 /* … … 73 73 imageVirtBase(-1), realBaseAddress(0), imageVirtEnd(0), 74 74 nrNameExports(0), nrOrdExports(0), nameexports(NULL), ordexports(NULL), 75 pResSection(NULL),fImgMapping(0)75 fImgMapping(0) 76 76 { 77 77 HFILE dllfile; … … 140 140 ULONG filesize, ulRead; 141 141 PIMAGE_SECTION_HEADER psh; 142 IMAGE_SECTION_HEADER sh; 142 143 IMAGE_TLS_DIRECTORY *tlsDir = NULL; 143 144 int nSections, i; … … 315 316 } 316 317 } 317 fout << "*************************PE SECTIONS END **************************" << endl; 318 imageSize += imageVirtBase - oh.ImageBase; 319 fout << "Total size of Image " << imageSize << endl; 320 fout << "imageVirtBase " << imageVirtBase << endl; 321 fout << "imageVirtEnd " << imageVirtEnd << endl; 322 323 //In case there are any gaps between sections, adjust size 324 if(imageSize != imageVirtEnd - oh.ImageBase) { 318 } 319 else { 320 if(GetSectionHdrByName (win32file, &sh, ".rsrc")) 321 { 322 addSection(SECTION_RESOURCE, (char *)win32file+sh.PointerToRawData, 323 sh.SizeOfRawData, sh.VirtualAddress + oh.ImageBase, 324 sh.Misc.VirtualSize); 325 } 326 } 327 fout << "*************************PE SECTIONS END **************************" << endl; 328 imageSize += imageVirtBase - oh.ImageBase; 329 fout << "Total size of Image " << imageSize << endl; 330 fout << "imageVirtBase " << imageVirtBase << endl; 331 fout << "imageVirtEnd " << imageVirtEnd << endl; 332 333 //In case there are any gaps between sections, adjust size 334 if(imageSize != imageVirtEnd - oh.ImageBase) { 325 335 fout << "imageSize != imageVirtEnd - oh.ImageBase!" << endl; 326 336 imageSize = imageVirtEnd - oh.ImageBase; 327 328 337 } 338 if(allocSections(reservedMem) == FALSE) { 329 339 fout << "Failed to allocate image memory, rc " << errorState << endl; 330 340 goto failure; 331 332 333 341 } 342 fout << "OS/2 base address " << realBaseAddress << endl; 343 if(storeSections((char *)win32file) == FALSE) { 334 344 fout << "Failed to store sections, rc " << errorState << endl; 335 345 goto failure; 336 337 346 } 347 if(oh.AddressOfEntryPoint) { 338 348 entryPoint = realBaseAddress + oh.AddressOfEntryPoint; 339 340 349 } 350 else { 341 351 fout << "EntryPoint == NULL" << endl; 342 352 entryPoint = NULL; 343 } 344 353 } 354 355 if(loadType == REAL_LOAD) 356 { 345 357 if(tlsDir != NULL) { 346 358 Section *sect = findSection(SECTION_TLS); … … 381 393 } 382 394 } 383 384 //SvL: Use pointer to image header as module handle now. Some apps needs this 385 hinstance = (HINSTANCE)realBaseAddress;386 }395 } 396 397 //SvL: Use pointer to image header as module handle now. Some apps needs this 398 hinstance = (HINSTANCE)realBaseAddress; 387 399 388 400 //PH: get pResDir pointer correct first, since processImports may 389 401 // implicitly call functions depending on it. 390 IMAGE_SECTION_HEADER sh;391 402 if(GetSectionHdrByName (win32file, &sh, ".rsrc")) { 392 403 //get offset in resource object of directory entry 393 404 pResDir = (PIMAGE_RESOURCE_DIRECTORY)(sh.VirtualAddress + realBaseAddress); 394 pResourceSectionStart = (ULONG)pResSection->virtaddr - oh.ImageBase;405 pResourceSectionStart = sh.VirtualAddress; 395 406 } 396 407 … … 401 412 goto failure; 402 413 } 403 404 //set final memory protection flags (storeSections sets them to read/write) 405 if(setMemFlags() == FALSE) { 414 } 415 416 //set final memory protection flags (storeSections sets them to read/write) 417 if(setMemFlags() == FALSE) { 406 418 fout << "Failed to set memory protection" << endl; 407 419 goto failure; 408 409 410 411 } 420 } 421 CloseHandle(fImgMapping); 422 fImgMapping = 0; 423 412 424 return(TRUE); 413 425 failure: … … 428 440 section[nrsections].virtaddr = virtaddress; 429 441 430 if(type == SECTION_RESOURCE) {431 pResSection = §ion[nrsections];432 }433 442 virtsize = ((virtsize - 1) & ~0xFFF) + PAGE_SIZE; 434 443 imageSize += virtsize;
Note:
See TracChangeset
for help on using the changeset viewer.