VirtualBox

Changeset 65240 in vbox for trunk/src


Ignore:
Timestamp:
Jan 11, 2017 10:39:51 AM (8 years ago)
Author:
vboxsync
Message:

pecoff.h,ldrPE.cpp: New IMAGE_LOAD_CONFIG_DIRECTORY structure in 15002, guard fields are used now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r64891 r65240  
    29792979     * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff.
    29802980     */
    2981     IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V7 volatile *)pLoadCfg;
    2982     IMAGE_LOAD_CONFIG_DIRECTORY64_V7 volatile *pLoadCfg64 = pLoadCfg;
    2983 
     2981    IMAGE_LOAD_CONFIG_DIRECTORY32_V8 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V8 volatile *)pLoadCfg;
     2982    IMAGE_LOAD_CONFIG_DIRECTORY64_V8 volatile *pLoadCfg64 = pLoadCfg;
     2983
     2984    pLoadCfg64->HotPatchTableOffset             = pLoadCfg32->HotPatchTableOffset;
     2985    pLoadCfg64->GuardRFVerifyStackPointerFunctionPointer = pLoadCfg32->GuardRFVerifyStackPointerFunctionPointer;
     2986    pLoadCfg64->Reserved2                       = pLoadCfg32->Reserved2;
     2987    pLoadCfg64->DynamicValueRelocTableSection   = pLoadCfg32->DynamicValueRelocTableSection;
     2988    pLoadCfg64->DynamicValueRelocTableOffset    = pLoadCfg32->DynamicValueRelocTableOffset;
     2989    pLoadCfg64->GuardRFFailureRoutineFunctionPointer = pLoadCfg32->GuardRFFailureRoutineFunctionPointer;
     2990    pLoadCfg64->GuardRFFailureRoutine           = pLoadCfg32->GuardRFFailureRoutine;
     2991    pLoadCfg64->CHPEMetadataPointer             = pLoadCfg32->CHPEMetadataPointer;
     2992    pLoadCfg64->DynamicValueRelocTable          = pLoadCfg32->DynamicValueRelocTable;
     2993    pLoadCfg64->GuardLongJumpTargetCount        = pLoadCfg32->GuardLongJumpTargetCount;
     2994    pLoadCfg64->GuardLongJumpTargetTable        = pLoadCfg32->GuardLongJumpTargetTable;
     2995    pLoadCfg64->GuardAddressTakenIatEntryCount  = pLoadCfg32->GuardAddressTakenIatEntryCount;
    29842996    pLoadCfg64->GuardAddressTakenIatEntryTable  = pLoadCfg32->GuardAddressTakenIatEntryTable;
    2985     pLoadCfg64->GuardAddressTakenIatEntryCount  = pLoadCfg32->GuardAddressTakenIatEntryCount;
    2986     pLoadCfg64->GuardLongJumpTargetTable        = pLoadCfg32->GuardLongJumpTargetTable;
    2987     pLoadCfg64->GuardLongJumpTargetCount        = pLoadCfg32->GuardLongJumpTargetCount;
    29882997    pLoadCfg64->CodeIntegrity.Reserved          = pLoadCfg32->CodeIntegrity.Reserved;
    29892998    pLoadCfg64->CodeIntegrity.CatalogOffset     = pLoadCfg32->CodeIntegrity.CatalogOffset;
     
    35363545    if (Dir.Size)
    35373546    {
     3547        const size_t cbExpectV8 = !pModPe->f64Bit
     3548                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V8)
     3549                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V8);
    35383550        const size_t cbExpectV7 = !pModPe->f64Bit
    35393551                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V7)
     
    35583570                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/;
    35593571        const size_t cbNewHack  = cbExpectV5; /* Playing safe here since there might've been revisions between V5 and V6 we don't know about . */
    3560         const size_t cbMaxKnown = cbExpectV7;
     3572        const size_t cbMaxKnown = cbExpectV8;
    35613573
    35623574        bool fNewerStructureHack = false;
    3563         if (   Dir.Size != cbExpectV7
     3575        if (   Dir.Size != cbExpectV8
     3576            && Dir.Size != cbExpectV7
    35643577            && Dir.Size != cbExpectV6
    35653578            && Dir.Size != cbExpectV5
     
    35713584            fNewerStructureHack = Dir.Size > cbNewHack /* These structure changes are slowly getting to us! More futher down. */
    35723585                               && Dir.Size <= sizeof(u);
    3573             Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
    3574                  pszLogName, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
     3586            Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
     3587                 pszLogName, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
    35753588                 fNewerStructureHack ? " Will try ignore extra bytes if all zero." : ""));
    35763589            if (!fNewerStructureHack)
    35773590                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3578                                      "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    3579                                      Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     3591                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     3592                                     Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    35803593        }
    35813594
     
    36153628            /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get
    36163629               updated and stores some old size in the directory.  Use the header size. */
    3617             else if (   u.Cfg64.Size == cbExpectV7
     3630            else if (   u.Cfg64.Size == cbExpectV8
     3631                     || u.Cfg64.Size == cbExpectV7
    36183632                     || u.Cfg64.Size == cbExpectV6
    36193633                     || u.Cfg64.Size == cbExpectV5
     
    36503664            else
    36513665            {
    3652                 Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n",
    3653                      pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
     3666                Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n",
     3667                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
    36543668                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3655                                      "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    3656                                      u.Cfg64.Size, Dir.Size, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     3669                                     "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     3670                                     u.Cfg64.Size, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    36573671            }
    36583672        }
     
    36993713                 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount,
    37003714                 u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount ));
     3715#if 0 /* ntdll 15002 uses this. */
    37013716            return RTErrInfoSetF(pErrInfo, VERR_LDRPE_GUARD_CF_STUFF,
    37023717                                 "Guard bits in load config: %RX64,%RX64,%RX64,%RX64,%RX32,%RX64,%RX64,%RX64,%RX64!",
     
    37053720                                 u.Cfg64.GuardAddressTakenIatEntryTable, u.Cfg64.GuardAddressTakenIatEntryCount,
    37063721                                 u.Cfg64.GuardLongJumpTargetTable, u.Cfg64.GuardLongJumpTargetCount);
     3722#endif
    37073723        }
    37083724    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette