VirtualBox

Changeset 65240 in vbox


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.

Location:
trunk
Files:
2 edited

Legend:

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

    r64204 r65240  
    790790    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    791791    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    792     uint32_t  HybridMetadataPointer;                /**< 0x7c */
    793     uint32_t  FailFastIndirectProc;                 /**< 0x80 - temporary name, rename when we get symbols */
    794     uint32_t  FailFastPointer;                      /**< 0x84 - temporary name, rename when we get symbols */
    795     uint32_t  UnknownZero1;                         /**< 0x88 - temporary name, rename when we get symbols */
     792    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
     793    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
     794    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
     795    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
     796    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
     797    uint16_t  Reserved2;                            /**< 0x8e */
    796798} IMAGE_LOAD_CONFIG_DIRECTORY32_V7;
    797 AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V7, 0x8c);
     799AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V7, 0x90);
    798800typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
    799801typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
    800802
    801 typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7   IMAGE_LOAD_CONFIG_DIRECTORY32;
    802 typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V7  PIMAGE_LOAD_CONFIG_DIRECTORY32;
    803 typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
     803/** @since  Windows 10 build 15002 (or maybe earlier). */
     804typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V8
     805{
     806    uint32_t  Size;                                 /**< 0x00 */
     807    uint32_t  TimeDateStamp;                        /**< 0x04 */
     808    uint16_t  MajorVersion;                         /**< 0x08 */
     809    uint16_t  MinorVersion;                         /**< 0x0a */
     810    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
     811    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
     812    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
     813    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
     814    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
     815    uint32_t  LockPrefixTable;                      /**< 0x20 */
     816    uint32_t  MaximumAllocationSize;                /**< 0x24 */
     817    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
     818    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
     819    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
     820    uint16_t  CSDVersion;                           /**< 0x34 */
     821    uint16_t  DependentLoadFlags;                   /**< 0x36 */
     822    uint32_t  EditList;                             /**< 0x38 */
     823    uint32_t  SecurityCookie;                       /**< 0x3c */
     824    uint32_t  SEHandlerTable;                       /**< 0x40 */
     825    uint32_t  SEHandlerCount;                       /**< 0x44 */
     826    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
     827    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
     828    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
     829    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
     830    uint32_t  GuardFlags;                           /**< 0x58 */
     831    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
     832    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
     833    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
     834    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
     835    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
     836    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
     837    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
     838    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
     839    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
     840    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
     841    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
     842    uint16_t  Reserved2;                            /**< 0x8e */
     843    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
     844    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
     845} IMAGE_LOAD_CONFIG_DIRECTORY32_V8;
     846AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V8, 0x98);
     847typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
     848typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
     849
     850typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8   IMAGE_LOAD_CONFIG_DIRECTORY32;
     851typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V8  PIMAGE_LOAD_CONFIG_DIRECTORY32;
     852typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
    804853
    805854
     
    10131062    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    10141063    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    1015     uint64_t  HybridMetadataPointer;                /**< 0xc8 */
    1016     uint64_t  FailFastIndirectProc;                 /**< 0xd0 - temporary name, rename when we get symbols */
    1017     uint64_t  FailFastPointer;                      /**< 0xd8 - temporary name, rename when we get symbols */
    1018     uint64_t  UnknownZero1;                         /**< 0xe0 - temporary name, rename when we get symbols */
     1064    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 Not sure when this was renamed from HybridMetadataPointer. */
     1065    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
     1066    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
     1067    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
     1068    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
     1069    uint16_t  Reserved2;                            /**< 0xe6 */
    10191070} IMAGE_LOAD_CONFIG_DIRECTORY64_V7;
    10201071AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V7, 0xe8);
     
    10221073typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
    10231074
    1024 typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7   IMAGE_LOAD_CONFIG_DIRECTORY64;
    1025 typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V7  PIMAGE_LOAD_CONFIG_DIRECTORY64;
    1026 typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
     1075/** @since  Windows 10 build 15002 (or maybe earlier). */
     1076#pragma pack(4) /* Stupid, stupid microsofties! */
     1077typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V8
     1078{
     1079    uint32_t  Size;                                 /**< 0x00 */
     1080    uint32_t  TimeDateStamp;                        /**< 0x04 */
     1081    uint16_t  MajorVersion;                         /**< 0x08 */
     1082    uint16_t  MinorVersion;                         /**< 0x0a */
     1083    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
     1084    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
     1085    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
     1086    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
     1087    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
     1088    uint64_t  LockPrefixTable;                      /**< 0x28 */
     1089    uint64_t  MaximumAllocationSize;                /**< 0x30 */
     1090    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
     1091    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
     1092    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
     1093    uint16_t  CSDVersion;                           /**< 0x4c */
     1094    uint16_t  DependentLoadFlags;                   /**< 0x4e */
     1095    uint64_t  EditList;                             /**< 0x50 */
     1096    uint64_t  SecurityCookie;                       /**< 0x58 */
     1097    uint64_t  SEHandlerTable;                       /**< 0x60 */
     1098    uint64_t  SEHandlerCount;                       /**< 0x68 */
     1099    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
     1100    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
     1101    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
     1102    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
     1103    uint32_t  GuardFlags;                           /**< 0x90 */
     1104    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
     1105    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
     1106    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
     1107    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
     1108    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
     1109    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
     1110    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
     1111    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
     1112    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
     1113    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
     1114    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
     1115    uint16_t  Reserved2;                            /**< 0xe6 */
     1116    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
     1117    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
     1118} IMAGE_LOAD_CONFIG_DIRECTORY64_V8;
     1119#pragma pack()
     1120AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V8, 0xf4);
     1121typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
     1122typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
     1123
     1124typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8   IMAGE_LOAD_CONFIG_DIRECTORY64;
     1125typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V8  PIMAGE_LOAD_CONFIG_DIRECTORY64;
     1126typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
    10271127
    10281128/** @} */
  • 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