Changeset 60297 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Apr 3, 2016 5:10:48 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106343
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r59747 r60297 2959 2959 * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff. 2960 2960 */ 2961 IMAGE_LOAD_CONFIG_DIRECTORY32_V4 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V4 volatile *)pLoadCfg; 2962 IMAGE_LOAD_CONFIG_DIRECTORY64_V4 volatile *pLoadCfg64 = pLoadCfg; 2963 2964 pLoadCfg64->CodeIntegrity.Reserved = pLoadCfg32->CodeIntegrity.Reserved; 2965 pLoadCfg64->CodeIntegrity.CatalogOffset = pLoadCfg32->CodeIntegrity.CatalogOffset; 2966 pLoadCfg64->CodeIntegrity.Catalog = pLoadCfg32->CodeIntegrity.Catalog; 2967 pLoadCfg64->CodeIntegrity.Flags = pLoadCfg32->CodeIntegrity.Flags; 2968 pLoadCfg64->GuardFlags = pLoadCfg32->GuardFlags; 2969 pLoadCfg64->GuardCFFunctionCount = pLoadCfg32->GuardCFFunctionCount; 2970 pLoadCfg64->GuardCFFunctionTable = pLoadCfg32->GuardCFFunctionTable; 2971 pLoadCfg64->Reserved2 = pLoadCfg32->Reserved2; 2972 pLoadCfg64->GuardCFCCheckFunctionPointer= pLoadCfg32->GuardCFCCheckFunctionPointer; 2973 pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; 2974 pLoadCfg64->SEHandlerTable = pLoadCfg32->SEHandlerTable; 2975 pLoadCfg64->SecurityCookie = pLoadCfg32->SecurityCookie; 2976 pLoadCfg64->EditList = pLoadCfg32->EditList; 2977 pLoadCfg64->Reserved1 = pLoadCfg32->Reserved1; 2978 pLoadCfg64->CSDVersion = pLoadCfg32->CSDVersion; 2979 pLoadCfg64->ProcessHeapFlags = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */ 2980 pLoadCfg64->ProcessAffinityMask = pLoadCfg32->ProcessAffinityMask; 2981 pLoadCfg64->VirtualMemoryThreshold = pLoadCfg32->VirtualMemoryThreshold; 2982 pLoadCfg64->MaximumAllocationSize = pLoadCfg32->MaximumAllocationSize; 2983 pLoadCfg64->LockPrefixTable = pLoadCfg32->LockPrefixTable; 2984 pLoadCfg64->DeCommitTotalFreeThreshold = pLoadCfg32->DeCommitTotalFreeThreshold; 2985 uint32_t u32DeCommitFreeBlockThreshold = pLoadCfg32->DeCommitFreeBlockThreshold; 2986 pLoadCfg64->DeCommitFreeBlockThreshold = u32DeCommitFreeBlockThreshold; 2961 IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V5 volatile *)pLoadCfg; 2962 IMAGE_LOAD_CONFIG_DIRECTORY64_V5 volatile *pLoadCfg64 = pLoadCfg; 2963 2964 pLoadCfg64->GuardAddressTakenIatEntryTable = pLoadCfg32->GuardAddressTakenIatEntryTable; 2965 pLoadCfg64->GuardAddressTakenIatEntryCount = pLoadCfg32->GuardAddressTakenIatEntryCount; 2966 pLoadCfg64->GuardLongJumpTargetTable = pLoadCfg32->GuardLongJumpTargetTable; 2967 pLoadCfg64->GuardLongJumpTargetCount = pLoadCfg32->GuardLongJumpTargetCount; 2968 pLoadCfg64->CodeIntegrity.Reserved = pLoadCfg32->CodeIntegrity.Reserved; 2969 pLoadCfg64->CodeIntegrity.CatalogOffset = pLoadCfg32->CodeIntegrity.CatalogOffset; 2970 pLoadCfg64->CodeIntegrity.Catalog = pLoadCfg32->CodeIntegrity.Catalog; 2971 pLoadCfg64->CodeIntegrity.Flags = pLoadCfg32->CodeIntegrity.Flags; 2972 pLoadCfg64->GuardFlags = pLoadCfg32->GuardFlags; 2973 pLoadCfg64->GuardCFFunctionCount = pLoadCfg32->GuardCFFunctionCount; 2974 pLoadCfg64->GuardCFFunctionTable = pLoadCfg32->GuardCFFunctionTable; 2975 pLoadCfg64->Reserved2 = pLoadCfg32->Reserved2; 2976 pLoadCfg64->GuardCFCCheckFunctionPointer = pLoadCfg32->GuardCFCCheckFunctionPointer; 2977 pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; 2978 pLoadCfg64->SEHandlerTable = pLoadCfg32->SEHandlerTable; 2979 pLoadCfg64->SecurityCookie = pLoadCfg32->SecurityCookie; 2980 pLoadCfg64->EditList = pLoadCfg32->EditList; 2981 pLoadCfg64->Reserved1 = pLoadCfg32->Reserved1; 2982 pLoadCfg64->CSDVersion = pLoadCfg32->CSDVersion; 2983 pLoadCfg64->ProcessHeapFlags = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */ 2984 pLoadCfg64->ProcessAffinityMask = pLoadCfg32->ProcessAffinityMask; 2985 pLoadCfg64->VirtualMemoryThreshold = pLoadCfg32->VirtualMemoryThreshold; 2986 pLoadCfg64->MaximumAllocationSize = pLoadCfg32->MaximumAllocationSize; 2987 pLoadCfg64->LockPrefixTable = pLoadCfg32->LockPrefixTable; 2988 pLoadCfg64->DeCommitTotalFreeThreshold = pLoadCfg32->DeCommitTotalFreeThreshold; 2989 uint32_t u32DeCommitFreeBlockThreshold = pLoadCfg32->DeCommitFreeBlockThreshold; 2990 pLoadCfg64->DeCommitFreeBlockThreshold = u32DeCommitFreeBlockThreshold; 2987 2991 /* the rest is equal. */ 2988 2992 Assert( RT_OFFSETOF(IMAGE_LOAD_CONFIG_DIRECTORY32, DeCommitFreeBlockThreshold) … … 3487 3491 * @param fFlags Loader flags, RTLDR_O_XXX. 3488 3492 */ 3489 static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const IMAGE_OPTIONAL_HEADER64 *pOptHdr, uint32_t fFlags) 3493 static int rtldrPEValidateDirectoriesAndRememberStuff(PRTLDRMODPE pModPe, const IMAGE_OPTIONAL_HEADER64 *pOptHdr, uint32_t fFlags, 3494 PRTERRINFO pErrInfo) 3490 3495 { 3491 3496 const char *pszLogName = pModPe->Core.pReader->pfnLogName(pModPe->Core.pReader); NOREF(pszLogName); … … 3503 3508 if (Dir.Size) 3504 3509 { 3510 const size_t cbExpectV5 = !pModPe->f64Bit 3511 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V5) 3512 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5); 3505 3513 const size_t cbExpectV4 = !pModPe->f64Bit 3506 3514 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V4) … … 3516 3524 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/; 3517 3525 3518 if ( Dir.Size != cbExpectV4 3526 if ( Dir.Size != cbExpectV5 3527 && Dir.Size != cbExpectV4 3519 3528 && Dir.Size != cbExpectV3 3520 3529 && Dir.Size != cbExpectV2 3521 3530 && Dir.Size != cbExpectV1) 3522 3531 { 3523 Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %d bytes, expected %d, %d, %d, or %d.\n", 3524 pszLogName, Dir.Size, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1)); 3525 return VERR_LDRPE_LOAD_CONFIG_SIZE; 3532 Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.\n", 3533 pszLogName, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1)); 3534 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3535 "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu", 3536 Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1); 3526 3537 } 3527 3538 … … 3579 3590 Log(("rtldrPEOpen: %s: load cfg dir: unexpected header size of %d bytes, expected %d.\n", 3580 3591 pszLogName, u.Cfg64.Size, Dir.Size)); 3581 return VERR_LDRPE_LOAD_CONFIG_SIZE; 3592 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3593 "Load config header vs directory size mismatch: %#x vs %#x", u.Cfg64.Size, Dir.Size); 3582 3594 } 3583 3595 } … … 3586 3598 Log(("rtldrPEOpen: %s: load cfg dir: lock prefix table at %RX64. We don't support lock prefix tables!\n", 3587 3599 pszLogName, u.Cfg64.LockPrefixTable)); 3588 return VERR_LDRPE_LOCK_PREFIX_TABLE; 3600 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOCK_PREFIX_TABLE, 3601 "Lock prefix table not supported: %RX64", u.Cfg64.LockPrefixTable); 3589 3602 } 3590 3603 #if 0/* this seems to be safe to ignore. */ … … 3601 3614 Log(("rtldrPEOpen: %s: load cfg dir: EditList=%RX64 is unsupported!\n", 3602 3615 pszLogName, u.Cfg64.EditList)); 3603 return VERR_BAD_EXE_FORMAT;3616 return RTErrInfoSetF(pErrInfo, VERR_BAD_EXE_FORMAT, "Load config EditList=%RX64 is not supported", u.Cfg64.EditList); 3604 3617 } 3605 3618 /** @todo GuardCFC? Possibly related to: … … 3611 3624 || u.Cfg64.GuardCFFunctionTable 3612 3625 || u.Cfg64.GuardCFFunctionCount 3613 || u.Cfg64.GuardFlags) 3614 && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION))) 3615 { 3616 Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32!\n", 3626 || u.Cfg64.GuardFlags 3627 || u.Cfg64.GuardAddressTakenIatEntryTable 3628 || u.Cfg64.GuardAddressTakenIatEntryCount 3629 || u.Cfg64.GuardLongJumpTargetTable 3630 || u.Cfg64.GuardLongJumpTargetCount) 3631 && !(fFlags & (RTLDR_O_FOR_DEBUG | RTLDR_O_FOR_VALIDATION)) ) 3632 { 3633 Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!\n", 3617 3634 pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2, 3618 u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags)); 3619 return VERR_BAD_EXE_FORMAT; 3635 u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, 3636 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount, 3637 u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount )); 3638 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_GUARD_CF_STUFF, 3639 "Guard bits in load config: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!", 3640 u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.Reserved2, 3641 u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, 3642 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount, 3643 u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount); 3620 3644 } 3621 3645 } … … 3644 3668 { 3645 3669 Log(("rtldrPEOpen: %s: cert at %#x/%#x: dwLength=%#x\n", pszLogName, off, Dir.Size, pCur->dwLength)); 3646 rc = VERR_LDRPE_CERT_MALFORMED; 3670 rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, 3671 "Cert at %#x LB %#x: Bad header length value: %#x", off, Dir.Size, pCur->dwLength); 3647 3672 break; 3648 3673 } … … 3651 3676 { 3652 3677 Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); 3653 rc = pCur->wRevision >= WIN_CERT_REVISION_1_0 ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; 3678 if (pCur->wRevision >= WIN_CERT_REVISION_1_0) 3679 rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_UNSUPPORTED, 3680 "Cert at %#x LB %#x: Unsupported revision: %#x", off, Dir.Size, pCur->wRevision); 3681 else 3682 rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, 3683 "Cert at %#x LB %#x: Malformed revision: %#x", off, Dir.Size, pCur->wRevision); 3654 3684 break; 3655 3685 } … … 3662 3692 ) 3663 3693 { 3664 Log(("rtldrPEOpen: %s: cert at %#x/%#x: wRevision=%#x\n", pszLogName, off, Dir.Size, pCur->wRevision)); 3665 rc = pCur->wCertificateType ? VERR_LDRPE_CERT_UNSUPPORTED : VERR_LDRPE_CERT_MALFORMED; 3694 Log(("rtldrPEOpen: %s: cert at %#x/%#x: wCertificateType=%#x\n", pszLogName, off, Dir.Size, pCur->wCertificateType)); 3695 if (pCur->wCertificateType) 3696 rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_UNSUPPORTED, 3697 "Cert at %#x LB %#x: Unsupported certificate type: %#x", 3698 off, Dir.Size, pCur->wCertificateType); 3699 else 3700 rc = RTErrInfoSetF(pErrInfo, VERR_LDRPE_CERT_MALFORMED, 3701 "Cert at %#x LB %#x: Malformed certificate type: %#x", 3702 off, Dir.Size, pCur->wCertificateType); 3666 3703 break; 3667 3704 } … … 3815 3852 * information. 3816 3853 */ 3817 rc = rtldrPEValidateDirectoriesAndRememberStuff(pModPe, &OptHdr, fFlags );3854 rc = rtldrPEValidateDirectoriesAndRememberStuff(pModPe, &OptHdr, fFlags, pErrInfo); 3818 3855 if (RT_SUCCESS(rc)) 3819 3856 {
Note:
See TracChangeset
for help on using the changeset viewer.