VirtualBox

Changeset 67948 in vbox


Ignore:
Timestamp:
Jul 13, 2017 10:00:40 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116941
Message:

pecoff,ldrPE: Another load config change surfaced in build 16237, 64-bit bcrypt*.dll uses it while 32-bit doesn't. Sigh.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/formats/pecoff.h

    r66484 r67948  
    922922typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
    923923
    924 typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8   IMAGE_LOAD_CONFIG_DIRECTORY32;
    925 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V8  PIMAGE_LOAD_CONFIG_DIRECTORY32;
    926 typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
     924/** @since  Windows 10 build 16237 (or maybe earlier). */
     925typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V9
     926{
     927    uint32_t  Size;                                 /**< 0x00 */
     928    uint32_t  TimeDateStamp;                        /**< 0x04 */
     929    uint16_t  MajorVersion;                         /**< 0x08 */
     930    uint16_t  MinorVersion;                         /**< 0x0a */
     931    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
     932    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
     933    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
     934    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
     935    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
     936    uint32_t  LockPrefixTable;                      /**< 0x20 */
     937    uint32_t  MaximumAllocationSize;                /**< 0x24 */
     938    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
     939    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
     940    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
     941    uint16_t  CSDVersion;                           /**< 0x34 */
     942    uint16_t  DependentLoadFlags;                   /**< 0x36 */
     943    uint32_t  EditList;                             /**< 0x38 */
     944    uint32_t  SecurityCookie;                       /**< 0x3c */
     945    uint32_t  SEHandlerTable;                       /**< 0x40 */
     946    uint32_t  SEHandlerCount;                       /**< 0x44 */
     947    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
     948    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
     949    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
     950    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
     951    uint32_t  GuardFlags;                           /**< 0x58 */
     952    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
     953    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
     954    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
     955    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
     956    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
     957    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
     958    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
     959    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
     960    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
     961    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
     962    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
     963    uint16_t  Reserved2;                            /**< 0x8e */
     964    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
     965    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
     966    uint32_t  AddressOfSomeUnicodeString;           /**< 0x98 - 64-bit version has this member about here. not sure about location yet. */
     967    uint32_t  Reserved3QuestionMark;                /**< 0x9a - Did they 8-byte pad the structure or is AddressOfSomeUnicodeString 64-bit? */
     968} IMAGE_LOAD_CONFIG_DIRECTORY32_V9;
     969AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V9, 0xa0);
     970typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V9;
     971typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V9;
     972
     973typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9   IMAGE_LOAD_CONFIG_DIRECTORY32;
     974typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V9  PIMAGE_LOAD_CONFIG_DIRECTORY32;
     975typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V9 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
    927976
    928977
     
    11961245typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
    11971246
    1198 typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8   IMAGE_LOAD_CONFIG_DIRECTORY64;
    1199 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V8  PIMAGE_LOAD_CONFIG_DIRECTORY64;
    1200 typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
     1247/** @since  Windows 10 build 15002 (or maybe earlier). */
     1248typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V9
     1249{
     1250    uint32_t  Size;                                 /**< 0x00 */
     1251    uint32_t  TimeDateStamp;                        /**< 0x04 */
     1252    uint16_t  MajorVersion;                         /**< 0x08 */
     1253    uint16_t  MinorVersion;                         /**< 0x0a */
     1254    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
     1255    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
     1256    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
     1257    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
     1258    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
     1259    uint64_t  LockPrefixTable;                      /**< 0x28 */
     1260    uint64_t  MaximumAllocationSize;                /**< 0x30 */
     1261    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
     1262    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
     1263    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
     1264    uint16_t  CSDVersion;                           /**< 0x4c */
     1265    uint16_t  DependentLoadFlags;                   /**< 0x4e */
     1266    uint64_t  EditList;                             /**< 0x50 */
     1267    uint64_t  SecurityCookie;                       /**< 0x58 */
     1268    uint64_t  SEHandlerTable;                       /**< 0x60 */
     1269    uint64_t  SEHandlerCount;                       /**< 0x68 */
     1270    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
     1271    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
     1272    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
     1273    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
     1274    uint32_t  GuardFlags;                           /**< 0x90 */
     1275    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
     1276    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
     1277    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
     1278    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
     1279    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
     1280    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
     1281    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
     1282    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
     1283    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
     1284    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
     1285    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
     1286    uint16_t  Reserved2;                            /**< 0xe6 */
     1287    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
     1288    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
     1289    uint32_t  Reserved3;                            /**< 0xf4 */
     1290    uint64_t  AddressOfSomeUnicodeString;           /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
     1291} IMAGE_LOAD_CONFIG_DIRECTORY64_V9;
     1292AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V9, 0x100);
     1293typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V9;
     1294typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V9;
     1295
     1296typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9   IMAGE_LOAD_CONFIG_DIRECTORY64;
     1297typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V9  PIMAGE_LOAD_CONFIG_DIRECTORY64;
     1298typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V9 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
    12011299
    12021300/** @} */
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r66367 r67948  
    30393039     * volatile everywhere! Trying to prevent the compiler being a smarta$$ and reorder stuff.
    30403040     */
    3041     IMAGE_LOAD_CONFIG_DIRECTORY32_V8 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V8 volatile *)pLoadCfg;
    3042     IMAGE_LOAD_CONFIG_DIRECTORY64_V8 volatile *pLoadCfg64 = pLoadCfg;
    3043 
     3041    IMAGE_LOAD_CONFIG_DIRECTORY32_V9 volatile *pLoadCfg32 = (IMAGE_LOAD_CONFIG_DIRECTORY32_V9 volatile *)pLoadCfg;
     3042    IMAGE_LOAD_CONFIG_DIRECTORY64_V9 volatile *pLoadCfg64 = pLoadCfg;
     3043
     3044    pLoadCfg64->AddressOfSomeUnicodeString      = pLoadCfg32->AddressOfSomeUnicodeString;
    30443045    pLoadCfg64->HotPatchTableOffset             = pLoadCfg32->HotPatchTableOffset;
    30453046    pLoadCfg64->GuardRFVerifyStackPointerFunctionPointer = pLoadCfg32->GuardRFVerifyStackPointerFunctionPointer;
     
    36053606    if (Dir.Size)
    36063607    {
     3608        const size_t cbExpectV9 = !pModPe->f64Bit
     3609                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V9)
     3610                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V9);
    36073611        const size_t cbExpectV8 = !pModPe->f64Bit
    36083612                                ? sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_V8)
     
    36303634                                : sizeof(IMAGE_LOAD_CONFIG_DIRECTORY64_V2) /*No V1*/;
    36313635        const size_t cbNewHack  = cbExpectV5; /* Playing safe here since there might've been revisions between V5 and V6 we don't know about . */
    3632         const size_t cbMaxKnown = cbExpectV8;
     3636        const size_t cbMaxKnown = cbExpectV9;
    36333637
    36343638        bool fNewerStructureHack = false;
    3635         if (   Dir.Size != cbExpectV8
     3639        if (   Dir.Size != cbExpectV9
     3640            && Dir.Size != cbExpectV8
    36363641            && Dir.Size != cbExpectV7
    36373642            && Dir.Size != cbExpectV6
     
    36443649            fNewerStructureHack = Dir.Size > cbNewHack /* These structure changes are slowly getting to us! More futher down. */
    36453650                               && Dir.Size <= sizeof(u);
    3646             Log(("rtldrPEOpen: %s: load cfg dir: unexpected dir size of %u bytes, expected %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu.%s\n",
    3647                  pszLogName, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
     3651            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",
     3652                 pszLogName, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1,
    36483653                 fNewerStructureHack ? " Will try ignore extra bytes if all zero." : ""));
    36493654            if (!fNewerStructureHack)
    36503655                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3651                                      "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    3652                                      Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     3656                                     "Unexpected load config dir size of %u bytes; supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     3657                                     Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    36533658        }
    36543659
     
    36883693            /* Kludge #2: This happens a lot. Structure changes, but the linker doesn't get
    36893694               updated and stores some old size in the directory.  Use the header size. */
    3690             else if (   u.Cfg64.Size == cbExpectV8
     3695            else if (   u.Cfg64.Size == cbExpectV9
     3696                     || u.Cfg64.Size == cbExpectV8
    36913697                     || u.Cfg64.Size == cbExpectV7
    36923698                     || u.Cfg64.Size == cbExpectV6
     
    37243730            else
    37253731            {
    3726                 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",
    3727                      pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
     3732                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",
     3733                     pszLogName, u.Cfg64.Size, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1));
    37283734                return RTErrInfoSetF(pErrInfo, VERR_LDRPE_LOAD_CONFIG_SIZE,
    3729                                      "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
    3730                                      u.Cfg64.Size, Dir.Size, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
     3735                                     "Unexpected load config header size of %u bytes (dir %u); supported sized: %zu, %zu, %zu, %zu, %zu, %zu, %zu, %zu, or %zu",
     3736                                     u.Cfg64.Size, Dir.Size, cbExpectV9, cbExpectV8, cbExpectV7, cbExpectV6, cbExpectV5, cbExpectV4, cbExpectV3, cbExpectV2, cbExpectV1);
    37313737            }
    37323738        }
Note: See TracChangeset for help on using the changeset viewer.

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