VirtualBox

Changeset 60699 in vbox


Ignore:
Timestamp:
Apr 25, 2016 10:19:52 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106872
Message:

ldrPE.cpp: Implemented a more relaxed approach to the ever changing LOAD_IMAGE_CONFIG_DIRECTORY structure: Accept a bunch more bytes provided they are all zero.

File:
1 edited

Legend:

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

    r60467 r60699  
    34993499    {
    35003500        IMAGE_LOAD_CONFIG_DIRECTORY64   Cfg64;
     3501        uint8_t                         abZeros[sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V5) * 4];
    35013502    } u;
    35023503
     
    35253526                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/;
    35263527
     3528        bool fNewerStructureHack = false;
    35273529        if (   Dir.Size != cbExpectV5
    35283530            && Dir.Size != cbExpectV4
     
    35313533            && Dir.Size != cbExpectV1)
    35323534        {
    3533             Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.\n",
    3534                  pszLogName, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
    3535             return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3536                                  "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu",
    3537                                  Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     3535            fNewerStructureHack = Dir.Size > cbExpectV5  /* These structure changes are slowly getting to us! More futher down. */
     3536                               && Dir.Size <= sizeof(u);
     3537            Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, or %zu.%s\n",
     3538                 pszLogName, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
     3539                 fNewerStructureHack ? " Will try ignore extra bytes if all zero." : ""));
     3540            if (!fNewerStructureHack)
     3541                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
     3542                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, or %zu",
     3543                                     Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    35383544        }
    35393545
    35403546        /*
    3541          * Read and convert to 64-bit.
     3547         * Read, check new stuff and convert to 64-bit.
     3548         *
     3549         * If we accepted a newer structure, we check whether the new bits are
     3550         * all zero.  This PRAYING/ASSUMING that the nothing new weird stuff is
     3551         * activated by a zero value and that it'll mostly be unused in areas
     3552         * we care about (which has been the case till now).
    35423553         */
    35433554        RT_ZERO(u.Cfg64);
     
    35453556        if (RT_FAILURE(rc))
    35463557            return rc;
     3558        if (   fNewerStructureHack
     3559            && !ASMMemIsZero(&u.abZeros[cbExpectV5], Dir.Size - cbExpectV5))
     3560        {
     3561            Log(("rtldrPEOpen: %s: load cfg dir: Unexpected bytes are non-zero (%u bytes of which %u expected to be zero): %.*Rhxs\n",
     3562                 pszLogName, Dir.Size, Dir.Size - cbExpectV5, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]));
     3563            return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
     3564                                 "Grown load config (%u to %u bytes) includes non-zero bytes: %.*Rhxs",
     3565                                 cbExpectV5, Dir.Size, Dir.Size - cbExpectV5, &u.abZeros[cbExpectV5]);
     3566        }
    35473567        rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64);
    35483568
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