Changeset 53818 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jan 15, 2015 1:49:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r52839 r53818 3217 3217 * @param cbRawImage The raw image size. 3218 3218 * @param fFlags Loader flags, RTLDR_O_XXX. 3219 * @param fNoCode Verify that the image contains no code. 3219 3220 */ 3220 3221 static int rtldrPEValidateSectionHeaders(const IMAGE_SECTION_HEADER *paSections, unsigned cSections, const char *pszLogName, 3221 const IMAGE_OPTIONAL_HEADER64 *pOptHdr, RTFOFF cbRawImage, uint32_t fFlags )3222 const IMAGE_OPTIONAL_HEADER64 *pOptHdr, RTFOFF cbRawImage, uint32_t fFlags, bool fNoCode) 3222 3223 { 3223 3224 const uint32_t cbImage = pOptHdr->SizeOfImage; … … 3305 3306 uRvaPrev = pSH->VirtualAddress + pSH->Misc.VirtualSize; 3306 3307 } 3308 3309 /* 3310 * Do a separate run if we need to validate the no-code claim from the 3311 * optional header. 3312 */ 3313 if (fNoCode) 3314 { 3315 pSH = &paSections[0]; 3316 for (unsigned cSHdrsLeft = cSections; cSHdrsLeft > 0; cSHdrsLeft--, pSH++) 3317 if (pSH->Characteristics & (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE)) 3318 return VERR_LDR_ARCH_MISMATCH; 3319 } 3320 3307 3321 3308 3322 /** @todo r=bird: more sanity checks! */ … … 3618 3632 * Match the CPU architecture. 3619 3633 */ 3620 if ( enmArch != RTLDRARCH_WHATEVER 3621 && enmArch != enmArchImage) 3622 return VERR_LDR_ARCH_MISMATCH; 3634 bool fArchNoCodeCheckPending = false; 3635 if ( enmArch != enmArchImage 3636 && ( enmArch != RTLDRARCH_WHATEVER 3637 && !(fFlags & RTLDR_O_WHATEVER_ARCH)) ) 3638 { 3639 if (!(fFlags & RTLDR_O_IGNORE_ARCH_IF_NO_CODE)) 3640 return VERR_LDR_ARCH_MISMATCH; 3641 fArchNoCodeCheckPending = true; 3642 } 3623 3643 3624 3644 /* … … 3634 3654 if (RT_FAILURE(rc)) 3635 3655 return rc; 3656 if (fArchNoCodeCheckPending && OptHdr.SizeOfCode != 0) 3657 return VERR_LDR_ARCH_MISMATCH; 3636 3658 3637 3659 /* … … 3647 3669 { 3648 3670 rc = rtldrPEValidateSectionHeaders(paSections, FileHdr.NumberOfSections, pszLogName, 3649 &OptHdr, pReader->pfnSize(pReader), fFlags );3671 &OptHdr, pReader->pfnSize(pReader), fFlags, fArchNoCodeCheckPending); 3650 3672 if (RT_SUCCESS(rc)) 3651 3673 {
Note:
See TracChangeset
for help on using the changeset viewer.