Changeset 4047 for trunk/src/kernel32/winimagepe2lx.cpp
- Timestamp:
- Aug 19, 2000, 7:22:52 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimagepe2lx.cpp
r3765 r4047 1 /* $Id: winimagepe2lx.cpp,v 1.1 1 2000-06-28 18:08:35 sandervlExp $ */1 /* $Id: winimagepe2lx.cpp,v 1.12 2000-08-19 17:22:52 bird Exp $ */ 2 2 3 3 /* … … 260 260 ulRVAResourceSection = pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; 261 261 pResRootDir = (PIMAGE_RESOURCE_DIRECTORY)getPointerFromRVA(ulRVAResourceSection); 262 263 /* 264 * Temporary fix. 265 * Make resource section writable. 266 * Make 64 KB before the resource section present. 267 */ 268 int iSection; 269 if (pResRootDir != NULL && (iSection = getSectionIndexFromRVA(ulRVAResourceSection)) != -1) 270 { 271 ULONG ulAddr = paSections[iSection].ulAddress; 272 rc = DosSetMem((PVOID)ulAddr, paSections[iSection].cbVirtual, PAG_WRITE | PAG_READ); 273 ulAddr -= 0x10000; 274 while (ulAddr < paSections[iSection].ulAddress) 275 { 276 ULONG fl = ~0UL; 277 ULONG cb = ~0UL; 278 if ((rc = DosQueryMem((PVOID)ulAddr, &cb, &fl)) == NO_ERROR) 279 { 280 if ((fl & PAG_COMMIT) == 0) 281 { 282 fl &= PAG_WRITE & PAG_READ & PAG_GUARD; 283 if ((fl & PAG_READ) == 0) 284 fl |= PAG_READ; 285 rc = DosSetMem((PVOID)ulAddr, cb, fl | PAG_COMMIT); 286 } 287 288 ulAddr += cb; 289 } 290 } 291 rc = NO_ERROR; 292 } 262 293 } 263 294 … … 593 624 } 594 625 626 627 /** 628 * Gets the (0-based) index into paSection of the section holding the 629 * given ulRVA. 630 * @returns Section index (0 based). 631 * -1 on error. 632 * @param ulRVA Relative Virtual Address. 633 * @sketch DEBUG: validate state, paSections != NULL 634 * IF ulRVA is 0 THEN return NULL 635 * LOOP while more section left and ulRVA is not within section 636 * next section 637 * IF section matching ulRVA is not found THEN fail. 638 * The index. 639 * @status 640 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 641 * @remark 642 */ 643 LONG Win32Pe2LxImage::getSectionIndexFromRVA(ULONG ulRVA) 644 { 645 int i; 646 #ifdef DEBUG 647 if (paSections == NULL) 648 return NULL; 649 #endif 650 651 if (ulRVA == 0UL) 652 return NULL; 653 654 i = 0; 655 while (i < cSections && 656 !(paSections[i].ulRVA <= ulRVA && paSections[i].ulRVA + paSections[i].cbVirtual > ulRVA)) /* ALIGN on page too? */ 657 i++; 658 659 if (i >= cSections) 660 return -1; 661 662 return i; 663 } 664 665 595 666 /** 596 667 * Gets pointer to an exported procedure by procedure name.
Note:
See TracChangeset
for help on using the changeset viewer.