VirtualBox

source: vbox/trunk/include/iprt/formats/pecoff.h@ 81369

Last change on this file since 81369 was 81369, checked in by vboxsync, 5 years ago

*: doxygen fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 93.0 KB
Line 
1/* $Id: pecoff.h 81369 2019-10-18 21:13:03Z vboxsync $ */
2/** @file
3 * IPRT - Windows NT PE & COFF Structures and Constants.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_formats_pecoff_h
28#define IPRT_INCLUDED_formats_pecoff_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34#include <iprt/assertcompile.h>
35
36
37/** @defgroup grp_rt_formats_pecoff PE & Microsoft COFF structures and definitions
38 * @ingroup grp_rt_formats
39 * @{
40 */
41
42
43/**
44 * PE & COFF file header.
45 *
46 * This starts COFF files, while in PE files it's preceeded by the PE signature
47 * (see IMAGE_NT_HEADERS32, IMAGE_NT_HEADERS64).
48 */
49typedef struct _IMAGE_FILE_HEADER
50{
51 uint16_t Machine; /**< 0x00 */
52 uint16_t NumberOfSections; /**< 0x02 */
53 uint32_t TimeDateStamp; /**< 0x04 */
54 uint32_t PointerToSymbolTable; /**< 0x08 */
55 uint32_t NumberOfSymbols; /**< 0x0c */
56 uint16_t SizeOfOptionalHeader; /**< 0x10 */
57 uint16_t Characteristics; /**< 0x12 */
58} IMAGE_FILE_HEADER; /* size: 0x14 */
59AssertCompileSize(IMAGE_FILE_HEADER, 0x14);
60typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
61typedef IMAGE_FILE_HEADER const *PCIMAGE_FILE_HEADER;
62
63
64/** @name PE & COFF machine types.
65 * Used by IMAGE_FILE_HEADER::Machine and IMAGE_SEPARATE_DEBUG_HEADER::Machine.
66 * @{ */
67/** X86 compatible CPU, 32-bit instructions. */
68#define IMAGE_FILE_MACHINE_I386 UINT16_C(0x014c)
69/** AMD64 compatible CPU, 64-bit instructions. */
70#define IMAGE_FILE_MACHINE_AMD64 UINT16_C(0x8664)
71
72/** Unknown target CPU. */
73#define IMAGE_FILE_MACHINE_UNKNOWN UINT16_C(0x0000)
74/** Basic-16 (whatever that is). */
75#define IMAGE_FILE_MACHINE_BASIC_16 UINT16_C(0x0142)
76/** Basic-16 (whatever that is) w/ transfer vector(s?) (TV). */
77#define IMAGE_FILE_MACHINE_BASIC_16_TV UINT16_C(0x0143)
78/** Intel iAPX 16 (8086?). */
79#define IMAGE_FILE_MACHINE_IAPX16 UINT16_C(0x0144)
80/** Intel iAPX 16 (8086?) w/ transfer vector(s?) (TV). */
81#define IMAGE_FILE_MACHINE_IAPX16_TV UINT16_C(0x0145)
82/** Intel iAPX 20 (80286?). */
83#define IMAGE_FILE_MACHINE_IAPX20 UINT16_C(0x0144)
84/** Intel iAPX 20 (80286?) w/ transfer vector(s?) (TV). */
85#define IMAGE_FILE_MACHINE_IAPX20_TV UINT16_C(0x0145)
86/** X86 compatible CPU, 8086. */
87#define IMAGE_FILE_MACHINE_I8086 UINT16_C(0x0148)
88/** X86 compatible CPU, 8086 w/ transfer vector(s?) (TV). */
89#define IMAGE_FILE_MACHINE_I8086_TV UINT16_C(0x0149)
90/** X86 compatible CPU, 80286 small model program. */
91#define IMAGE_FILE_MACHINE_I286_SMALL UINT16_C(0x014a)
92/** Motorola 68000. */
93#define IMAGE_FILE_MACHINE_MC68 UINT16_C(0x0150)
94/** Motorola 68000 w/ writable text sections. */
95#define IMAGE_FILE_MACHINE_MC68_WR UINT16_C(0x0150)
96/** Motorola 68000 w/ transfer vector(s?). */
97#define IMAGE_FILE_MACHINE_MC68_TV UINT16_C(0x0151)
98/** Motorola 68000 w/ demand paged text.
99 * @note shared with 80286 large model program. */
100#define IMAGE_FILE_MACHINE_MC68_PG UINT16_C(0x0152)
101/** X86 compatible CPU, 80286 large model program.
102 * @note shared with MC68000 w/ demand paged text */
103#define IMAGE_FILE_MACHINE_I286_LARGE UINT16_C(0x0152)
104/** IBM 370 (writable text). */
105#define IMAGE_FILE_MACHINE_U370_WR UINT16_C(0x0158)
106/** Amdahl 470/580 (writable text). */
107#define IMAGE_FILE_MACHINE_AMDAHL_470_WR UINT16_C(0x0159)
108/** Amdahl 470/580 (read only text). */
109#define IMAGE_FILE_MACHINE_AMDAHL_470_RO UINT16_C(0x015c)
110/** IBM 370 (read only text). */
111#define IMAGE_FILE_MACHINE_U370_RO UINT16_C(0x015d)
112/** MIPS R4000 CPU, little endian. */
113#define IMAGE_FILE_MACHINE_R4000 UINT16_C(0x0166)
114/** MIPS CPU, little endian, Windows CE (?) v2 designation. */
115#define IMAGE_FILE_MACHINE_WCEMIPSV2 UINT16_C(0x0169)
116/** VAX-11/750 and VAX-11/780 (writable text). */
117#define IMAGE_FILE_MACHINE_VAX_WR UINT16_C(0x0178)
118/** VAX-11/750 and VAX-11/780 (read-only text). */
119#define IMAGE_FILE_MACHINE_VAX_RO UINT16_C(0x017d)
120/** Hitachi SH3 CPU. */
121#define IMAGE_FILE_MACHINE_SH3 UINT16_C(0x01a2)
122/** Hitachi SH3 DSP. */
123#define IMAGE_FILE_MACHINE_SH3DSP UINT16_C(0x01a3)
124/** Hitachi SH4 CPU. */
125#define IMAGE_FILE_MACHINE_SH4 UINT16_C(0x01a6)
126/** Hitachi SH5 CPU. */
127#define IMAGE_FILE_MACHINE_SH5 UINT16_C(0x01a8)
128/** Little endian ARM CPU. */
129#define IMAGE_FILE_MACHINE_ARM UINT16_C(0x01c0)
130/** ARM or Thumb stuff. */
131#define IMAGE_FILE_MACHINE_THUMB UINT16_C(0x01c2)
132/** ARMv7 or higher CPU, Thumb mode. */
133#define IMAGE_FILE_MACHINE_ARMNT UINT16_C(0x01c4)
134/** Matshushita AM33 CPU. */
135#define IMAGE_FILE_MACHINE_AM33 UINT16_C(0x01d3)
136/** Power PC CPU, little endian. */
137#define IMAGE_FILE_MACHINE_POWERPC UINT16_C(0x01f0)
138/** Power PC CPU with FPU, also little endian? */
139#define IMAGE_FILE_MACHINE_POWERPCFP UINT16_C(0x01f1)
140/** "Itanic" CPU. */
141#define IMAGE_FILE_MACHINE_IA64 UINT16_C(0x0200)
142/** MIPS CPU, compact 16-bit instructions only? */
143#define IMAGE_FILE_MACHINE_MIPS16 UINT16_C(0x0266)
144/** MIPS CPU with FPU, full 32-bit instructions only? */
145#define IMAGE_FILE_MACHINE_MIPSFPU UINT16_C(0x0366)
146/** MIPS CPU with FPU, compact 16-bit instructions? */
147#define IMAGE_FILE_MACHINE_MIPSFPU16 UINT16_C(0x0466)
148/** EFI byte code. */
149#define IMAGE_FILE_MACHINE_EBC UINT16_C(0x0ebc)
150/** Mitsubishi M32R CPU, little endian. */
151#define IMAGE_FILE_MACHINE_M32R UINT16_C(0x9041)
152/** ARMv8 CPU, 64-bit mode. */
153#define IMAGE_FILE_MACHINE_ARM64 UINT16_C(0xaa64)
154/** @} */
155
156/** @name File header characteristics (IMAGE_FILE_HEADER::Characteristics)
157 * @{ */
158#define IMAGE_FILE_RELOCS_STRIPPED UINT16_C(0x0001)
159#define IMAGE_FILE_EXECUTABLE_IMAGE UINT16_C(0x0002)
160#define IMAGE_FILE_LINE_NUMS_STRIPPED UINT16_C(0x0004)
161#define IMAGE_FILE_LOCAL_SYMS_STRIPPED UINT16_C(0x0008)
162#define IMAGE_FILE_AGGRESIVE_WS_TRIM UINT16_C(0x0010)
163#define IMAGE_FILE_LARGE_ADDRESS_AWARE UINT16_C(0x0020)
164#define IMAGE_FILE_16BIT_MACHINE UINT16_C(0x0040)
165#define IMAGE_FILE_BYTES_REVERSED_LO UINT16_C(0x0080)
166#define IMAGE_FILE_32BIT_MACHINE UINT16_C(0x0100)
167#define IMAGE_FILE_DEBUG_STRIPPED UINT16_C(0x0200)
168#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP UINT16_C(0x0400)
169#define IMAGE_FILE_NET_RUN_FROM_SWAP UINT16_C(0x0800)
170#define IMAGE_FILE_SYSTEM UINT16_C(0x1000) /**< (COFF/IAPX*: Used to indicate 80186 instructions) */
171#define IMAGE_FILE_DLL UINT16_C(0x2000) /**< (COFF/IAPX*: Used to indicate 80286 instructions) */
172#define IMAGE_FILE_UP_SYSTEM_ONLY UINT16_C(0x4000)
173#define IMAGE_FILE_BYTES_REVERSED_HI UINT16_C(0x8000)
174/** @} */
175
176
177/**
178 * PE data directory.
179 *
180 * This is used to locate data in the loaded image so the dynamic linker or
181 * others can make use of it. However, in the case of
182 * IMAGE_DIRECTORY_ENTRY_SECURITY it is referring to raw file offsets.
183 */
184typedef struct _IMAGE_DATA_DIRECTORY
185{
186 uint32_t VirtualAddress;
187 uint32_t Size;
188} IMAGE_DATA_DIRECTORY;
189AssertCompileSize(IMAGE_DATA_DIRECTORY, 0x8);
190typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
191typedef IMAGE_DATA_DIRECTORY const *PCIMAGE_DATA_DIRECTORY;
192
193/** The standard number of data directories in the optional header.
194 * I.e. the dimensions of IMAGE_OPTIONAL_HEADER32::DataDirectory and
195 * IMAGE_OPTIONAL_HEADER64::DataDirectory.
196 */
197#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 0x10
198
199
200/**
201 * PE optional header, 32-bit version.
202 */
203typedef struct _IMAGE_OPTIONAL_HEADER32
204{
205 uint16_t Magic; /**< 0x00 */
206 uint8_t MajorLinkerVersion; /**< 0x02 */
207 uint8_t MinorLinkerVersion; /**< 0x03 */
208 uint32_t SizeOfCode; /**< 0x04 */
209 uint32_t SizeOfInitializedData; /**< 0x08 */
210 uint32_t SizeOfUninitializedData; /**< 0x0c */
211 uint32_t AddressOfEntryPoint; /**< 0x10 */
212 uint32_t BaseOfCode; /**< 0x14 */
213 uint32_t BaseOfData; /**< 0x18 */
214 uint32_t ImageBase; /**< 0x1c */
215 uint32_t SectionAlignment; /**< 0x20 */
216 uint32_t FileAlignment; /**< 0x24 */
217 uint16_t MajorOperatingSystemVersion; /**< 0x28 */
218 uint16_t MinorOperatingSystemVersion; /**< 0x2a */
219 uint16_t MajorImageVersion; /**< 0x2c */
220 uint16_t MinorImageVersion; /**< 0x2e */
221 uint16_t MajorSubsystemVersion; /**< 0x30 */
222 uint16_t MinorSubsystemVersion; /**< 0x32 */
223 uint32_t Win32VersionValue; /**< 0x34 */
224 uint32_t SizeOfImage; /**< 0x38 */
225 uint32_t SizeOfHeaders; /**< 0x3c */
226 uint32_t CheckSum; /**< 0x40 */
227 uint16_t Subsystem; /**< 0x44 */
228 uint16_t DllCharacteristics; /**< 0x46 */
229 uint32_t SizeOfStackReserve; /**< 0x48 */
230 uint32_t SizeOfStackCommit; /**< 0x4c */
231 uint32_t SizeOfHeapReserve; /**< 0x50 */
232 uint32_t SizeOfHeapCommit; /**< 0x54 */
233 uint32_t LoaderFlags; /**< 0x58 */
234 uint32_t NumberOfRvaAndSizes; /**< 0x5c */
235 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x60; 0x10*8 = 0x80 */
236} IMAGE_OPTIONAL_HEADER32; /* size: 0xe0 */
237AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
238typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
239typedef IMAGE_OPTIONAL_HEADER32 const *PCIMAGE_OPTIONAL_HEADER32;
240
241/**
242 * PE optional header, 64-bit version.
243 */
244typedef struct _IMAGE_OPTIONAL_HEADER64
245{
246 uint16_t Magic; /**< 0x00 */
247 uint8_t MajorLinkerVersion; /**< 0x02 */
248 uint8_t MinorLinkerVersion; /**< 0x03 */
249 uint32_t SizeOfCode; /**< 0x04 */
250 uint32_t SizeOfInitializedData; /**< 0x08 */
251 uint32_t SizeOfUninitializedData; /**< 0x0c */
252 uint32_t AddressOfEntryPoint; /**< 0x10 */
253 uint32_t BaseOfCode; /**< 0x14 */
254 uint64_t ImageBase; /**< 0x18 */
255 uint32_t SectionAlignment; /**< 0x20 */
256 uint32_t FileAlignment; /**< 0x24 */
257 uint16_t MajorOperatingSystemVersion; /**< 0x28 */
258 uint16_t MinorOperatingSystemVersion; /**< 0x2a */
259 uint16_t MajorImageVersion; /**< 0x2c */
260 uint16_t MinorImageVersion; /**< 0x2e */
261 uint16_t MajorSubsystemVersion; /**< 0x30 */
262 uint16_t MinorSubsystemVersion; /**< 0x32 */
263 uint32_t Win32VersionValue; /**< 0x34 */
264 uint32_t SizeOfImage; /**< 0x38 */
265 uint32_t SizeOfHeaders; /**< 0x3c */
266 uint32_t CheckSum; /**< 0x40 */
267 uint16_t Subsystem; /**< 0x44 */
268 uint16_t DllCharacteristics; /**< 0x46 */
269 uint64_t SizeOfStackReserve; /**< 0x48 */
270 uint64_t SizeOfStackCommit; /**< 0x50 */
271 uint64_t SizeOfHeapReserve; /**< 0x58 */
272 uint64_t SizeOfHeapCommit; /**< 0x60 */
273 uint32_t LoaderFlags; /**< 0x68 */
274 uint32_t NumberOfRvaAndSizes; /**< 0x6c */
275 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x70; 0x10*8 = 0x80 */
276} IMAGE_OPTIONAL_HEADER64; /* size: 0xf0 */
277AssertCompileSize(IMAGE_OPTIONAL_HEADER64, 0xf0);
278typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
279typedef IMAGE_OPTIONAL_HEADER64 const *PCIMAGE_OPTIONAL_HEADER64;
280
281/** @name Optional header magic values.
282 * @{ */
283#define IMAGE_NT_OPTIONAL_HDR32_MAGIC UINT16_C(0x010b)
284#define IMAGE_NT_OPTIONAL_HDR64_MAGIC UINT16_C(0x020b)
285/** @} */
286
287/** @name IMAGE_SUBSYSTEM_XXX - Optional header subsystems.
288 * IMAGE_OPTIONAL_HEADER32::Subsystem, IMAGE_OPTIONAL_HEADER64::Subsystem
289 * @{ */
290#define IMAGE_SUBSYSTEM_UNKNOWN UINT16_C(0x0000)
291#define IMAGE_SUBSYSTEM_NATIVE UINT16_C(0x0001)
292#define IMAGE_SUBSYSTEM_WINDOWS_GUI UINT16_C(0x0002)
293#define IMAGE_SUBSYSTEM_WINDOWS_CUI UINT16_C(0x0003)
294#define IMAGE_SUBSYSTEM_OS2_GUI UINT16_C(0x0004)
295#define IMAGE_SUBSYSTEM_OS2_CUI UINT16_C(0x0005)
296#define IMAGE_SUBSYSTEM_POSIX_CUI UINT16_C(0x0007)
297/** @} */
298
299/** @name Optional header characteristics.
300 * @{ */
301#define IMAGE_LIBRARY_PROCESS_INIT UINT16_C(0x0001)
302#define IMAGE_LIBRARY_PROCESS_TERM UINT16_C(0x0002)
303#define IMAGE_LIBRARY_THREAD_INIT UINT16_C(0x0004)
304#define IMAGE_LIBRARY_THREAD_TERM UINT16_C(0x0008)
305#define IMAGE_DLLCHARACTERISTICS_RESERVED UINT16_C(0x0010)
306#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA UINT16_C(0x0020)
307#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE UINT16_C(0x0040)
308#define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY UINT16_C(0x0080)
309#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT UINT16_C(0x0100)
310#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION UINT16_C(0x0200)
311#define IMAGE_DLLCHARACTERISTICS_NO_SEH UINT16_C(0x0400)
312#define IMAGE_DLLCHARACTERISTICS_NO_BIND UINT16_C(0x0800)
313#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER UINT16_C(0x1000)
314#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER UINT16_C(0x2000)
315#define IMAGE_DLLCHARACTERISTICS_GUARD_CF UINT16_C(0x4000)
316#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE UINT16_C(0x8000)
317/** @} */
318
319
320/** @name IMAGE_DIRECTORY_ENTRY_XXX - Data directory indexes.
321 * Used to index IMAGE_OPTIONAL_HEADER32::DataDirectory and
322 * IMAGE_OPTIONAL_HEADER64::DataDirectory
323 * @{ */
324#define IMAGE_DIRECTORY_ENTRY_EXPORT 0x0
325#define IMAGE_DIRECTORY_ENTRY_IMPORT 0x1
326#define IMAGE_DIRECTORY_ENTRY_RESOURCE 0x2
327#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 0x3
328#define IMAGE_DIRECTORY_ENTRY_SECURITY 0x4
329#define IMAGE_DIRECTORY_ENTRY_BASERELOC 0x5
330#define IMAGE_DIRECTORY_ENTRY_DEBUG 0x6
331#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 0x7
332#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
333#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 0x8
334#define IMAGE_DIRECTORY_ENTRY_TLS 0x9
335#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 0xa
336#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 0xb
337#define IMAGE_DIRECTORY_ENTRY_IAT 0xc
338#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 0xd
339#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 0xe
340/** @} */
341
342
343/**
344 * PE (NT) headers, 32-bit version.
345 */
346typedef struct _IMAGE_NT_HEADERS32
347{
348 uint32_t Signature; /**< 0x00 */
349 IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
350 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /**< 0x18 */
351} IMAGE_NT_HEADERS32; /* size: 0xf8 */
352AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
353AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
354AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
355typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
356typedef IMAGE_NT_HEADERS32 const *PCIMAGE_NT_HEADERS32;
357
358/**
359 * PE (NT) headers, 64-bit version.
360 */
361typedef struct _IMAGE_NT_HEADERS64
362{
363 uint32_t Signature; /**< 0x00 */
364 IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
365 IMAGE_OPTIONAL_HEADER64 OptionalHeader; /**< 0x18 */
366} IMAGE_NT_HEADERS64; /**< 0x108 */
367AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
368AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
369AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
370typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
371typedef IMAGE_NT_HEADERS64 const *PCIMAGE_NT_HEADERS64;
372
373/** The PE signature.
374 * Used by IMAGE_NT_HEADERS32::Signature, IMAGE_NT_HEADERS64::Signature. */
375#define IMAGE_NT_SIGNATURE UINT32_C(0x00004550)
376
377
378/** Section header short name length (IMAGE_SECTION_HEADER::Name). */
379#define IMAGE_SIZEOF_SHORT_NAME 0x8
380
381/**
382 * PE & COFF section header.
383 */
384typedef struct _IMAGE_SECTION_HEADER
385{
386 uint8_t Name[IMAGE_SIZEOF_SHORT_NAME];
387 union
388 {
389 uint32_t PhysicalAddress;
390 uint32_t VirtualSize;
391 } Misc;
392 uint32_t VirtualAddress;
393 uint32_t SizeOfRawData;
394 uint32_t PointerToRawData;
395 uint32_t PointerToRelocations;
396 uint32_t PointerToLinenumbers;
397 uint16_t NumberOfRelocations;
398 uint16_t NumberOfLinenumbers;
399 uint32_t Characteristics;
400} IMAGE_SECTION_HEADER;
401AssertCompileSize(IMAGE_SECTION_HEADER, 40);
402typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
403typedef IMAGE_SECTION_HEADER const *PCIMAGE_SECTION_HEADER;
404
405/** @name IMAGE_SCN_XXX - Section header characteristics.
406 * Used by IMAGE_SECTION_HEADER::Characteristics.
407 * @{ */
408#define IMAGE_SCN_TYPE_REG UINT32_C(0x00000000)
409#define IMAGE_SCN_TYPE_DSECT UINT32_C(0x00000001)
410#define IMAGE_SCN_TYPE_NOLOAD UINT32_C(0x00000002)
411#define IMAGE_SCN_TYPE_GROUP UINT32_C(0x00000004)
412#define IMAGE_SCN_TYPE_NO_PAD UINT32_C(0x00000008)
413#define IMAGE_SCN_TYPE_COPY UINT32_C(0x00000010)
414
415#define IMAGE_SCN_CNT_CODE UINT32_C(0x00000020)
416#define IMAGE_SCN_CNT_INITIALIZED_DATA UINT32_C(0x00000040)
417#define IMAGE_SCN_CNT_UNINITIALIZED_DATA UINT32_C(0x00000080)
418
419#define IMAGE_SCN_LNK_OTHER UINT32_C(0x00000100)
420#define IMAGE_SCN_LNK_INFO UINT32_C(0x00000200)
421#define IMAGE_SCN_TYPE_OVER UINT32_C(0x00000400)
422#define IMAGE_SCN_LNK_REMOVE UINT32_C(0x00000800)
423#define IMAGE_SCN_LNK_COMDAT UINT32_C(0x00001000)
424#define IMAGE_SCN_MEM_PROTECTED UINT32_C(0x00004000)
425#define IMAGE_SCN_NO_DEFER_SPEC_EXC UINT32_C(0x00004000)
426#define IMAGE_SCN_GPREL UINT32_C(0x00008000)
427#define IMAGE_SCN_MEM_FARDATA UINT32_C(0x00008000)
428#define IMAGE_SCN_MEM_SYSHEAP UINT32_C(0x00010000)
429#define IMAGE_SCN_MEM_PURGEABLE UINT32_C(0x00020000)
430#define IMAGE_SCN_MEM_16BIT UINT32_C(0x00020000)
431#define IMAGE_SCN_MEM_LOCKED UINT32_C(0x00040000)
432#define IMAGE_SCN_MEM_PRELOAD UINT32_C(0x00080000)
433
434#define IMAGE_SCN_ALIGN_1BYTES UINT32_C(0x00100000)
435#define IMAGE_SCN_ALIGN_2BYTES UINT32_C(0x00200000)
436#define IMAGE_SCN_ALIGN_4BYTES UINT32_C(0x00300000)
437#define IMAGE_SCN_ALIGN_8BYTES UINT32_C(0x00400000)
438#define IMAGE_SCN_ALIGN_16BYTES UINT32_C(0x00500000)
439#define IMAGE_SCN_ALIGN_32BYTES UINT32_C(0x00600000)
440#define IMAGE_SCN_ALIGN_64BYTES UINT32_C(0x00700000)
441#define IMAGE_SCN_ALIGN_128BYTES UINT32_C(0x00800000)
442#define IMAGE_SCN_ALIGN_256BYTES UINT32_C(0x00900000)
443#define IMAGE_SCN_ALIGN_512BYTES UINT32_C(0x00A00000)
444#define IMAGE_SCN_ALIGN_1024BYTES UINT32_C(0x00B00000)
445#define IMAGE_SCN_ALIGN_2048BYTES UINT32_C(0x00C00000)
446#define IMAGE_SCN_ALIGN_4096BYTES UINT32_C(0x00D00000)
447#define IMAGE_SCN_ALIGN_8192BYTES UINT32_C(0x00E00000)
448#define IMAGE_SCN_ALIGN_MASK UINT32_C(0x00F00000)
449#define IMAGE_SCN_ALIGN_SHIFT 20
450
451#define IMAGE_SCN_LNK_NRELOC_OVFL UINT32_C(0x01000000)
452#define IMAGE_SCN_MEM_DISCARDABLE UINT32_C(0x02000000)
453#define IMAGE_SCN_MEM_NOT_CACHED UINT32_C(0x04000000)
454#define IMAGE_SCN_MEM_NOT_PAGED UINT32_C(0x08000000)
455#define IMAGE_SCN_MEM_SHARED UINT32_C(0x10000000)
456#define IMAGE_SCN_MEM_EXECUTE UINT32_C(0x20000000)
457#define IMAGE_SCN_MEM_READ UINT32_C(0x40000000)
458#define IMAGE_SCN_MEM_WRITE UINT32_C(0x80000000)
459/** @} */
460
461
462/**
463 * PE image base relocations block header.
464 *
465 * This found in IMAGE_DIRECTORY_ENTRY_BASERELOC. Each entry is follow
466 * immediately by an array of 16-bit words, where the lower 12-bits are used
467 * for the page offset and the upper 4-bits for the base relocation type
468 * (IMAGE_REL_BASE_XXX). The block should be padded with
469 * IMAGE_REL_BASED_ABSOLUTE entries to ensure 32-bit alignment of this header.
470 */
471typedef struct _IMAGE_BASE_RELOCATION
472{
473 /** The RVA of the page/block the following ase relocations applies to. */
474 uint32_t VirtualAddress;
475 /** The size of this relocation block, including this header. */
476 uint32_t SizeOfBlock;
477} IMAGE_BASE_RELOCATION;
478AssertCompileSize(IMAGE_BASE_RELOCATION, 8);
479typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
480typedef IMAGE_BASE_RELOCATION const *PCIMAGE_BASE_RELOCATION;
481
482/** @name IMAGE_REL_BASED_XXX - PE base relocations.
483 * Found in the IMAGE_DIRECTORY_ENTRY_BASERELOC data directory.
484 * @{ */
485#define IMAGE_REL_BASED_ABSOLUTE UINT16_C(0x0)
486#define IMAGE_REL_BASED_HIGH UINT16_C(0x1)
487#define IMAGE_REL_BASED_LOW UINT16_C(0x2)
488#define IMAGE_REL_BASED_HIGHLOW UINT16_C(0x3)
489#define IMAGE_REL_BASED_HIGHADJ UINT16_C(0x4)
490#define IMAGE_REL_BASED_MIPS_JMPADDR UINT16_C(0x5)
491#define IMAGE_REL_BASED_MIPS_JMPADDR16 UINT16_C(0x9)
492#define IMAGE_REL_BASED_IA64_IMM64 UINT16_C(0x9)
493#define IMAGE_REL_BASED_DIR64 UINT16_C(0xa)
494#define IMAGE_REL_BASED_HIGH3ADJ UINT16_C(0xb)
495/** @} */
496
497/**
498 * PE export directory entry.
499 */
500typedef struct _IMAGE_EXPORT_DIRECTORY
501{
502 uint32_t Characteristics;
503 uint32_t TimeDateStamp;
504 uint16_t MajorVersion;
505 uint16_t MinorVersion;
506 uint32_t Name;
507 uint32_t Base;
508 uint32_t NumberOfFunctions;
509 uint32_t NumberOfNames;
510 uint32_t AddressOfFunctions;
511 uint32_t AddressOfNames;
512 uint32_t AddressOfNameOrdinals;
513} IMAGE_EXPORT_DIRECTORY;
514AssertCompileSize(IMAGE_EXPORT_DIRECTORY, 40);
515typedef IMAGE_EXPORT_DIRECTORY *PIMAGE_EXPORT_DIRECTORY;
516typedef IMAGE_EXPORT_DIRECTORY const *PCIMAGE_EXPORT_DIRECTORY;
517
518
519/**
520 * PE import directory entry.
521 */
522typedef struct _IMAGE_IMPORT_DESCRIPTOR
523{
524 union
525 {
526 uint32_t Characteristics;
527 uint32_t OriginalFirstThunk;
528 } u;
529 uint32_t TimeDateStamp;
530 uint32_t ForwarderChain;
531 uint32_t Name;
532 uint32_t FirstThunk;
533} IMAGE_IMPORT_DESCRIPTOR;
534AssertCompileSize(IMAGE_IMPORT_DESCRIPTOR, 20);
535typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
536typedef IMAGE_IMPORT_DESCRIPTOR const *PCIMAGE_IMPORT_DESCRIPTOR;
537
538/**
539 * Something we currently don't make use of...
540 */
541typedef struct _IMAGE_IMPORT_BY_NAME
542{
543 uint16_t Hint;
544 uint8_t Name[1];
545} IMAGE_IMPORT_BY_NAME;
546AssertCompileSize(IMAGE_IMPORT_BY_NAME, 4);
547typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
548typedef IMAGE_IMPORT_BY_NAME const *PCIMAGE_IMPORT_BY_NAME;
549
550
551#if 0
552/* The image_thunk_data32/64 structures are not very helpful except for getting RSI.
553 keep them around till all the code has been converted. */
554typedef struct _IMAGE_THUNK_DATA64
555{
556 union
557 {
558 uint64_t ForwarderString;
559 uint64_t Function;
560 uint64_t Ordinal;
561 uint64_t AddressOfData;
562 } u1;
563} IMAGE_THUNK_DATA64;
564typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
565typedef IMAGE_THUNK_DATA64 const *PCIMAGE_THUNK_DATA64;
566
567typedef struct _IMAGE_THUNK_DATA32
568{
569 union
570 {
571 uint32_t ForwarderString;
572 uint32_t Function;
573 uint32_t Ordinal;
574 uint32_t AddressOfData;
575 } u1;
576} IMAGE_THUNK_DATA32;
577typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
578typedef IMAGE_THUNK_DATA32 const *PCIMAGE_THUNK_DATA32;
579#endif
580
581/** @name PE import directory macros.
582 * @{ */
583#define IMAGE_ORDINAL_FLAG32 UINT32_C(0x80000000)
584#define IMAGE_ORDINAL32(ord) ((ord) & UINT32_C(0xffff))
585#define IMAGE_SNAP_BY_ORDINAL32(ord) (!!((ord) & IMAGE_ORDINAL_FLAG32))
586
587#define IMAGE_ORDINAL_FLAG64 UINT64_C(0x8000000000000000)
588#define IMAGE_ORDINAL64(ord) ((ord) & UINT32_C(0xffff))
589#define IMAGE_SNAP_BY_ORDINAL64(ord) (!!((ord) & IMAGE_ORDINAL_FLAG64))
590/** @} */
591
592/** @name PE Resource directory
593 * @{ */
594typedef struct _IMAGE_RESOURCE_DIRECTORY
595{
596 uint32_t Characteristics;
597 uint32_t TimeDateStamp;
598 uint16_t MajorVersion;
599 uint16_t MinorVersion;
600 uint16_t NumberOfNamedEntries;
601 uint16_t NumberOfIdEntries;
602} IMAGE_RESOURCE_DIRECTORY;
603typedef IMAGE_RESOURCE_DIRECTORY *PIMAGE_RESOURCE_DIRECTORY;
604typedef IMAGE_RESOURCE_DIRECTORY const *PCIMAGE_RESOURCE_DIRECTORY;
605
606typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
607{
608 union
609 {
610 struct
611 {
612 uint32_t NameOffset : 31;
613 uint32_t NameIsString : 1; /**< IMAGE_RESOURCE_NAME_IS_STRING */
614 } s;
615 uint32_t Name;
616 uint16_t Id;
617 } u;
618 union
619 {
620 struct
621 {
622 uint32_t OffsetToDirectory : 31;
623 uint32_t DataIsDirectory : 1; /**< IMAGE_RESOURCE_DATA_IS_DIRECTORY*/
624 } s2;
625 uint32_t OffsetToData;
626 } u2;
627} IMAGE_RESOURCE_DIRECTORY_ENTRY;
628typedef IMAGE_RESOURCE_DIRECTORY_ENTRY *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
629typedef IMAGE_RESOURCE_DIRECTORY_ENTRY const *PCIMAGE_RESOURCE_DIRECTORY_ENTRY;
630
631#define IMAGE_RESOURCE_NAME_IS_STRING UINT32_C(0x80000000)
632#define IMAGE_RESOURCE_DATA_IS_DIRECTORY UINT32_C(0x80000000)
633
634typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
635{
636 uint16_t Length;
637 char NameString[1];
638} IMAGE_RESOURCE_DIRECTORY_STRING;
639typedef IMAGE_RESOURCE_DIRECTORY_STRING *PIMAGE_RESOURCE_DIRECTORY_STRING;
640typedef IMAGE_RESOURCE_DIRECTORY_STRING const *PCIMAGE_RESOURCE_DIRECTORY_STRING;
641
642
643typedef struct _IMAGE_RESOURCE_DIR_STRING_U
644{
645 uint16_t Length;
646 RTUTF16 NameString[1];
647} IMAGE_RESOURCE_DIR_STRING_U;
648typedef IMAGE_RESOURCE_DIR_STRING_U *PIMAGE_RESOURCE_DIR_STRING_U;
649typedef IMAGE_RESOURCE_DIR_STRING_U const *PCIMAGE_RESOURCE_DIR_STRING_U;
650
651
652typedef struct _IMAGE_RESOURCE_DATA_ENTRY
653{
654 uint32_t OffsetToData;
655 uint32_t Size;
656 uint32_t CodePage;
657 uint32_t Reserved;
658} IMAGE_RESOURCE_DATA_ENTRY;
659typedef IMAGE_RESOURCE_DATA_ENTRY *PIMAGE_RESOURCE_DATA_ENTRY;
660typedef IMAGE_RESOURCE_DATA_ENTRY const *PCIMAGE_RESOURCE_DATA_ENTRY;
661
662/** @} */
663
664/** @name Image exception information
665 * @{ */
666
667/** This structure is used by AMD64 and "Itanic".
668 * MIPS uses a different one. ARM, SH3, SH4 and PPC on WinCE also uses a different one. */
669typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY
670{
671 uint32_t BeginAddress;
672 uint32_t EndAddress;
673 uint32_t UnwindInfoAddress;
674} IMAGE_RUNTIME_FUNCTION_ENTRY;
675AssertCompileSize(IMAGE_RUNTIME_FUNCTION_ENTRY, 12);
676typedef IMAGE_RUNTIME_FUNCTION_ENTRY *PIMAGE_RUNTIME_FUNCTION_ENTRY;
677typedef IMAGE_RUNTIME_FUNCTION_ENTRY const *PCIMAGE_RUNTIME_FUNCTION_ENTRY;
678
679/**
680 * An unwind code for AMD64 and ARM64.
681 *
682 * @note Also known as UNWIND_CODE or _UNWIND_CODE.
683 */
684typedef union IMAGE_UNWIND_CODE
685{
686 struct
687 {
688 /** The prolog offset where the change takes effect.
689 * This means the instruction following the one being described. */
690 uint8_t CodeOffset;
691 /** Unwind opcode.
692 * For AMD64 see IMAGE_AMD64_UNWIND_OP_CODES. */
693 RT_GCC_EXTENSION uint8_t UnwindOp : 4;
694 /** Opcode specific. */
695 RT_GCC_EXTENSION uint8_t OpInfo : 4;
696 } u;
697 uint16_t FrameOffset;
698} IMAGE_UNWIND_CODE;
699AssertCompileSize(IMAGE_UNWIND_CODE, 2);
700
701/**
702 * Unwind information for AMD64 and ARM64.
703 *
704 * Pointed to by IMAGE_RUNTIME_FUNCTION_ENTRY::UnwindInfoAddress,
705 *
706 * @note Also known as UNWIND_INFO or _UNWIND_INFO.
707 */
708typedef struct IMAGE_UNWIND_INFO
709{
710 /** Version, currently 1 or 2. The latter if IMAGE_AMD64_UWOP_EPILOG is used. */
711 RT_GCC_EXTENSION uint8_t Version : 3;
712 /** IMAGE_UNW_FLAG_XXX */
713 RT_GCC_EXTENSION uint8_t Flags : 5;
714 /** Size of function prolog. */
715 uint8_t SizeOfProlog;
716 /** Number of opcodes in aOpcodes. */
717 uint8_t CountOfCodes;
718 /** Initial frame register. */
719 RT_GCC_EXTENSION uint8_t FrameRegister : 4;
720 /** Scaled frame register offset. */
721 RT_GCC_EXTENSION uint8_t FrameOffset : 4;
722 /** Unwind opcodes. */
723 IMAGE_UNWIND_CODE aOpcodes[RT_FLEXIBLE_ARRAY];
724} IMAGE_UNWIND_INFO;
725AssertCompileMemberOffset(IMAGE_UNWIND_INFO, aOpcodes, 4);
726typedef IMAGE_UNWIND_INFO *PIMAGE_UNWIND_INFO;
727typedef IMAGE_UNWIND_INFO const *PCIMAGE_UNWIND_INFO;
728
729/** IMAGE_UNW_FLAGS_XXX - IMAGE_UNWIND_INFO::Flags.
730 * @{ */
731/** No handler.
732 * @note Aslo know as UNW_FLAG_NHANDLER. */
733#define IMAGE_UNW_FLAGS_NHANDLER 0
734/** Have exception handler (RVA after codes, dword aligned.)
735 * @note Aslo know as UNW_FLAG_NHANDLER. */
736#define IMAGE_UNW_FLAGS_EHANDLER 1
737/** Have unwind handler (RVA after codes, dword aligned.)
738 * @note Aslo know as UNW_FLAG_NHANDLER. */
739#define IMAGE_UNW_FLAGS_UHANDLER 2
740/** Set if not primary unwind info for a function. An
741 * IMAGE_RUNTIME_FUNCTION_ENTRY giving the chained unwind info follows the
742 * aOpcodes array at a dword aligned offset. */
743#define IMAGE_UNW_FLAGS_CHAININFO 4
744/** @} */
745
746/**
747 * AMD64 unwind opcodes.
748 */
749typedef enum IMAGE_AMD64_UNWIND_OP_CODES
750{
751 /** Push non-volatile register (OpInfo).
752 * YASM: [pushreg reg]
753 * MASM: .PUSHREG reg */
754 IMAGE_AMD64_UWOP_PUSH_NONVOL = 0,
755 /** Stack allocation: Size stored in scaled in the next slot if OpInfo == 0,
756 * otherwise stored unscaled in the next two slots.
757 * YASM: [allocstack size]
758 * MASM: .ALLOCSTACK size */
759 IMAGE_AMD64_UWOP_ALLOC_LARGE,
760 /** Stack allocation: OpInfo = size / 8 - 1.
761 * YASM: [allocstack size]
762 * MASM: .ALLOCSTACK size */
763 IMAGE_AMD64_UWOP_ALLOC_SMALL,
764 /** Set frame pointer register: RSP + FrameOffset * 16.
765 * YASM: [setframe reg, offset]
766 * MASM: .SETFRAME reg, offset
767 * @code
768 * LEA RBP, [RSP + 20h]
769 * [setframe RBP, 20h]
770 * @endcode */
771 IMAGE_AMD64_UWOP_SET_FPREG,
772 /** Save non-volatile register (OpInfo) on stack (RSP/FP + next slot).
773 * YASM: [savereg reg, offset]
774 * MASM: .SAVEREG reg, offset */
775 IMAGE_AMD64_UWOP_SAVE_NONVOL,
776 /** Save non-volatile register (OpInfo) on stack (RSP/FP + next two slots).
777 * YASM: [savereg reg, offset]
778 * MASM: .SAVEREG reg, offset */
779 IMAGE_AMD64_UWOP_SAVE_NONVOL_FAR,
780 /** Epilog info, version 2+.
781 *
782 * The first time this opcode is used, the CodeOffset gives the size of the
783 * epilog and bit 0 of the OpInfo field indicates that there is only one
784 * epilog at the very end of the function.
785 *
786 * Subsequent uses of this opcode specifies epilog start offsets relative to
787 * the end of the function, using CodeOffset for the 8 lower bits and OpInfo
788 * for bits 8 thru 11.
789 *
790 * The compiler seems to stack allocations and register saving opcodes and
791 * indicates the location mirroring the first IMAGE_AMD64_UWOP_PUSH_NONVOL. */
792 IMAGE_AMD64_UWOP_EPILOG,
793 /** Undefined. */
794 IMAGE_AMD64_UWOP_RESERVED_7,
795 /** Save 128-bit XMM register (OpInfo) on stack (RSP/FP + next slot).
796 * YASM: [savexmm128 reg, offset]
797 * MASM: .SAVEXMM128 reg, offset */
798 IMAGE_AMD64_UWOP_SAVE_XMM128,
799 /** Save 128-bit XMM register (OpInfo) on stack (RSP/FP + next two slots).
800 * YASM: [savexmm128 reg, offset]
801 * MASM: .SAVEXMM128 reg, offset */
802 IMAGE_AMD64_UWOP_SAVE_XMM128_FAR,
803 /** IRET frame, OpInfo serves as error code indicator.
804 * YASM: [pushframe with-code]
805 * MASM: .pushframe with-code */
806 IMAGE_AMD64_UWOP_PUSH_MACHFRAME
807} IMAGE_AMD64_UNWIND_OP_CODES;
808/** @} */
809
810
811
812/** @name Image load config directories
813 * @{ */
814
815/** @since Windows 10 (preview 9879) */
816typedef struct _IMAGE_LOAD_CONFIG_CODE_INTEGRITY
817{
818 uint16_t Flags;
819 uint16_t Catalog;
820 uint32_t CatalogOffset;
821 uint32_t Reserved;
822} IMAGE_LOAD_CONFIG_CODE_INTEGRITY;
823AssertCompileSize(IMAGE_LOAD_CONFIG_CODE_INTEGRITY, 12);
824typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY *PIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
825typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY const *PCIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
826
827typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V1
828{
829 uint32_t Size;
830 uint32_t TimeDateStamp;
831 uint16_t MajorVersion;
832 uint16_t MinorVersion;
833 uint32_t GlobalFlagsClear;
834 uint32_t GlobalFlagsSet;
835 uint32_t CriticalSectionDefaultTimeout;
836 uint32_t DeCommitFreeBlockThreshold;
837 uint32_t DeCommitTotalFreeThreshold;
838 uint32_t LockPrefixTable;
839 uint32_t MaximumAllocationSize;
840 uint32_t VirtualMemoryThreshold;
841 uint32_t ProcessHeapFlags;
842 uint32_t ProcessAffinityMask;
843 uint16_t CSDVersion;
844 uint16_t DependentLoadFlags;
845 uint32_t EditList;
846 uint32_t SecurityCookie;
847} IMAGE_LOAD_CONFIG_DIRECTORY32_V1;
848AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V1, 0x40);
849typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V1;
850typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V1;
851
852typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V2
853{
854 uint32_t Size;
855 uint32_t TimeDateStamp;
856 uint16_t MajorVersion;
857 uint16_t MinorVersion;
858 uint32_t GlobalFlagsClear;
859 uint32_t GlobalFlagsSet;
860 uint32_t CriticalSectionDefaultTimeout;
861 uint32_t DeCommitFreeBlockThreshold;
862 uint32_t DeCommitTotalFreeThreshold;
863 uint32_t LockPrefixTable;
864 uint32_t MaximumAllocationSize;
865 uint32_t VirtualMemoryThreshold;
866 uint32_t ProcessHeapFlags;
867 uint32_t ProcessAffinityMask;
868 uint16_t CSDVersion;
869 uint16_t DependentLoadFlags;
870 uint32_t EditList;
871 uint32_t SecurityCookie;
872 uint32_t SEHandlerTable;
873 uint32_t SEHandlerCount;
874} IMAGE_LOAD_CONFIG_DIRECTORY32_V2;
875AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V2, 0x48);
876typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V2;
877typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V2;
878
879typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V3
880{
881 uint32_t Size;
882 uint32_t TimeDateStamp;
883 uint16_t MajorVersion;
884 uint16_t MinorVersion;
885 uint32_t GlobalFlagsClear;
886 uint32_t GlobalFlagsSet;
887 uint32_t CriticalSectionDefaultTimeout;
888 uint32_t DeCommitFreeBlockThreshold;
889 uint32_t DeCommitTotalFreeThreshold;
890 uint32_t LockPrefixTable;
891 uint32_t MaximumAllocationSize;
892 uint32_t VirtualMemoryThreshold;
893 uint32_t ProcessHeapFlags;
894 uint32_t ProcessAffinityMask;
895 uint16_t CSDVersion;
896 uint16_t DependentLoadFlags;
897 uint32_t EditList;
898 uint32_t SecurityCookie;
899 uint32_t SEHandlerTable;
900 uint32_t SEHandlerCount;
901 uint32_t GuardCFCCheckFunctionPointer;
902 uint32_t GuardCFDispatchFunctionPointer;
903 uint32_t GuardCFFunctionTable;
904 uint32_t GuardCFFunctionCount;
905 uint32_t GuardFlags;
906} IMAGE_LOAD_CONFIG_DIRECTORY32_V3;
907AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V3, 0x5c);
908typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V3;
909typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V3;
910
911/** @since Windows 10 (preview 9879) */
912typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V4
913{
914 uint32_t Size;
915 uint32_t TimeDateStamp;
916 uint16_t MajorVersion;
917 uint16_t MinorVersion;
918 uint32_t GlobalFlagsClear;
919 uint32_t GlobalFlagsSet;
920 uint32_t CriticalSectionDefaultTimeout;
921 uint32_t DeCommitFreeBlockThreshold;
922 uint32_t DeCommitTotalFreeThreshold;
923 uint32_t LockPrefixTable;
924 uint32_t MaximumAllocationSize;
925 uint32_t VirtualMemoryThreshold;
926 uint32_t ProcessHeapFlags;
927 uint32_t ProcessAffinityMask;
928 uint16_t CSDVersion;
929 uint16_t DependentLoadFlags;
930 uint32_t EditList;
931 uint32_t SecurityCookie;
932 uint32_t SEHandlerTable;
933 uint32_t SEHandlerCount;
934 uint32_t GuardCFCCheckFunctionPointer;
935 uint32_t GuardCFDispatchFunctionPointer;
936 uint32_t GuardCFFunctionTable;
937 uint32_t GuardCFFunctionCount;
938 uint32_t GuardFlags;
939 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
940} IMAGE_LOAD_CONFIG_DIRECTORY32_V4;
941AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V4, 0x68);
942typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V4;
943typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4;
944
945/** @since Windows 10 build 14286 (or maybe earlier). */
946typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V5
947{
948 uint32_t Size;
949 uint32_t TimeDateStamp;
950 uint16_t MajorVersion;
951 uint16_t MinorVersion;
952 uint32_t GlobalFlagsClear;
953 uint32_t GlobalFlagsSet;
954 uint32_t CriticalSectionDefaultTimeout;
955 uint32_t DeCommitFreeBlockThreshold;
956 uint32_t DeCommitTotalFreeThreshold;
957 uint32_t LockPrefixTable;
958 uint32_t MaximumAllocationSize;
959 uint32_t VirtualMemoryThreshold;
960 uint32_t ProcessHeapFlags;
961 uint32_t ProcessAffinityMask;
962 uint16_t CSDVersion;
963 uint16_t DependentLoadFlags;
964 uint32_t EditList;
965 uint32_t SecurityCookie;
966 uint32_t SEHandlerTable;
967 uint32_t SEHandlerCount;
968 uint32_t GuardCFCCheckFunctionPointer;
969 uint32_t GuardCFDispatchFunctionPointer;
970 uint32_t GuardCFFunctionTable;
971 uint32_t GuardCFFunctionCount;
972 uint32_t GuardFlags;
973 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
974 uint32_t GuardAddressTakenIatEntryTable;
975 uint32_t GuardAddressTakenIatEntryCount;
976 uint32_t GuardLongJumpTargetTable;
977 uint32_t GuardLongJumpTargetCount;
978} IMAGE_LOAD_CONFIG_DIRECTORY32_V5;
979AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V5, 0x78);
980typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V5;
981typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5;
982
983/** @since Windows 10 build 14383 (or maybe earlier). */
984typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V6
985{
986 uint32_t Size; /**< 0x00 */
987 uint32_t TimeDateStamp; /**< 0x04 */
988 uint16_t MajorVersion; /**< 0x08 */
989 uint16_t MinorVersion; /**< 0x0a */
990 uint32_t GlobalFlagsClear; /**< 0x0c */
991 uint32_t GlobalFlagsSet; /**< 0x10 */
992 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
993 uint32_t DeCommitFreeBlockThreshold; /**< 0x18 */
994 uint32_t DeCommitTotalFreeThreshold; /**< 0x1c */
995 uint32_t LockPrefixTable; /**< 0x20 */
996 uint32_t MaximumAllocationSize; /**< 0x24 */
997 uint32_t VirtualMemoryThreshold; /**< 0x28 */
998 uint32_t ProcessHeapFlags; /**< 0x2c */
999 uint32_t ProcessAffinityMask; /**< 0x30 */
1000 uint16_t CSDVersion; /**< 0x34 */
1001 uint16_t DependentLoadFlags; /**< 0x36 */
1002 uint32_t EditList; /**< 0x38 */
1003 uint32_t SecurityCookie; /**< 0x3c */
1004 uint32_t SEHandlerTable; /**< 0x40 */
1005 uint32_t SEHandlerCount; /**< 0x44 */
1006 uint32_t GuardCFCCheckFunctionPointer; /**< 0x48 */
1007 uint32_t GuardCFDispatchFunctionPointer; /**< 0x4c */
1008 uint32_t GuardCFFunctionTable; /**< 0x50 */
1009 uint32_t GuardCFFunctionCount; /**< 0x54 */
1010 uint32_t GuardFlags; /**< 0x58 */
1011 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
1012 uint32_t GuardAddressTakenIatEntryTable; /**< 0x68 */
1013 uint32_t GuardAddressTakenIatEntryCount; /**< 0x6c */
1014 uint32_t GuardLongJumpTargetTable; /**< 0x70 */
1015 uint32_t GuardLongJumpTargetCount; /**< 0x74 */
1016 uint32_t DynamicValueRelocTable; /**< 0x78 */
1017 uint32_t HybridMetadataPointer; /**< 0x7c */
1018} IMAGE_LOAD_CONFIG_DIRECTORY32_V6;
1019AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V6, 0x80);
1020typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V6;
1021typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V6;
1022
1023/** @since Windows 10 build 14901 (or maybe earlier). */
1024typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V7
1025{
1026 uint32_t Size; /**< 0x00 */
1027 uint32_t TimeDateStamp; /**< 0x04 */
1028 uint16_t MajorVersion; /**< 0x08 */
1029 uint16_t MinorVersion; /**< 0x0a */
1030 uint32_t GlobalFlagsClear; /**< 0x0c */
1031 uint32_t GlobalFlagsSet; /**< 0x10 */
1032 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1033 uint32_t DeCommitFreeBlockThreshold; /**< 0x18 */
1034 uint32_t DeCommitTotalFreeThreshold; /**< 0x1c */
1035 uint32_t LockPrefixTable; /**< 0x20 */
1036 uint32_t MaximumAllocationSize; /**< 0x24 */
1037 uint32_t VirtualMemoryThreshold; /**< 0x28 */
1038 uint32_t ProcessHeapFlags; /**< 0x2c */
1039 uint32_t ProcessAffinityMask; /**< 0x30 */
1040 uint16_t CSDVersion; /**< 0x34 */
1041 uint16_t DependentLoadFlags; /**< 0x36 */
1042 uint32_t EditList; /**< 0x38 */
1043 uint32_t SecurityCookie; /**< 0x3c */
1044 uint32_t SEHandlerTable; /**< 0x40 */
1045 uint32_t SEHandlerCount; /**< 0x44 */
1046 uint32_t GuardCFCCheckFunctionPointer; /**< 0x48 */
1047 uint32_t GuardCFDispatchFunctionPointer; /**< 0x4c */
1048 uint32_t GuardCFFunctionTable; /**< 0x50 */
1049 uint32_t GuardCFFunctionCount; /**< 0x54 */
1050 uint32_t GuardFlags; /**< 0x58 */
1051 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
1052 uint32_t GuardAddressTakenIatEntryTable; /**< 0x68 */
1053 uint32_t GuardAddressTakenIatEntryCount; /**< 0x6c */
1054 uint32_t GuardLongJumpTargetTable; /**< 0x70 */
1055 uint32_t GuardLongJumpTargetCount; /**< 0x74 */
1056 uint32_t DynamicValueRelocTable; /**< 0x78 */
1057 uint32_t CHPEMetadataPointer; /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
1058 uint32_t GuardRFFailureRoutine; /**< 0x80 */
1059 uint32_t GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
1060 uint32_t DynamicValueRelocTableOffset; /**< 0x88 */
1061 uint16_t DynamicValueRelocTableSection; /**< 0x8c */
1062 uint16_t Reserved2; /**< 0x8e */
1063} IMAGE_LOAD_CONFIG_DIRECTORY32_V7;
1064AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V7, 0x90);
1065typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
1066typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
1067
1068/** @since Windows 10 build 15002 (or maybe earlier). */
1069typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V8
1070{
1071 uint32_t Size; /**< 0x00 */
1072 uint32_t TimeDateStamp; /**< 0x04 */
1073 uint16_t MajorVersion; /**< 0x08 */
1074 uint16_t MinorVersion; /**< 0x0a */
1075 uint32_t GlobalFlagsClear; /**< 0x0c */
1076 uint32_t GlobalFlagsSet; /**< 0x10 */
1077 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1078 uint32_t DeCommitFreeBlockThreshold; /**< 0x18 */
1079 uint32_t DeCommitTotalFreeThreshold; /**< 0x1c */
1080 uint32_t LockPrefixTable; /**< 0x20 */
1081 uint32_t MaximumAllocationSize; /**< 0x24 */
1082 uint32_t VirtualMemoryThreshold; /**< 0x28 */
1083 uint32_t ProcessHeapFlags; /**< 0x2c */
1084 uint32_t ProcessAffinityMask; /**< 0x30 */
1085 uint16_t CSDVersion; /**< 0x34 */
1086 uint16_t DependentLoadFlags; /**< 0x36 */
1087 uint32_t EditList; /**< 0x38 */
1088 uint32_t SecurityCookie; /**< 0x3c */
1089 uint32_t SEHandlerTable; /**< 0x40 */
1090 uint32_t SEHandlerCount; /**< 0x44 */
1091 uint32_t GuardCFCCheckFunctionPointer; /**< 0x48 */
1092 uint32_t GuardCFDispatchFunctionPointer; /**< 0x4c */
1093 uint32_t GuardCFFunctionTable; /**< 0x50 */
1094 uint32_t GuardCFFunctionCount; /**< 0x54 */
1095 uint32_t GuardFlags; /**< 0x58 */
1096 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
1097 uint32_t GuardAddressTakenIatEntryTable; /**< 0x68 */
1098 uint32_t GuardAddressTakenIatEntryCount; /**< 0x6c */
1099 uint32_t GuardLongJumpTargetTable; /**< 0x70 */
1100 uint32_t GuardLongJumpTargetCount; /**< 0x74 */
1101 uint32_t DynamicValueRelocTable; /**< 0x78 */
1102 uint32_t CHPEMetadataPointer; /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
1103 uint32_t GuardRFFailureRoutine; /**< 0x80 */
1104 uint32_t GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
1105 uint32_t DynamicValueRelocTableOffset; /**< 0x88 */
1106 uint16_t DynamicValueRelocTableSection; /**< 0x8c */
1107 uint16_t Reserved2; /**< 0x8e */
1108 uint32_t GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
1109 uint32_t HotPatchTableOffset; /**< 0x94 */
1110} IMAGE_LOAD_CONFIG_DIRECTORY32_V8;
1111AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V8, 0x98);
1112typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
1113typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
1114
1115/** @since Windows 10 build 16237 (or maybe earlier). */
1116typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V9
1117{
1118 uint32_t Size; /**< 0x00 */
1119 uint32_t TimeDateStamp; /**< 0x04 */
1120 uint16_t MajorVersion; /**< 0x08 */
1121 uint16_t MinorVersion; /**< 0x0a */
1122 uint32_t GlobalFlagsClear; /**< 0x0c */
1123 uint32_t GlobalFlagsSet; /**< 0x10 */
1124 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1125 uint32_t DeCommitFreeBlockThreshold; /**< 0x18 */
1126 uint32_t DeCommitTotalFreeThreshold; /**< 0x1c */
1127 uint32_t LockPrefixTable; /**< 0x20 */
1128 uint32_t MaximumAllocationSize; /**< 0x24 */
1129 uint32_t VirtualMemoryThreshold; /**< 0x28 */
1130 uint32_t ProcessHeapFlags; /**< 0x2c */
1131 uint32_t ProcessAffinityMask; /**< 0x30 */
1132 uint16_t CSDVersion; /**< 0x34 */
1133 uint16_t DependentLoadFlags; /**< 0x36 */
1134 uint32_t EditList; /**< 0x38 */
1135 uint32_t SecurityCookie; /**< 0x3c */
1136 uint32_t SEHandlerTable; /**< 0x40 */
1137 uint32_t SEHandlerCount; /**< 0x44 */
1138 uint32_t GuardCFCCheckFunctionPointer; /**< 0x48 */
1139 uint32_t GuardCFDispatchFunctionPointer; /**< 0x4c */
1140 uint32_t GuardCFFunctionTable; /**< 0x50 */
1141 uint32_t GuardCFFunctionCount; /**< 0x54 */
1142 uint32_t GuardFlags; /**< 0x58 */
1143 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
1144 uint32_t GuardAddressTakenIatEntryTable; /**< 0x68 */
1145 uint32_t GuardAddressTakenIatEntryCount; /**< 0x6c */
1146 uint32_t GuardLongJumpTargetTable; /**< 0x70 */
1147 uint32_t GuardLongJumpTargetCount; /**< 0x74 */
1148 uint32_t DynamicValueRelocTable; /**< 0x78 */
1149 uint32_t CHPEMetadataPointer; /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
1150 uint32_t GuardRFFailureRoutine; /**< 0x80 */
1151 uint32_t GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
1152 uint32_t DynamicValueRelocTableOffset; /**< 0x88 */
1153 uint16_t DynamicValueRelocTableSection; /**< 0x8c */
1154 uint16_t Reserved2; /**< 0x8e */
1155 uint32_t GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
1156 uint32_t HotPatchTableOffset; /**< 0x94 */
1157 uint32_t AddressOfSomeUnicodeString; /**< 0x98 - 64-bit version has this member about here. not sure about location yet. */
1158 uint32_t Reserved3QuestionMark; /**< 0x9a - Did they 8-byte pad the structure or is AddressOfSomeUnicodeString 64-bit? */
1159} IMAGE_LOAD_CONFIG_DIRECTORY32_V9;
1160AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V9, 0xa0);
1161typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V9;
1162typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V9;
1163
1164typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 IMAGE_LOAD_CONFIG_DIRECTORY32;
1165typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V9 PIMAGE_LOAD_CONFIG_DIRECTORY32;
1166typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V9 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
1167
1168
1169/* No _IMAGE_LOAD_CONFIG_DIRECTORY64_V1 exists. */
1170
1171typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V2
1172{
1173 uint32_t Size;
1174 uint32_t TimeDateStamp;
1175 uint16_t MajorVersion;
1176 uint16_t MinorVersion;
1177 uint32_t GlobalFlagsClear;
1178 uint32_t GlobalFlagsSet;
1179 uint32_t CriticalSectionDefaultTimeout;
1180 uint64_t DeCommitFreeBlockThreshold;
1181 uint64_t DeCommitTotalFreeThreshold;
1182 uint64_t LockPrefixTable;
1183 uint64_t MaximumAllocationSize;
1184 uint64_t VirtualMemoryThreshold;
1185 uint64_t ProcessAffinityMask;
1186 uint32_t ProcessHeapFlags;
1187 uint16_t CSDVersion;
1188 uint16_t DependentLoadFlags;
1189 uint64_t EditList;
1190 uint64_t SecurityCookie;
1191 uint64_t SEHandlerTable;
1192 uint64_t SEHandlerCount;
1193} IMAGE_LOAD_CONFIG_DIRECTORY64_V2;
1194AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V2, 0x70);
1195typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V2;
1196typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V2;
1197
1198#pragma pack(4) /* Why not 8 byte alignment, baka microsofties?!? */
1199typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V3
1200{
1201 uint32_t Size;
1202 uint32_t TimeDateStamp;
1203 uint16_t MajorVersion;
1204 uint16_t MinorVersion;
1205 uint32_t GlobalFlagsClear;
1206 uint32_t GlobalFlagsSet;
1207 uint32_t CriticalSectionDefaultTimeout;
1208 uint64_t DeCommitFreeBlockThreshold;
1209 uint64_t DeCommitTotalFreeThreshold;
1210 uint64_t LockPrefixTable;
1211 uint64_t MaximumAllocationSize;
1212 uint64_t VirtualMemoryThreshold;
1213 uint64_t ProcessAffinityMask;
1214 uint32_t ProcessHeapFlags;
1215 uint16_t CSDVersion;
1216 uint16_t DependentLoadFlags;
1217 uint64_t EditList;
1218 uint64_t SecurityCookie;
1219 uint64_t SEHandlerTable;
1220 uint64_t SEHandlerCount;
1221 uint64_t GuardCFCCheckFunctionPointer;
1222 uint64_t GuardCFDispatchFunctionPointer;
1223 uint64_t GuardCFFunctionTable;
1224 uint64_t GuardCFFunctionCount;
1225 uint32_t GuardFlags;
1226} IMAGE_LOAD_CONFIG_DIRECTORY64_V3;
1227#pragma pack()
1228AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V3, 0x94);
1229typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V3;
1230typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V3;
1231
1232/** @since Windows 10 (Preview (9879). */
1233typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V4
1234{
1235 uint32_t Size; /**< 0x00 */
1236 uint32_t TimeDateStamp; /**< 0x04 */
1237 uint16_t MajorVersion; /**< 0x08 */
1238 uint16_t MinorVersion; /**< 0x0a */
1239 uint32_t GlobalFlagsClear; /**< 0x0c */
1240 uint32_t GlobalFlagsSet; /**< 0x10 */
1241 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1242 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1243 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1244 uint64_t LockPrefixTable; /**< 0x28 */
1245 uint64_t MaximumAllocationSize; /**< 0x30 */
1246 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1247 uint64_t ProcessAffinityMask; /**< 0x40 */
1248 uint32_t ProcessHeapFlags; /**< 0x48 */
1249 uint16_t CSDVersion; /**< 0x4c */
1250 uint16_t DependentLoadFlags; /**< 0x4e */
1251 uint64_t EditList; /**< 0x50 */
1252 uint64_t SecurityCookie; /**< 0x58 */
1253 uint64_t SEHandlerTable; /**< 0x60 */
1254 uint64_t SEHandlerCount; /**< 0x68 */
1255 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1256 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1257 uint64_t GuardCFFunctionTable; /**< 0x80 */
1258 uint64_t GuardCFFunctionCount; /**< 0x88 */
1259 uint32_t GuardFlags; /**< 0x90 */
1260 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1261} IMAGE_LOAD_CONFIG_DIRECTORY64_V4;
1262AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V4, 0xa0);
1263typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
1264typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
1265
1266/** @since Windows 10 build 14286 (or maybe earlier). */
1267typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V5
1268{
1269 uint32_t Size; /**< 0x00 */
1270 uint32_t TimeDateStamp; /**< 0x04 */
1271 uint16_t MajorVersion; /**< 0x08 */
1272 uint16_t MinorVersion; /**< 0x0a */
1273 uint32_t GlobalFlagsClear; /**< 0x0c */
1274 uint32_t GlobalFlagsSet; /**< 0x10 */
1275 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1276 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1277 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1278 uint64_t LockPrefixTable; /**< 0x28 */
1279 uint64_t MaximumAllocationSize; /**< 0x30 */
1280 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1281 uint64_t ProcessAffinityMask; /**< 0x40 */
1282 uint32_t ProcessHeapFlags; /**< 0x48 */
1283 uint16_t CSDVersion; /**< 0x4c */
1284 uint16_t DependentLoadFlags; /**< 0x4e */
1285 uint64_t EditList; /**< 0x50 */
1286 uint64_t SecurityCookie; /**< 0x58 */
1287 uint64_t SEHandlerTable; /**< 0x60 */
1288 uint64_t SEHandlerCount; /**< 0x68 */
1289 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1290 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1291 uint64_t GuardCFFunctionTable; /**< 0x80 */
1292 uint64_t GuardCFFunctionCount; /**< 0x88 */
1293 uint32_t GuardFlags; /**< 0x90 */
1294 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1295 uint64_t GuardAddressTakenIatEntryTable; /**< 0xa0 */
1296 uint64_t GuardAddressTakenIatEntryCount; /**< 0xa8 */
1297 uint64_t GuardLongJumpTargetTable; /**< 0xb0 */
1298 uint64_t GuardLongJumpTargetCount; /**< 0xb8 */
1299} IMAGE_LOAD_CONFIG_DIRECTORY64_V5;
1300AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V5, 0xc0);
1301typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V5;
1302typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5;
1303
1304/** @since Windows 10 build 14393 (or maybe earlier). */
1305typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V6
1306{
1307 uint32_t Size; /**< 0x00 */
1308 uint32_t TimeDateStamp; /**< 0x04 */
1309 uint16_t MajorVersion; /**< 0x08 */
1310 uint16_t MinorVersion; /**< 0x0a */
1311 uint32_t GlobalFlagsClear; /**< 0x0c */
1312 uint32_t GlobalFlagsSet; /**< 0x10 */
1313 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1314 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1315 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1316 uint64_t LockPrefixTable; /**< 0x28 */
1317 uint64_t MaximumAllocationSize; /**< 0x30 */
1318 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1319 uint64_t ProcessAffinityMask; /**< 0x40 */
1320 uint32_t ProcessHeapFlags; /**< 0x48 */
1321 uint16_t CSDVersion; /**< 0x4c */
1322 uint16_t DependentLoadFlags; /**< 0x4e */
1323 uint64_t EditList; /**< 0x50 */
1324 uint64_t SecurityCookie; /**< 0x58 */
1325 uint64_t SEHandlerTable; /**< 0x60 */
1326 uint64_t SEHandlerCount; /**< 0x68 */
1327 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1328 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1329 uint64_t GuardCFFunctionTable; /**< 0x80 */
1330 uint64_t GuardCFFunctionCount; /**< 0x88 */
1331 uint32_t GuardFlags; /**< 0x90 */
1332 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1333 uint64_t GuardAddressTakenIatEntryTable; /**< 0xa0 */
1334 uint64_t GuardAddressTakenIatEntryCount; /**< 0xa8 */
1335 uint64_t GuardLongJumpTargetTable; /**< 0xb0 */
1336 uint64_t GuardLongJumpTargetCount; /**< 0xb8 */
1337 uint64_t DynamicValueRelocTable; /**< 0xc0 */
1338 uint64_t HybridMetadataPointer; /**< 0xc8 */
1339} IMAGE_LOAD_CONFIG_DIRECTORY64_V6;
1340AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V6, 0xd0);
1341typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V6;
1342typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V6;
1343
1344/** @since Windows 10 build 14901 (or maybe earlier). */
1345typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V7
1346{
1347 uint32_t Size; /**< 0x00 */
1348 uint32_t TimeDateStamp; /**< 0x04 */
1349 uint16_t MajorVersion; /**< 0x08 */
1350 uint16_t MinorVersion; /**< 0x0a */
1351 uint32_t GlobalFlagsClear; /**< 0x0c */
1352 uint32_t GlobalFlagsSet; /**< 0x10 */
1353 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1354 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1355 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1356 uint64_t LockPrefixTable; /**< 0x28 */
1357 uint64_t MaximumAllocationSize; /**< 0x30 */
1358 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1359 uint64_t ProcessAffinityMask; /**< 0x40 */
1360 uint32_t ProcessHeapFlags; /**< 0x48 */
1361 uint16_t CSDVersion; /**< 0x4c */
1362 uint16_t DependentLoadFlags; /**< 0x4e */
1363 uint64_t EditList; /**< 0x50 */
1364 uint64_t SecurityCookie; /**< 0x58 */
1365 uint64_t SEHandlerTable; /**< 0x60 */
1366 uint64_t SEHandlerCount; /**< 0x68 */
1367 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1368 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1369 uint64_t GuardCFFunctionTable; /**< 0x80 */
1370 uint64_t GuardCFFunctionCount; /**< 0x88 */
1371 uint32_t GuardFlags; /**< 0x90 */
1372 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1373 uint64_t GuardAddressTakenIatEntryTable; /**< 0xa0 */
1374 uint64_t GuardAddressTakenIatEntryCount; /**< 0xa8 */
1375 uint64_t GuardLongJumpTargetTable; /**< 0xb0 */
1376 uint64_t GuardLongJumpTargetCount; /**< 0xb8 */
1377 uint64_t DynamicValueRelocTable; /**< 0xc0 */
1378 uint64_t CHPEMetadataPointer; /**< 0xc8 Not sure when this was renamed from HybridMetadataPointer. */
1379 uint64_t GuardRFFailureRoutine; /**< 0xd0 */
1380 uint64_t GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
1381 uint32_t DynamicValueRelocTableOffset; /**< 0xe0 */
1382 uint16_t DynamicValueRelocTableSection; /**< 0xe4 */
1383 uint16_t Reserved2; /**< 0xe6 */
1384} IMAGE_LOAD_CONFIG_DIRECTORY64_V7;
1385AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V7, 0xe8);
1386typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
1387typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
1388
1389/** @since Windows 10 build 15002 (or maybe earlier). */
1390#pragma pack(4) /* Stupid, stupid microsofties! */
1391typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V8
1392{
1393 uint32_t Size; /**< 0x00 */
1394 uint32_t TimeDateStamp; /**< 0x04 */
1395 uint16_t MajorVersion; /**< 0x08 */
1396 uint16_t MinorVersion; /**< 0x0a */
1397 uint32_t GlobalFlagsClear; /**< 0x0c */
1398 uint32_t GlobalFlagsSet; /**< 0x10 */
1399 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1400 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1401 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1402 uint64_t LockPrefixTable; /**< 0x28 */
1403 uint64_t MaximumAllocationSize; /**< 0x30 */
1404 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1405 uint64_t ProcessAffinityMask; /**< 0x40 */
1406 uint32_t ProcessHeapFlags; /**< 0x48 */
1407 uint16_t CSDVersion; /**< 0x4c */
1408 uint16_t DependentLoadFlags; /**< 0x4e */
1409 uint64_t EditList; /**< 0x50 */
1410 uint64_t SecurityCookie; /**< 0x58 */
1411 uint64_t SEHandlerTable; /**< 0x60 */
1412 uint64_t SEHandlerCount; /**< 0x68 */
1413 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1414 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1415 uint64_t GuardCFFunctionTable; /**< 0x80 */
1416 uint64_t GuardCFFunctionCount; /**< 0x88 */
1417 uint32_t GuardFlags; /**< 0x90 */
1418 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1419 uint64_t GuardAddressTakenIatEntryTable; /**< 0xa0 */
1420 uint64_t GuardAddressTakenIatEntryCount; /**< 0xa8 */
1421 uint64_t GuardLongJumpTargetTable; /**< 0xb0 */
1422 uint64_t GuardLongJumpTargetCount; /**< 0xb8 */
1423 uint64_t DynamicValueRelocTable; /**< 0xc0 */
1424 uint64_t CHPEMetadataPointer; /**< 0xc8 */
1425 uint64_t GuardRFFailureRoutine; /**< 0xd0 */
1426 uint64_t GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
1427 uint32_t DynamicValueRelocTableOffset; /**< 0xe0 */
1428 uint16_t DynamicValueRelocTableSection; /**< 0xe4 */
1429 uint16_t Reserved2; /**< 0xe6 */
1430 uint64_t GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
1431 uint32_t HotPatchTableOffset; /**< 0xf0 */
1432} IMAGE_LOAD_CONFIG_DIRECTORY64_V8;
1433#pragma pack()
1434AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V8, 0xf4);
1435typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
1436typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
1437
1438/** @since Windows 10 build 15002 (or maybe earlier). */
1439typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V9
1440{
1441 uint32_t Size; /**< 0x00 */
1442 uint32_t TimeDateStamp; /**< 0x04 */
1443 uint16_t MajorVersion; /**< 0x08 */
1444 uint16_t MinorVersion; /**< 0x0a */
1445 uint32_t GlobalFlagsClear; /**< 0x0c */
1446 uint32_t GlobalFlagsSet; /**< 0x10 */
1447 uint32_t CriticalSectionDefaultTimeout; /**< 0x14 */
1448 uint64_t DeCommitFreeBlockThreshold; /**< 0x18 */
1449 uint64_t DeCommitTotalFreeThreshold; /**< 0x20 */
1450 uint64_t LockPrefixTable; /**< 0x28 */
1451 uint64_t MaximumAllocationSize; /**< 0x30 */
1452 uint64_t VirtualMemoryThreshold; /**< 0x38 */
1453 uint64_t ProcessAffinityMask; /**< 0x40 */
1454 uint32_t ProcessHeapFlags; /**< 0x48 */
1455 uint16_t CSDVersion; /**< 0x4c */
1456 uint16_t DependentLoadFlags; /**< 0x4e */
1457 uint64_t EditList; /**< 0x50 */
1458 uint64_t SecurityCookie; /**< 0x58 */
1459 uint64_t SEHandlerTable; /**< 0x60 */
1460 uint64_t SEHandlerCount; /**< 0x68 */
1461 uint64_t GuardCFCCheckFunctionPointer; /**< 0x70 */
1462 uint64_t GuardCFDispatchFunctionPointer; /**< 0x78 */
1463 uint64_t GuardCFFunctionTable; /**< 0x80 */
1464 uint64_t GuardCFFunctionCount; /**< 0x88 */
1465 uint32_t GuardFlags; /**< 0x90 */
1466 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
1467 uint64_t GuardAddressTakenIatEntryTable; /**< 0xa0 */
1468 uint64_t GuardAddressTakenIatEntryCount; /**< 0xa8 */
1469 uint64_t GuardLongJumpTargetTable; /**< 0xb0 */
1470 uint64_t GuardLongJumpTargetCount; /**< 0xb8 */
1471 uint64_t DynamicValueRelocTable; /**< 0xc0 */
1472 uint64_t CHPEMetadataPointer; /**< 0xc8 */
1473 uint64_t GuardRFFailureRoutine; /**< 0xd0 */
1474 uint64_t GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
1475 uint32_t DynamicValueRelocTableOffset; /**< 0xe0 */
1476 uint16_t DynamicValueRelocTableSection; /**< 0xe4 */
1477 uint16_t Reserved2; /**< 0xe6 */
1478 uint64_t GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
1479 uint32_t HotPatchTableOffset; /**< 0xf0 */
1480 uint32_t Reserved3; /**< 0xf4 */
1481 uint64_t AddressOfSomeUnicodeString; /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
1482} IMAGE_LOAD_CONFIG_DIRECTORY64_V9;
1483AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V9, 0x100);
1484typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V9;
1485typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V9;
1486
1487typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 IMAGE_LOAD_CONFIG_DIRECTORY64;
1488typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V9 PIMAGE_LOAD_CONFIG_DIRECTORY64;
1489typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V9 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
1490
1491/** @} */
1492
1493
1494/**
1495 * PE certificate directory.
1496 *
1497 * Found in IMAGE_DIRECTORY_ENTRY_SECURITY.
1498 */
1499typedef struct WIN_CERTIFICATE
1500{
1501 uint32_t dwLength;
1502 uint16_t wRevision;
1503 uint16_t wCertificateType;
1504 uint8_t bCertificate[8];
1505} WIN_CERTIFICATE;
1506AssertCompileSize(WIN_CERTIFICATE, 16);
1507typedef WIN_CERTIFICATE *PWIN_CERTIFICATE;
1508typedef WIN_CERTIFICATE const *PCWIN_CERTIFICATE;
1509
1510/** @name WIN_CERT_REVISION_XXX - Certificate data directory revision.
1511 * Used WIN_CERTIFICATE::wRevision found in the IMAGE_DIRECTORY_ENTRY_SECURITY
1512 * data directory.
1513 * @{ */
1514#define WIN_CERT_REVISION_1_0 UINT16_C(0x0100)
1515#define WIN_CERT_REVISION_2_0 UINT16_C(0x0200)
1516/** @} */
1517
1518/** @name WIN_CERT_TYPE_XXX - Signature type.
1519 * Used by WIN_CERTIFICATE::wCertificateType.
1520 * @{ */
1521#define WIN_CERT_TYPE_X509 UINT16_C(1)
1522#define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2)
1523#define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3)
1524#define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4)
1525#define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0)
1526#define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1)
1527/** @} */
1528
1529/** The alignment of the certificate table.
1530 * @remarks Found thru signtool experiments. */
1531#define WIN_CERTIFICATE_ALIGNMENT UINT32_C(8)
1532
1533
1534/**
1535 * Debug directory.
1536 *
1537 * Found in IMAGE_DIRECTORY_ENTRY_DEBUG.
1538 */
1539typedef struct _IMAGE_DEBUG_DIRECTORY
1540{
1541 uint32_t Characteristics;
1542 uint32_t TimeDateStamp;
1543 uint16_t MajorVersion;
1544 uint16_t MinorVersion;
1545 uint32_t Type;
1546 uint32_t SizeOfData;
1547 uint32_t AddressOfRawData;
1548 uint32_t PointerToRawData;
1549} IMAGE_DEBUG_DIRECTORY;
1550AssertCompileSize(IMAGE_DEBUG_DIRECTORY, 28);
1551typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
1552typedef IMAGE_DEBUG_DIRECTORY const *PCIMAGE_DEBUG_DIRECTORY;
1553
1554/** @name IMAGE_DEBUG_TYPE_XXX - Debug format types.
1555 * Used by IMAGE_DEBUG_DIRECTORY::Type.
1556 * @{ */
1557#define IMAGE_DEBUG_TYPE_UNKNOWN UINT32_C(0x00)
1558#define IMAGE_DEBUG_TYPE_COFF UINT32_C(0x01)
1559#define IMAGE_DEBUG_TYPE_CODEVIEW UINT32_C(0x02)
1560#define IMAGE_DEBUG_TYPE_FPO UINT32_C(0x03)
1561#define IMAGE_DEBUG_TYPE_MISC UINT32_C(0x04)
1562#define IMAGE_DEBUG_TYPE_EXCEPTION UINT32_C(0x05)
1563#define IMAGE_DEBUG_TYPE_FIXUP UINT32_C(0x06)
1564#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC UINT32_C(0x07)
1565#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC UINT32_C(0x08)
1566#define IMAGE_DEBUG_TYPE_BORLAND UINT32_C(0x09)
1567#define IMAGE_DEBUG_TYPE_RESERVED10 UINT32_C(0x0a)
1568#define IMAGE_DEBUG_TYPE_CLSID UINT32_C(0x0b)
1569#define IMAGE_DEBUG_TYPE_VC_FEATURE UINT32_C(0x0c)
1570#define IMAGE_DEBUG_TYPE_POGO UINT32_C(0x0d)
1571#define IMAGE_DEBUG_TYPE_ILTCG UINT32_C(0x0e)
1572#define IMAGE_DEBUG_TYPE_MPX UINT32_C(0x0f)
1573#define IMAGE_DEBUG_TYPE_REPRO UINT32_C(0x10)
1574/** @} */
1575
1576/** @name IMAGE_DEBUG_MISC_XXX - Misc debug data type.
1577 * Used by IMAGE_DEBUG_MISC::DataType.
1578 * @{ */
1579#define IMAGE_DEBUG_MISC_EXENAME UINT32_C(1)
1580/** @} */
1581
1582
1583/**
1584 * The format of IMAGE_DEBUG_TYPE_MISC debug info.
1585 */
1586typedef struct _IMAGE_DEBUG_MISC
1587{
1588 uint32_t DataType;
1589 uint32_t Length;
1590 uint8_t Unicode;
1591 uint8_t Reserved[3];
1592 uint8_t Data[1];
1593} IMAGE_DEBUG_MISC;
1594AssertCompileSize(IMAGE_DEBUG_MISC, 16);
1595typedef IMAGE_DEBUG_MISC *PIMAGE_DEBUG_MISC;
1596typedef IMAGE_DEBUG_MISC const *PCIMAGE_DEBUG_MISC;
1597
1598
1599
1600/**
1601 * The header of a .DBG file (NT4).
1602 */
1603typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
1604{
1605 uint16_t Signature; /**< 0x00 */
1606 uint16_t Flags; /**< 0x02 */
1607 uint16_t Machine; /**< 0x04 */
1608 uint16_t Characteristics; /**< 0x06 */
1609 uint32_t TimeDateStamp; /**< 0x08 */
1610 uint32_t CheckSum; /**< 0x0c */
1611 uint32_t ImageBase; /**< 0x10 */
1612 uint32_t SizeOfImage; /**< 0x14 */
1613 uint32_t NumberOfSections; /**< 0x18 */
1614 uint32_t ExportedNamesSize; /**< 0x1c */
1615 uint32_t DebugDirectorySize; /**< 0x20 */
1616 uint32_t SectionAlignment; /**< 0x24 */
1617 uint32_t Reserved[2]; /**< 0x28 */
1618} IMAGE_SEPARATE_DEBUG_HEADER; /* size: 0x30 */
1619AssertCompileSize(IMAGE_SEPARATE_DEBUG_HEADER, 0x30);
1620typedef IMAGE_SEPARATE_DEBUG_HEADER *PIMAGE_SEPARATE_DEBUG_HEADER;
1621typedef IMAGE_SEPARATE_DEBUG_HEADER const *PCIMAGE_SEPARATE_DEBUG_HEADER;
1622
1623/** The signature of a IMAGE_SEPARATE_DEBUG_HEADER. */
1624#define IMAGE_SEPARATE_DEBUG_SIGNATURE UINT16_C(0x4944)
1625
1626
1627/**
1628 * The format of IMAGE_DEBUG_TYPE_COFF debug info.
1629 */
1630typedef struct _IMAGE_COFF_SYMBOLS_HEADER
1631{
1632 uint32_t NumberOfSymbols;
1633 uint32_t LvaToFirstSymbol;
1634 uint32_t NumberOfLinenumbers;
1635 uint32_t LvaToFirstLinenumber;
1636 uint32_t RvaToFirstByteOfCode;
1637 uint32_t RvaToLastByteOfCode;
1638 uint32_t RvaToFirstByteOfData;
1639 uint32_t RvaToLastByteOfData;
1640} IMAGE_COFF_SYMBOLS_HEADER;
1641AssertCompileSize(IMAGE_COFF_SYMBOLS_HEADER, 0x20);
1642typedef IMAGE_COFF_SYMBOLS_HEADER *PIMAGE_COFF_SYMBOLS_HEADER;
1643typedef IMAGE_COFF_SYMBOLS_HEADER const *PCIMAGE_COFF_SYMBOLS_HEADER;
1644
1645
1646/**
1647 * Line number format of IMAGE_DEBUG_TYPE_COFF debug info.
1648 *
1649 * @remarks This has misaligned members.
1650 */
1651#pragma pack(2)
1652typedef struct _IMAGE_LINENUMBER
1653{
1654 union
1655 {
1656 uint32_t VirtualAddress;
1657 uint32_t SymbolTableIndex;
1658 } Type;
1659 uint16_t Linenumber;
1660} IMAGE_LINENUMBER;
1661#pragma pack()
1662AssertCompileSize(IMAGE_LINENUMBER, 6);
1663typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
1664typedef IMAGE_LINENUMBER const *PCIMAGE_LINENUMBER;
1665
1666
1667/** The size of a IMAGE_SYMBOL & IMAGE_AUX_SYMBOL structure. */
1668#define IMAGE_SIZE_OF_SYMBOL 18
1669/** The size of a IMAGE_SYMBOL_EX & IMAGE_AUX_SYMBOL_EX structure. */
1670#define IMAGE_SIZE_OF_SYMBOL_EX 20
1671
1672/**
1673 * COFF symbol.
1674 */
1675#pragma pack(2)
1676typedef struct _IMAGE_SYMBOL
1677{
1678 union
1679 {
1680 uint8_t ShortName[8];
1681 struct
1682 {
1683 uint32_t Short;
1684 uint32_t Long;
1685 } Name;
1686 uint32_t LongName[2];
1687 } N;
1688
1689 uint32_t Value;
1690 int16_t SectionNumber;
1691 uint16_t Type;
1692 uint8_t StorageClass;
1693 uint8_t NumberOfAuxSymbols;
1694} IMAGE_SYMBOL;
1695#pragma pack()
1696AssertCompileSize(IMAGE_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
1697typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
1698typedef IMAGE_SYMBOL const *PCIMAGE_SYMBOL;
1699
1700/**
1701 * COFF auxiliary symbol token defintion (whatever that is).
1702 */
1703#pragma pack(2)
1704typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF
1705{
1706 uint8_t bAuxType;
1707 uint8_t bReserved;
1708 uint32_t SymbolTableIndex;
1709 uint8_t rgbReserved[12];
1710} IMAGE_AUX_SYMBOL_TOKEN_DEF;
1711#pragma pack()
1712AssertCompileSize(IMAGE_AUX_SYMBOL_TOKEN_DEF, IMAGE_SIZE_OF_SYMBOL);
1713typedef IMAGE_AUX_SYMBOL_TOKEN_DEF *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
1714typedef IMAGE_AUX_SYMBOL_TOKEN_DEF const *PCIMAGE_AUX_SYMBOL_TOKEN_DEF;
1715
1716/**
1717 * COFF auxiliary symbol.
1718 */
1719#pragma pack(1)
1720typedef union _IMAGE_AUX_SYMBOL
1721{
1722 struct
1723 {
1724 uint32_t TagIndex;
1725 union
1726 {
1727 struct
1728 {
1729 uint16_t Linenumber;
1730 uint16_t Size;
1731 } LnSz;
1732 } Misc;
1733 union
1734 {
1735 struct
1736 {
1737 uint32_t PointerToLinenumber;
1738 uint32_t PointerToNextFunction;
1739 } Function;
1740 struct
1741 {
1742 uint16_t Dimension[4];
1743 } Array;
1744 } FcnAry;
1745 uint16_t TvIndex;
1746 } Sym;
1747
1748 struct
1749 {
1750 uint8_t Name[IMAGE_SIZE_OF_SYMBOL];
1751 } File;
1752
1753 struct
1754 {
1755 uint32_t Length;
1756 uint16_t NumberOfRelocations;
1757 uint16_t NumberOfLinenumbers;
1758 uint32_t CheckSum;
1759 uint16_t Number;
1760 uint8_t Selection;
1761 uint8_t bReserved;
1762 uint16_t HighNumber;
1763 } Section;
1764
1765 IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
1766 struct
1767 {
1768 uint32_t crc;
1769 uint8_t rgbReserved[14];
1770 } CRC;
1771} IMAGE_AUX_SYMBOL;
1772#pragma pack()
1773AssertCompileSize(IMAGE_AUX_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
1774typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
1775typedef IMAGE_AUX_SYMBOL const *PCIMAGE_AUX_SYMBOL;
1776
1777
1778/**
1779 * Extended COFF symbol.
1780 */
1781typedef struct _IMAGE_SYMBOL_EX
1782{
1783 union
1784 {
1785 uint8_t ShortName[8];
1786 struct
1787 {
1788 uint32_t Short;
1789 uint32_t Long;
1790 } Name;
1791 uint32_t LongName[2];
1792 } N;
1793
1794 uint32_t Value;
1795 int32_t SectionNumber; /* The difference from IMAGE_SYMBOL */
1796 uint16_t Type;
1797 uint8_t StorageClass;
1798 uint8_t NumberOfAuxSymbols;
1799} IMAGE_SYMBOL_EX;
1800AssertCompileSize(IMAGE_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
1801typedef IMAGE_SYMBOL_EX *PIMAGE_SYMBOL_EX;
1802typedef IMAGE_SYMBOL_EX const *PCIMAGE_SYMBOL_EX;
1803
1804/**
1805 * Extended COFF auxiliary symbol.
1806 */
1807typedef union _IMAGE_AUX_SYMBOL_EX
1808{
1809 struct
1810 {
1811 uint32_t WeakDefaultSymIndex;
1812 uint32_t WeakSearchType;
1813 uint8_t rgbReserved[12];
1814 } Sym;
1815
1816 struct
1817 {
1818 uint8_t Name[IMAGE_SIZE_OF_SYMBOL_EX];
1819 } File;
1820
1821 struct
1822 {
1823 uint32_t Length;
1824 uint16_t NumberOfRelocations;
1825 uint16_t NumberOfLinenumbers;
1826 uint32_t CheckSum;
1827 uint16_t Number;
1828 uint8_t Selection;
1829 uint8_t bReserved;
1830 uint16_t HighNumber;
1831 uint8_t rgbReserved[2];
1832 } Section;
1833
1834 IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
1835
1836 struct
1837 {
1838 uint32_t crc;
1839 uint8_t rgbReserved[16];
1840 } CRC;
1841} IMAGE_AUX_SYMBOL_EX;
1842AssertCompileSize(IMAGE_AUX_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
1843typedef IMAGE_AUX_SYMBOL_EX *PIMAGE_AUX_SYMBOL_EX;
1844typedef IMAGE_AUX_SYMBOL_EX const *PCIMAGE_AUX_SYMBOL_EX;
1845
1846/** @name Special COFF section numbers.
1847 * Used by IMAGE_SYMBOL::SectionNumber and IMAGE_SYMBOL_EX::SectionNumber
1848 * @{ */
1849#define IMAGE_SYM_UNDEFINED INT16_C(0)
1850#define IMAGE_SYM_ABSOLUTE INT16_C(-1)
1851#define IMAGE_SYM_DEBUG INT16_C(-2)
1852/** @} */
1853
1854/** @name IMAGE_SYM_CLASS_XXX - COFF symbol storage classes.
1855 * @{ */
1856#define IMAGE_SYM_CLASS_END_OF_FUNCTION UINT8_C(0xff) /* -1 */
1857#define IMAGE_SYM_CLASS_NULL UINT8_C(0)
1858#define IMAGE_SYM_CLASS_AUTOMATIC UINT8_C(1)
1859#define IMAGE_SYM_CLASS_EXTERNAL UINT8_C(2)
1860#define IMAGE_SYM_CLASS_STATIC UINT8_C(3)
1861#define IMAGE_SYM_CLASS_REGISTER UINT8_C(4)
1862#define IMAGE_SYM_CLASS_EXTERNAL_DEF UINT8_C(5)
1863#define IMAGE_SYM_CLASS_LABEL UINT8_C(6)
1864#define IMAGE_SYM_CLASS_UNDEFINED_LABEL UINT8_C(7)
1865#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT UINT8_C(8)
1866#define IMAGE_SYM_CLASS_ARGUMENT UINT8_C(9)
1867#define IMAGE_SYM_CLASS_STRUCT_TAG UINT8_C(10)
1868#define IMAGE_SYM_CLASS_MEMBER_OF_UNION UINT8_C(11)
1869#define IMAGE_SYM_CLASS_UNION_TAG UINT8_C(12)
1870#define IMAGE_SYM_CLASS_TYPE_DEFINITION UINT8_C(13)
1871#define IMAGE_SYM_CLASS_UNDEFINED_STATIC UINT8_C(14)
1872#define IMAGE_SYM_CLASS_ENUM_TAG UINT8_C(15)
1873#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM UINT8_C(16)
1874#define IMAGE_SYM_CLASS_REGISTER_PARAM UINT8_C(17)
1875#define IMAGE_SYM_CLASS_BIT_FIELD UINT8_C(18)
1876#define IMAGE_SYM_CLASS_FAR_EXTERNAL UINT8_C(68)
1877#define IMAGE_SYM_CLASS_BLOCK UINT8_C(100)
1878#define IMAGE_SYM_CLASS_FUNCTION UINT8_C(101)
1879#define IMAGE_SYM_CLASS_END_OF_STRUCT UINT8_C(102)
1880#define IMAGE_SYM_CLASS_FILE UINT8_C(103)
1881#define IMAGE_SYM_CLASS_SECTION UINT8_C(104)
1882#define IMAGE_SYM_CLASS_WEAK_EXTERNAL UINT8_C(105)
1883#define IMAGE_SYM_CLASS_CLR_TOKEN UINT8_C(107)
1884/** @} */
1885
1886/** @name IMAGE_SYM_TYPE_XXX - COFF symbol base types
1887 * @{ */
1888#define IMAGE_SYM_TYPE_NULL UINT16_C(0x0000)
1889#define IMAGE_SYM_TYPE_VOID UINT16_C(0x0001)
1890#define IMAGE_SYM_TYPE_CHAR UINT16_C(0x0002)
1891#define IMAGE_SYM_TYPE_SHORT UINT16_C(0x0003)
1892#define IMAGE_SYM_TYPE_INT UINT16_C(0x0004)
1893#define IMAGE_SYM_TYPE_LONG UINT16_C(0x0005)
1894#define IMAGE_SYM_TYPE_FLOAT UINT16_C(0x0006)
1895#define IMAGE_SYM_TYPE_DOUBLE UINT16_C(0x0007)
1896#define IMAGE_SYM_TYPE_STRUCT UINT16_C(0x0008)
1897#define IMAGE_SYM_TYPE_UNION UINT16_C(0x0009)
1898#define IMAGE_SYM_TYPE_ENUM UINT16_C(0x000a)
1899#define IMAGE_SYM_TYPE_MOE UINT16_C(0x000b)
1900#define IMAGE_SYM_TYPE_BYTE UINT16_C(0x000c)
1901#define IMAGE_SYM_TYPE_WORD UINT16_C(0x000d)
1902#define IMAGE_SYM_TYPE_UINT UINT16_C(0x000e)
1903#define IMAGE_SYM_TYPE_DWORD UINT16_C(0x000f)
1904#define IMAGE_SYM_TYPE_PCODE UINT16_C(0x8000)
1905/** @} */
1906
1907/** @name IMAGE_SYM_DTYPE_XXX - COFF symbol complex types
1908 * @{ */
1909#define IMAGE_SYM_DTYPE_NULL UINT16_C(0x0)
1910#define IMAGE_SYM_DTYPE_POINTER UINT16_C(0x1)
1911#define IMAGE_SYM_DTYPE_FUNCTION UINT16_C(0x2)
1912#define IMAGE_SYM_DTYPE_ARRAY UINT16_C(0x3)
1913/** @} */
1914
1915/** @name COFF Symbol type masks and shift counts.
1916 * @{ */
1917#define N_BTMASK UINT16_C(0x000f)
1918#define N_TMASK UINT16_C(0x0030)
1919#define N_TMASK1 UINT16_C(0x00c0)
1920#define N_TMASK2 UINT16_C(0x00f0)
1921#define N_BTSHFT 4
1922#define N_TSHIFT 2
1923/** @} */
1924
1925/** @name COFF Symbol type macros.
1926 * @{ */
1927#define BTYPE(a_Type) ( (a_Type) & N_BTMASK )
1928#define ISPTR(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) )
1929#define ISFCN(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT) )
1930#define ISARY(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT) )
1931#define ISTAG(a_StorageClass) ( (a_StorageClass) == IMAGE_SYM_CLASS_STRUCT_TAG \
1932 || (a_StorageClass) == IMAGE_SYM_CLASS_UNION_TAG \
1933 || (a_StorageClass) == IMAGE_SYM_CLASS_ENUM_TAG )
1934/** @} */
1935
1936
1937/**
1938 * COFF relocation table entry.
1939 *
1940 * @note The size of the structure is not a multiple of the largest member
1941 * (uint32_t), so odd relocation table entry members will have
1942 * misaligned uint32_t members.
1943 */
1944#pragma pack(1)
1945typedef struct _IMAGE_RELOCATION
1946{
1947 union
1948 {
1949 uint32_t VirtualAddress;
1950 uint32_t RelocCount;
1951 } u;
1952 uint32_t SymbolTableIndex;
1953 uint16_t Type;
1954} IMAGE_RELOCATION;
1955#pragma pack()
1956/** The size of a COFF relocation entry. */
1957#define IMAGE_SIZEOF_RELOCATION 10
1958AssertCompileSize(IMAGE_RELOCATION, IMAGE_SIZEOF_RELOCATION);
1959typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
1960typedef IMAGE_RELOCATION const *PCIMAGE_RELOCATION;
1961
1962
1963/** @name IMAGE_REL_AMD64_XXX - COFF relocations for AMD64 CPUs.
1964 * Used by IMAGE_RELOCATION::Type.
1965 * @{ */
1966#define IMAGE_REL_AMD64_ABSOLUTE UINT16_C(0x0000)
1967#define IMAGE_REL_AMD64_ADDR64 UINT16_C(0x0001)
1968#define IMAGE_REL_AMD64_ADDR32 UINT16_C(0x0002)
1969#define IMAGE_REL_AMD64_ADDR32NB UINT16_C(0x0003)
1970#define IMAGE_REL_AMD64_REL32 UINT16_C(0x0004)
1971#define IMAGE_REL_AMD64_REL32_1 UINT16_C(0x0005)
1972#define IMAGE_REL_AMD64_REL32_2 UINT16_C(0x0006)
1973#define IMAGE_REL_AMD64_REL32_3 UINT16_C(0x0007)
1974#define IMAGE_REL_AMD64_REL32_4 UINT16_C(0x0008)
1975#define IMAGE_REL_AMD64_REL32_5 UINT16_C(0x0009)
1976#define IMAGE_REL_AMD64_SECTION UINT16_C(0x000a)
1977#define IMAGE_REL_AMD64_SECREL UINT16_C(0x000b)
1978#define IMAGE_REL_AMD64_SECREL7 UINT16_C(0x000c)
1979#define IMAGE_REL_AMD64_TOKEN UINT16_C(0x000d)
1980#define IMAGE_REL_AMD64_SREL32 UINT16_C(0x000e)
1981#define IMAGE_REL_AMD64_PAIR UINT16_C(0x000f)
1982#define IMAGE_REL_AMD64_SSPAN32 UINT16_C(0x0010)
1983/** @} */
1984
1985/** @name ARM IMAGE_REL_ARM_XXX - COFF relocations for ARM CPUs.
1986 * Used by IMAGE_RELOCATION::Type.
1987 * @{ */
1988#define IMAGE_REL_ARM_ABSOLUTE UINT16_C(0x0000)
1989#define IMAGE_REL_ARM_ADDR32 UINT16_C(0x0001)
1990#define IMAGE_REL_ARM_ADDR32NB UINT16_C(0x0002)
1991#define IMAGE_REL_ARM_BRANCH24 UINT16_C(0x0003)
1992#define IMAGE_REL_ARM_BRANCH11 UINT16_C(0x0004)
1993#define IMAGE_REL_ARM_TOKEN UINT16_C(0x0005)
1994#define IMAGE_REL_ARM_BLX24 UINT16_C(0x0008)
1995#define IMAGE_REL_ARM_BLX11 UINT16_C(0x0009)
1996#define IMAGE_REL_ARM_SECTION UINT16_C(0x000e)
1997#define IMAGE_REL_ARM_SECREL UINT16_C(0x000f)
1998#define IMAGE_REL_ARM_MOV32A UINT16_C(0x0010)
1999#define IMAGE_REL_ARM_MOV32T UINT16_C(0x0011)
2000#define IMAGE_REL_ARM_BRANCH20T UINT16_C(0x0012)
2001#define IMAGE_REL_ARM_BRANCH24T UINT16_C(0x0014)
2002#define IMAGE_REL_ARM_BLX23T UINT16_C(0x0015)
2003/** @} */
2004
2005/** @name IMAGE_REL_ARM64_XXX - COFF relocations for ARMv8 CPUs (64-bit).
2006 * Used by IMAGE_RELOCATION::Type.
2007 * @{ */
2008#define IMAGE_REL_ARM64_ABSOLUTE UINT16_C(0x0000)
2009#define IMAGE_REL_ARM64_ADDR32 UINT16_C(0x0001)
2010#define IMAGE_REL_ARM64_ADDR32NB UINT16_C(0x0002)
2011#define IMAGE_REL_ARM64_BRANCH26 UINT16_C(0x0003)
2012#define IMAGE_REL_ARM64_PAGEBASE_REL21 UINT16_C(0x0004)
2013#define IMAGE_REL_ARM64_REL21 UINT16_C(0x0005)
2014#define IMAGE_REL_ARM64_PAGEOFFSET_12A UINT16_C(0x0006)
2015#define IMAGE_REL_ARM64_PAGEOFFSET_12L UINT16_C(0x0007)
2016#define IMAGE_REL_ARM64_SECREL UINT16_C(0x0008)
2017#define IMAGE_REL_ARM64_SECREL_LOW12A UINT16_C(0x0009)
2018#define IMAGE_REL_ARM64_SECREL_HIGH12A UINT16_C(0x000a)
2019#define IMAGE_REL_ARM64_SECREL_LOW12L UINT16_C(0x000b)
2020#define IMAGE_REL_ARM64_TOKEN UINT16_C(0x000c)
2021#define IMAGE_REL_ARM64_SECTION UINT16_C(0x000d)
2022#define IMAGE_REL_ARM64_ADDR64 UINT16_C(0x000e)
2023/** @} */
2024
2025/** @name IMAGE_REL_SH3_XXX - COFF relocation for Hitachi SuperH CPUs.
2026 * Used by IMAGE_RELOCATION::Type.
2027 * @{ */
2028#define IMAGE_REL_SH3_ABSOLUTE UINT16_C(0x0000)
2029#define IMAGE_REL_SH3_DIRECT16 UINT16_C(0x0001)
2030#define IMAGE_REL_SH3_DIRECT32 UINT16_C(0x0002)
2031#define IMAGE_REL_SH3_DIRECT8 UINT16_C(0x0003)
2032#define IMAGE_REL_SH3_DIRECT8_WORD UINT16_C(0x0004)
2033#define IMAGE_REL_SH3_DIRECT8_LONG UINT16_C(0x0005)
2034#define IMAGE_REL_SH3_DIRECT4 UINT16_C(0x0006)
2035#define IMAGE_REL_SH3_DIRECT4_WORD UINT16_C(0x0007)
2036#define IMAGE_REL_SH3_DIRECT4_LONG UINT16_C(0x0008)
2037#define IMAGE_REL_SH3_PCREL8_WORD UINT16_C(0x0009)
2038#define IMAGE_REL_SH3_PCREL8_LONG UINT16_C(0x000a)
2039#define IMAGE_REL_SH3_PCREL12_WORD UINT16_C(0x000b)
2040#define IMAGE_REL_SH3_STARTOF_SECTION UINT16_C(0x000c)
2041#define IMAGE_REL_SH3_SIZEOF_SECTION UINT16_C(0x000d)
2042#define IMAGE_REL_SH3_SECTION UINT16_C(0x000e)
2043#define IMAGE_REL_SH3_SECREL UINT16_C(0x000f)
2044#define IMAGE_REL_SH3_DIRECT32_NB UINT16_C(0x0010)
2045#define IMAGE_REL_SH3_GPREL4_LONG UINT16_C(0x0011)
2046#define IMAGE_REL_SH3_TOKEN UINT16_C(0x0012)
2047#define IMAGE_REL_SHM_PCRELPT UINT16_C(0x0013)
2048#define IMAGE_REL_SHM_REFLO UINT16_C(0x0014)
2049#define IMAGE_REL_SHM_REFHALF UINT16_C(0x0015)
2050#define IMAGE_REL_SHM_RELLO UINT16_C(0x0016)
2051#define IMAGE_REL_SHM_RELHALF UINT16_C(0x0017)
2052#define IMAGE_REL_SHM_PAIR UINT16_C(0x0018)
2053#define IMAGE_REL_SHM_NOMODE UINT16_C(0x8000)
2054/** @} */
2055
2056/** @name IMAGE_REL_PPC_XXX - COFF relocations for IBM PowerPC CPUs.
2057 * Used by IMAGE_RELOCATION::Type.
2058 * @{ */
2059#define IMAGE_REL_PPC_ABSOLUTE UINT16_C(0x0000)
2060#define IMAGE_REL_PPC_ADDR64 UINT16_C(0x0001)
2061#define IMAGE_REL_PPC_ADDR32 UINT16_C(0x0002)
2062#define IMAGE_REL_PPC_ADDR24 UINT16_C(0x0003)
2063#define IMAGE_REL_PPC_ADDR16 UINT16_C(0x0004)
2064#define IMAGE_REL_PPC_ADDR14 UINT16_C(0x0005)
2065#define IMAGE_REL_PPC_REL24 UINT16_C(0x0006)
2066#define IMAGE_REL_PPC_REL14 UINT16_C(0x0007)
2067#define IMAGE_REL_PPC_ADDR32NB UINT16_C(0x000a)
2068#define IMAGE_REL_PPC_SECREL UINT16_C(0x000b)
2069#define IMAGE_REL_PPC_SECTION UINT16_C(0x000c)
2070#define IMAGE_REL_PPC_SECREL16 UINT16_C(0x000f)
2071#define IMAGE_REL_PPC_REFHI UINT16_C(0x0010)
2072#define IMAGE_REL_PPC_REFLO UINT16_C(0x0011)
2073#define IMAGE_REL_PPC_PAIR UINT16_C(0x0012)
2074#define IMAGE_REL_PPC_SECRELLO UINT16_C(0x0013)
2075#define IMAGE_REL_PPC_GPREL UINT16_C(0x0015)
2076#define IMAGE_REL_PPC_TOKEN UINT16_C(0x0016)
2077/** @} */
2078
2079/** @name IMAGE_REL_I386_XXX - COFF relocations for x86 CPUs.
2080 * Used by IMAGE_RELOCATION::Type.
2081 * @{ */
2082#define IMAGE_REL_I386_ABSOLUTE UINT16_C(0x0000)
2083#define IMAGE_REL_I386_DIR16 UINT16_C(0x0001)
2084#define IMAGE_REL_I386_REL16 UINT16_C(0x0002)
2085#define IMAGE_REL_I386_DIR32 UINT16_C(0x0006)
2086#define IMAGE_REL_I386_DIR32NB UINT16_C(0x0007)
2087#define IMAGE_REL_I386_SEG12 UINT16_C(0x0009)
2088#define IMAGE_REL_I386_SECTION UINT16_C(0x000A)
2089#define IMAGE_REL_I386_SECREL UINT16_C(0x000B)
2090#define IMAGE_REL_I386_TOKEN UINT16_C(0x000C)
2091#define IMAGE_REL_I386_SECREL7 UINT16_C(0x000D)
2092#define IMAGE_REL_I386_REL32 UINT16_C(0x0014)
2093/** @} */
2094
2095/** @name IMAGE_REL_IA64_XXX - COFF relocations for "Itanic" CPUs.
2096 * @{ */
2097#define IMAGE_REL_IA64_ABSOLUTE UINT16_C(0x0000)
2098#define IMAGE_REL_IA64_IMM14 UINT16_C(0x0001)
2099#define IMAGE_REL_IA64_IMM22 UINT16_C(0x0002)
2100#define IMAGE_REL_IA64_IMM64 UINT16_C(0x0003)
2101#define IMAGE_REL_IA64_DIR32 UINT16_C(0x0004)
2102#define IMAGE_REL_IA64_DIR64 UINT16_C(0x0005)
2103#define IMAGE_REL_IA64_PCREL21B UINT16_C(0x0006)
2104#define IMAGE_REL_IA64_PCREL21M UINT16_C(0x0007)
2105#define IMAGE_REL_IA64_PCREL21F UINT16_C(0x0008)
2106#define IMAGE_REL_IA64_GPREL22 UINT16_C(0x0009)
2107#define IMAGE_REL_IA64_LTOFF22 UINT16_C(0x000a)
2108#define IMAGE_REL_IA64_SECTION UINT16_C(0x000b)
2109#define IMAGE_REL_IA64_SECREL22 UINT16_C(0x000c)
2110#define IMAGE_REL_IA64_SECREL64I UINT16_C(0x000d)
2111#define IMAGE_REL_IA64_SECREL32 UINT16_C(0x000e)
2112#define IMAGE_REL_IA64_DIR32NB UINT16_C(0x0010)
2113#define IMAGE_REL_IA64_SREL14 UINT16_C(0x0011)
2114#define IMAGE_REL_IA64_SREL22 UINT16_C(0x0012)
2115#define IMAGE_REL_IA64_SREL32 UINT16_C(0x0013)
2116#define IMAGE_REL_IA64_UREL32 UINT16_C(0x0014)
2117#define IMAGE_REL_IA64_PCREL60X UINT16_C(0x0015)
2118#define IMAGE_REL_IA64_PCREL60B UINT16_C(0x0016)
2119#define IMAGE_REL_IA64_PCREL60F UINT16_C(0x0017)
2120#define IMAGE_REL_IA64_PCREL60I UINT16_C(0x0018)
2121#define IMAGE_REL_IA64_PCREL60M UINT16_C(0x0019)
2122#define IMAGE_REL_IA64_IMMGPREL64 UINT16_C(0x001a)
2123#define IMAGE_REL_IA64_TOKEN UINT16_C(0x001b)
2124#define IMAGE_REL_IA64_GPREL32 UINT16_C(0x001c)
2125#define IMAGE_REL_IA64_ADDEND UINT16_C(0x001f)
2126/** @} */
2127
2128/** @name IMAGE_REL_MIPS_XXX - COFF relocations for MIPS CPUs.
2129 * Used by IMAGE_RELOCATION::Type.
2130 * @{ */
2131#define IMAGE_REL_MIPS_ABSOLUTE UINT16_C(0x0000)
2132#define IMAGE_REL_MIPS_REFHALF UINT16_C(0x0001)
2133#define IMAGE_REL_MIPS_REFWORD UINT16_C(0x0002)
2134#define IMAGE_REL_MIPS_JMPADDR UINT16_C(0x0003)
2135#define IMAGE_REL_MIPS_REFHI UINT16_C(0x0004)
2136#define IMAGE_REL_MIPS_REFLO UINT16_C(0x0005)
2137#define IMAGE_REL_MIPS_GPREL UINT16_C(0x0006)
2138#define IMAGE_REL_MIPS_LITERAL UINT16_C(0x0007)
2139#define IMAGE_REL_MIPS_SECTION UINT16_C(0x000a)
2140#define IMAGE_REL_MIPS_SECREL UINT16_C(0x000b)
2141#define IMAGE_REL_MIPS_SECRELLO UINT16_C(0x000c)
2142#define IMAGE_REL_MIPS_SECRELHI UINT16_C(0x000d)
2143#define IMAGE_REL_MIPS_JMPADDR16 UINT16_C(0x0010)
2144#define IMAGE_REL_MIPS_REFWORDNB UINT16_C(0x0022)
2145#define IMAGE_REL_MIPS_PAIR UINT16_C(0x0025)
2146/** @} */
2147
2148/** @name IMAGE_REL_M32R_XXX - COFF relocations for Mitsubishi M32R CPUs.
2149 * Used by IMAGE_RELOCATION::Type.
2150 * @{ */
2151#define IMAGE_REL_M32R_ABSOLUTE UINT16_C(0x0000)
2152#define IMAGE_REL_M32R_ADDR32 UINT16_C(0x0001)
2153#define IMAGE_REL_M32R_ADDR32NB UINT16_C(0x0002)
2154#define IMAGE_REL_M32R_ADDR24 UINT16_C(0x0003)
2155#define IMAGE_REL_M32R_GPREL16 UINT16_C(0x0004)
2156#define IMAGE_REL_M32R_PCREL24 UINT16_C(0x0005)
2157#define IMAGE_REL_M32R_PCREL16 UINT16_C(0x0006)
2158#define IMAGE_REL_M32R_PCREL8 UINT16_C(0x0007)
2159#define IMAGE_REL_M32R_REFHALF UINT16_C(0x0008)
2160#define IMAGE_REL_M32R_REFHI UINT16_C(0x0009)
2161#define IMAGE_REL_M32R_REFLO UINT16_C(0x000a)
2162#define IMAGE_REL_M32R_PAIR UINT16_C(0x000b)
2163#define IMAGE_REL_M32R_SECTION UINT16_C(0x000c)
2164#define IMAGE_REL_M32R_SECREL UINT16_C(0x000d)
2165#define IMAGE_REL_M32R_TOKEN UINT16_C(0x000e)
2166/** @} */
2167
2168
2169/** @} */
2170
2171#endif /* !IPRT_INCLUDED_formats_pecoff_h */
2172
Note: See TracBrowser for help on using the repository browser.

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