Changeset 64204 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Oct 11, 2016 10:36:05 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r63561 r64204 2972 2972 * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff. 2973 2973 */ 2974 IMAGE_LOAD_CONFIG_DIRECTORY32_V 5 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V5volatile *)pLoadCfg;2975 IMAGE_LOAD_CONFIG_DIRECTORY64_V 5volatile *pLoadCfg64 = pLoadCfg;2974 IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *)pLoadCfg; 2975 IMAGE_LOAD_CONFIG_DIRECTORY64_V7 volatile *pLoadCfg64 = pLoadCfg; 2976 2976 2977 2977 pLoadCfg64->GuardAddressTakenIatEntryTable = pLoadCfg32->GuardAddressTakenIatEntryTable; … … 2986 2986 pLoadCfg64->GuardCFFunctionCount = pLoadCfg32->GuardCFFunctionCount; 2987 2987 pLoadCfg64->GuardCFFunctionTable = pLoadCfg32->GuardCFFunctionTable; 2988 pLoadCfg64-> Reserved2 = pLoadCfg32->Reserved2;2988 pLoadCfg64->GuardCFDispatchFunctionPointer = pLoadCfg32->GuardCFDispatchFunctionPointer; 2989 2989 pLoadCfg64->GuardCFCCheckFunctionPointer = pLoadCfg32->GuardCFCCheckFunctionPointer; 2990 2990 pLoadCfg64->SEHandlerCount = pLoadCfg32->SEHandlerCount; … … 2992 2992 pLoadCfg64->SecurityCookie = pLoadCfg32->SecurityCookie; 2993 2993 pLoadCfg64->EditList = pLoadCfg32->EditList; 2994 pLoadCfg64-> Reserved1 = pLoadCfg32->Reserved1;2994 pLoadCfg64->DependentLoadFlags = pLoadCfg32->DependentLoadFlags; 2995 2995 pLoadCfg64->CSDVersion = pLoadCfg32->CSDVersion; 2996 2996 pLoadCfg64->ProcessHeapFlags = pLoadCfg32->ProcessHeapFlags; /* switched place with ProcessAffinityMask, but we're more than 16 byte off by now so it doesn't matter. */ … … 3518 3518 { 3519 3519 IMAGE_LOAD_CONFIG_DIRECTORY64 Cfg64; 3520 uint8_t abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V 5) * 4];3520 uint8_t abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V7) * 4]; 3521 3521 } u; 3522 3522 … … 3529 3529 if (Dir.Size) 3530 3530 { 3531 const size_t cbExpectV7 = !pModPe->f64Bit 3532 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V7) 3533 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V7); 3534 const size_t cbExpectV6 = !pModPe->f64Bit 3535 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V6) 3536 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V6); 3531 3537 const size_t cbExpectV5 = !pModPe->f64Bit 3532 3538 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V5) … … 3544 3550 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V1) 3545 3551 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/; 3552 const size_t cbNewHack = cbExpectV5; /* Playing safe here since there might've been revisions between V5 and V6 we don't know about . */ 3553 const size_t cbMaxKnown = cbExpectV7; 3546 3554 3547 3555 bool fNewerStructureHack = false; 3548 if ( Dir.Size != cbExpectV5 3556 if ( Dir.Size != cbExpectV7 3557 && Dir.Size != cbExpectV6 3558 && Dir.Size != cbExpectV5 3549 3559 && Dir.Size != cbExpectV4 3550 3560 && Dir.Size != cbExpectV3 … … 3552 3562 && Dir.Size != cbExpectV1) 3553 3563 { 3554 fNewerStructureHack = Dir.Size > cb ExpectV5/* These structure changes are slowly getting to us! More futher down. */3564 fNewerStructureHack = Dir.Size > cbNewHack /* These structure changes are slowly getting to us! More futher down. */ 3555 3565 && Dir.Size <= sizeof(u); 3556 Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.%s\n",3557 pszLogName, Dir.Size, cbExpectV 5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,3566 Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n", 3567 pszLogName, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1, 3558 3568 fNewerStructureHack ? " Will try ignore extra bytes if all zero." : "")); 3559 3569 if (!fNewerStructureHack) 3560 3570 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3561 "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu",3562 Dir.Size, cbExpectV 5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);3571 "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu", 3572 Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1); 3563 3573 } 3564 3574 … … 3576 3586 return rc; 3577 3587 if ( fNewerStructureHack 3578 && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5)) 3588 && Dir.Size > cbMaxKnown 3589 && !ASMMemIsZero(&u.abZeros[cbMaxKnown], Dir.Size - cbMaxKnown)) 3579 3590 { 3580 3591 Log(("rtldrPEOpen: %s: load cfg dir: Unexpected bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n", 3581 pszLogName, Dir.Size, Dir.Size - cb ExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]));3592 pszLogName, Dir.Size, Dir.Size - cbMaxKnown, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown])); 3582 3593 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3583 3594 "Grown load config (%u to %u bytes) includes non-zero bytes: %.*Rhxs", 3584 cb ExpectV5, Dir.Size, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]);3595 cbMaxKnown, Dir.Size, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]); 3585 3596 } 3586 3597 rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64); … … 3597 3608 /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get 3598 3609 updated and stores some old size in the directory. Use the header size. */ 3599 else if ( u.Cfg64.Size == cbExpectV5 3610 else if ( u.Cfg64.Size == cbExpectV7 3611 || u.Cfg64.Size == cbExpectV6 3612 || u.Cfg64.Size == cbExpectV5 3600 3613 || u.Cfg64.Size == cbExpectV4 3601 3614 || u.Cfg64.Size == cbExpectV3 3602 3615 || u.Cfg64.Size == cbExpectV2 3603 3616 || u.Cfg64.Size == cbExpectV1 3604 || (fNewerStructureHack = (u.Cfg64.Size > cb ExpectV5&& u.Cfg64.Size <= sizeof(u))) )3617 || (fNewerStructureHack = (u.Cfg64.Size > cbNewHack && u.Cfg64.Size <= sizeof(u))) ) 3605 3618 { 3606 3619 Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the old linker kludge.\n", … … 3614 3627 return rc; 3615 3628 if ( fNewerStructureHack 3616 && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5)) 3629 && Dir.Size > cbMaxKnown 3630 && !ASMMemIsZero(&u.abZeros[cbMaxKnown], Dir.Size - cbMaxKnown)) 3617 3631 { 3618 3632 Log(("rtldrPEOpen: %s: load cfg dir: Unknown bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n", 3619 pszLogName, Dir.Size, Dir.Size - cb ExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]));3633 pszLogName, Dir.Size, Dir.Size - cbMaxKnown, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown])); 3620 3634 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3621 3635 "Grown load config (%u to %u bytes, dir %u) includes non-zero bytes: %.*Rhxs", 3622 cb ExpectV5, Dir.Size, uOrgDir, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]);3636 cbMaxKnown, Dir.Size, uOrgDir, Dir.Size - cbMaxKnown, &u.abZeros[cbMaxKnown]); 3623 3637 } 3624 3638 rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64); … … 3629 3643 else 3630 3644 { 3631 Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, or %zu.\n",3632 pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV 5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));3645 Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n", 3646 pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1)); 3633 3647 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, 3634 "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, or %zu",3635 u.Cfg64.Size, Dir.Size, cbExpectV 5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);3648 "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu", 3649 u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1); 3636 3650 } 3637 3651 } … … 3663 3677 * structure without messing up its natural alignment. */ 3664 3678 if ( ( u.Cfg64.GuardCFCCheckFunctionPointer 3665 || u.Cfg64. Reserved23679 || u.Cfg64.GuardCFDispatchFunctionPointer 3666 3680 || u.Cfg64.GuardCFFunctionTable 3667 3681 || u.Cfg64.GuardCFFunctionCount … … 3674 3688 { 3675 3689 Log(("rtldrPEOpen: %s: load cfg dir: Guard stuff: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!\n", 3676 pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64. Reserved2,3690 pszLogName, u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.GuardCFDispatchFunctionPointer, 3677 3691 u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, 3678 3692 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount, … … 3680 3694 return RTErrInfoSetF(pErrInfo, VERR_LDRPE_GUARD_CF_STUFF, 3681 3695 "Guard bits in load config: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!", 3682 u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64. Reserved2,3696 u.Cfg64.GuardCFCCheckFunctionPointer, u.Cfg64.GuardCFDispatchFunctionPointer, 3683 3697 u.Cfg64.GuardCFFunctionTable, u.Cfg64.GuardCFFunctionCount, u.Cfg64.GuardFlags, 3684 3698 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount,
Note:
See TracChangeset
for help on using the changeset viewer.