VirtualBox

Changeset 60467 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Apr 13, 2016 8:03:40 AM (9 years ago)
Author:
vboxsync
Message:

ldrPE: Generalized the load config dir size vs header size kludges.

File:
1 edited

Legend:

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

    r60298 r60467  
    35493549        if (u.Cfg64.Size != Dir.Size)
    35503550        {
    3551             /* Kludge #1, seen ati shipping 32-bit DLLs and EXEs with Dir.Size=0x40
    3552                and Cfg64.Size=0x5c or 0x48.  Windows seems to deal with it, so
    3553                lets do so as well. */
    3554             if (   Dir.Size < u.Cfg64.Size
    3555                 && (   u.Cfg64.Size == cbExpectV3
    3556                     || u.Cfg64.Size == cbExpectV2) )
    3557             {
    3558                 Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the ATI kludge\n",
     3551            /* Kludge #1: ntdll.dll from XP seen with Dir.Size=0x40 and Cfg64.Size=0x00. */
     3552            if (Dir.Size == 0x40 && u.Cfg64.Size == 0x00 && !pModPe->f64Bit)
     3553            {
     3554                Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the XP kludge.\n",
     3555                     pszLogName, u.Cfg64.Size, Dir.Size));
     3556                u.Cfg64.Size = Dir.Size;
     3557            }
     3558            /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get
     3559               it updated and stores some old size in the directory.  Use the header size. */
     3560            else if (   u.Cfg64.Size == cbExpectV5
     3561                     || u.Cfg64.Size == cbExpectV4
     3562                     || u.Cfg64.Size == cbExpectV3
     3563                     || u.Cfg64.Size == cbExpectV2
     3564                     || u.Cfg64.Size == cbExpectV1)
     3565            {
     3566                Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the old linker kludge.\n",
    35593567                     pszLogName, u.Cfg64.Size, Dir.Size));
    35603568                Dir.Size = u.Cfg64.Size;
     
    35643572                    return rc;
    35653573                rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64);
    3566             }
    3567 
    3568             /* Kludge #2, ntdll.dll from XP seen with Dir.Size=0x40 and Cfg64.Size=0x00. */
    3569             if (Dir.Size == 0x40 && u.Cfg64.Size == 0x00 && !pModPe->f64Bit)
    3570             {
    3571                 Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the XP kludge\n",
    3572                      pszLogName, u.Cfg64.Size, Dir.Size));
    3573                 u.Cfg64.Size = 0x40;
    3574             }
    3575 
    3576             /* Kludge #3, imagehlp.dll from W10/32 seen with Dir.Size=0x40 (V1) and Cfg64.Size=0x68 (V3). */
    3577             if (Dir.Size == 0x40 && u.Cfg64.Size == 0x68 && !pModPe->f64Bit)
    3578             {
    3579                 Log(("rtldrPEOpen: %s: load cfg dir: Header (%d) and directory (%d) size mismatch, applying the W10/32 kludge\n",
    3580                      pszLogName, u.Cfg64.Size, Dir.Size));
    3581                 Dir.Size = u.Cfg64.Size;
    3582                 RT_ZERO(u.Cfg64);
    3583                 rc = rtldrPEReadRVA(pModPe, &u.Cfg64, Dir.Size, Dir.VirtualAddress);
    3584                 if (RT_FAILURE(rc))
    3585                     return rc;
    3586                 rtldrPEConvert32BitLoadConfigTo64Bit(&u.Cfg64);
    3587             }
    3588 
    3589             if (u.Cfg64.Size != Dir.Size)
    3590             {
    3591                 Log(("rtldrPEOpen: %s: load cfg dir: unexpected header size of %d bytes, expected %d.\n",
    3592                      pszLogName, u.Cfg64.Size, Dir.Size));
     3574                AssertReturn(u.Cfg64.Size == Dir.Size,
     3575                             RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE, "Data changed while reading! (%d vs %d)\n",
     3576                                           u.Cfg64.Size, Dir.Size));
     3577            }
     3578            else
     3579            {
     3580                Log(("rtldrPEOpen: %s: load cfg hdr: unexpected hdr size of %u bytes (dir %u), expected %zu, %zu, %zu, %zu, or %zu.\n",
     3581                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
    35933582                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3594                                      "Load config header vs directory size mismatch: %#x vs %#x", u.Cfg64.Size, Dir.Size);
     3583                                     "Unexpected load config dir size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, or %zu",
     3584                                     u.Cfg64.Size, Dir.Size, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    35953585            }
    35963586        }
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