VirtualBox

Changeset 84361 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 19, 2020 9:47:34 AM (5 years ago)
Author:
vboxsync
Message:

IPRT/ldrPE: Found three new load config variations. V12 is what the Visual C++ 2019 linker produces and it upset the import validation helper we use for GAs. As usual the offical docs & headers are behind and much of the struct is still undocumented. bugref:8489

File:
1 edited

Legend:

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

    r82968 r84361  
    35863586     * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff.
    35873587     */
    3588     IMAGE_LOAD_CONFIG_DIRECTORY32_V9 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V9 volatile *)pLoadCfg;
    3589     IMAGE_LOAD_CONFIG_DIRECTORY64_V9 volatile *pLoadCfg64 = pLoadCfg;
    3590 
    3591     pLoadCfg64->AddressOfSomeUnicodeString      = pLoadCfg32->AddressOfSomeUnicodeString;
     3588    IMAGE_LOAD_CONFIG_DIRECTORY32_V12 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V12 volatile *)pLoadCfg;
     3589    IMAGE_LOAD_CONFIG_DIRECTORY64_V12 volatile *pLoadCfg64 = pLoadCfg;
     3590
     3591    pLoadCfg64->GuardXFGTableDispatchFunctionPointer = pLoadCfg32->GuardXFGTableDispatchFunctionPointer;
     3592    pLoadCfg64->GuardXFGDispatchFunctionPointer = pLoadCfg32->GuardXFGDispatchFunctionPointer;
     3593    pLoadCfg64->GuardXFGCheckFunctionPointer    = pLoadCfg32->GuardXFGCheckFunctionPointer;
     3594    pLoadCfg64->GuardEHContinuationCount        = pLoadCfg32->GuardEHContinuationCount;
     3595    pLoadCfg64->GuardEHContinuationTable        = pLoadCfg32->GuardEHContinuationTable;
     3596    pLoadCfg64->VolatileMetadataPointer         = pLoadCfg32->VolatileMetadataPointer;
     3597    pLoadCfg64->EnclaveConfigurationPointer     = pLoadCfg32->EnclaveConfigurationPointer;
     3598    pLoadCfg64->Reserved3                       = pLoadCfg32->Reserved3;
    35923599    pLoadCfg64->HotPatchTableOffset             = pLoadCfg32->HotPatchTableOffset;
    35933600    pLoadCfg64->GuardRFVerifyStackPointerFunctionPointer = pLoadCfg32->GuardRFVerifyStackPointerFunctionPointer;
     
    42094216    if (Dir.Size)
    42104217    {
     4218        const size_t cbExpectV12 = !pModPe->f64Bit
     4219                                 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V12)
     4220                                 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V12);
     4221        const size_t cbExpectV11 = !pModPe->f64Bit
     4222                                 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V11)
     4223                                 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V11);
     4224        const size_t cbExpectV10 = !pModPe->f64Bit
     4225                                 ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V10)
     4226                                 : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V10);
    42114227        const size_t cbExpectV9 = !pModPe->f64Bit
    42124228                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V9)
     
    42374253                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/;
    42384254        const size_t cbNewHack  = cbExpectV5; /* Playing safe here since there might've been revisions between V5 and V6 we don't know about . */
    4239         const size_t cbMaxKnown = cbExpectV9;
     4255        const size_t cbMaxKnown = cbExpectV12;
    42404256
    42414257        bool fNewerStructureHack = false;
    4242         if (   Dir.Size != cbExpectV9
     4258        if (   Dir.Size != cbExpectV12
     4259            && Dir.Size != cbExpectV11
     4260            && Dir.Size != cbExpectV10
     4261            && Dir.Size != cbExpectV9
    42434262            && Dir.Size != cbExpectV8
    42444263            && Dir.Size != cbExpectV7
     
    42524271            fNewerStructureHack = Dir.Size > cbNewHack /* These structure changes are slowly getting to us! More futher down. */
    42534272                               && Dir.Size <= sizeof(u);
    4254             Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
    4255                  pszLogName, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
     4273            Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
     4274                 pszLogName, Dir.Size, cbExpectV12, cbExpectV11, cbExpectV10, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
    42564275                 fNewerStructureHack ? " Will try ignore extra bytes if all zero." : ""));
    42574276            if (!fNewerStructureHack)
    42584277                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    4259                                      "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    4260                                      Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     4278                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     4279                                     Dir.Size, cbExpectV12, cbExpectV11, cbExpectV10, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    42614280        }
    42624281
     
    42974316            /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get
    42984317               updated and stores some old size in the directory.  Use the header size. */
    4299             else if (   u.Cfg64.Size == cbExpectV9
     4318            else if (   u.Cfg64.Size == cbExpectV12
     4319                     || u.Cfg64.Size == cbExpectV11
     4320                     || u.Cfg64.Size == cbExpectV10
     4321                     || u.Cfg64.Size == cbExpectV9
    43004322                     || u.Cfg64.Size == cbExpectV8
    43014323                     || u.Cfg64.Size == cbExpectV7
     
    43354357            else
    43364358            {
    4337                 Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n",
    4338                      pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
     4359                Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.\n",
     4360                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV12, cbExpectV11, cbExpectV10, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
    43394361                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    4340                                      "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    4341                                      u.Cfg64.Size, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     4362                                     "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     4363                                     u.Cfg64.Size, Dir.Size, cbExpectV12, cbExpectV11, cbExpectV10, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    43424364            }
    43434365        }
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