VirtualBox

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

Last change on this file since 58654 was 58654, checked in by vboxsync, 9 years ago

include/iprt/formats/pecoff.h: Copied from Runtime/include/internal/ldrPE.h and documented the thing, adding some missing COFF stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 54.0 KB
Line 
1/* $Id: pecoff.h 58654 2015-11-11 00:21:36Z vboxsync $ */
2/** @file
3 * IPRT - Windows NT PE & COFF Structures and Constants.
4 */
5
6/*
7 * Copyright (C) 2006-2015 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_formats_pecoff_h
28#define ___iprt_formats_pecoff_h
29
30#include <iprt/types.h>
31#include <iprt/assert.h>
32
33
34/** @defgroup grp_rt_formats_pecoff PE & Microsoft COFF structurs and definitions
35 * @ingroup grp_rt_formats
36 * @{
37 */
38
39
40/**
41 * PE & COFF file header.
42 *
43 * This starts COFF files, while in PE files it's preceeded by the PE signature
44 * (see IMAGE_NT_HEADERS32, IMAGE_NT_HEADERS64).
45 */
46typedef struct _IMAGE_FILE_HEADER
47{
48 uint16_t Machine; /**< 0x00 */
49 uint16_t NumberOfSections; /**< 0x02 */
50 uint32_t TimeDateStamp; /**< 0x04 */
51 uint32_t PointerToSymbolTable; /**< 0x08 */
52 uint32_t NumberOfSymbols; /**< 0x0c */
53 uint16_t SizeOfOptionalHeader; /**< 0x10 */
54 uint16_t Characteristics; /**< 0x12 */
55} IMAGE_FILE_HEADER; /* size: 0x14 */
56AssertCompileSize(IMAGE_FILE_HEADER, 0x14);
57typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
58typedef IMAGE_FILE_HEADER const *PCIMAGE_FILE_HEADER;
59
60
61/** @name PE & COFF machine types.
62 * Used by IMAGE_FILE_HEADER::Machine and IMAGE_SEPARATE_DEBUG_HEADER::Machine.
63 * @{ */
64#define IMAGE_FILE_MACHINE_I386 UINT16_C(0x014c)
65#define IMAGE_FILE_MACHINE_AMD64 UINT16_C(0x8664)
66/** @} */
67
68/** @name File header characteristics (IMAGE_FILE_HEADER::Characteristics)
69 * @{ */
70#define IMAGE_FILE_RELOCS_STRIPPED UINT16_C(0x0001)
71#define IMAGE_FILE_EXECUTABLE_IMAGE UINT16_C(0x0002)
72#define IMAGE_FILE_LINE_NUMS_STRIPPED UINT16_C(0x0004)
73#define IMAGE_FILE_LOCAL_SYMS_STRIPPED UINT16_C(0x0008)
74#define IMAGE_FILE_AGGRESIVE_WS_TRIM UINT16_C(0x0010)
75#define IMAGE_FILE_LARGE_ADDRESS_AWARE UINT16_C(0x0020)
76#define IMAGE_FILE_16BIT_MACHINE UINT16_C(0x0040)
77#define IMAGE_FILE_BYTES_REVERSED_LO UINT16_C(0x0080)
78#define IMAGE_FILE_32BIT_MACHINE UINT16_C(0x0100)
79#define IMAGE_FILE_DEBUG_STRIPPED UINT16_C(0x0200)
80#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP UINT16_C(0x0400)
81#define IMAGE_FILE_NET_RUN_FROM_SWAP UINT16_C(0x0800)
82#define IMAGE_FILE_SYSTEM UINT16_C(0x1000)
83#define IMAGE_FILE_DLL UINT16_C(0x2000)
84#define IMAGE_FILE_UP_SYSTEM_ONLY UINT16_C(0x4000)
85#define IMAGE_FILE_BYTES_REVERSED_HI UINT16_C(0x8000)
86/** @} */
87
88
89/**
90 * PE data directory.
91 *
92 * This is used to locate data in the loaded image so the dynamic linker or
93 * others can make use of it. However, in the case of
94 * IMAGE_DIRECTORY_ENTRY_SECURITY it is referring to raw file offsets.
95 */
96typedef struct _IMAGE_DATA_DIRECTORY
97{
98 uint32_t VirtualAddress;
99 uint32_t Size;
100} IMAGE_DATA_DIRECTORY;
101AssertCompileSize(IMAGE_DATA_DIRECTORY, 0x8);
102typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
103typedef IMAGE_DATA_DIRECTORY const *PCIMAGE_DATA_DIRECTORY;
104
105/** The standard number of data directories in the optional header.
106 * I.e. the dimensions of IMAGE_OPTIONAL_HEADER32::DataDirectory and
107 * IMAGE_OPTIONAL_HEADER64::DataDirectory.
108 */
109#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 0x10
110
111
112/**
113 * PE optional header, 32-bit version.
114 */
115typedef struct _IMAGE_OPTIONAL_HEADER32
116{
117 uint16_t Magic; /**< 0x00 */
118 uint8_t MajorLinkerVersion; /**< 0x02 */
119 uint8_t MinorLinkerVersion; /**< 0x03 */
120 uint32_t SizeOfCode; /**< 0x04 */
121 uint32_t SizeOfInitializedData; /**< 0x08 */
122 uint32_t SizeOfUninitializedData; /**< 0x0c */
123 uint32_t AddressOfEntryPoint; /**< 0x10 */
124 uint32_t BaseOfCode; /**< 0x14 */
125 uint32_t BaseOfData; /**< 0x18 */
126 uint32_t ImageBase; /**< 0x1c */
127 uint32_t SectionAlignment; /**< 0x20 */
128 uint32_t FileAlignment; /**< 0x24 */
129 uint16_t MajorOperatingSystemVersion; /**< 0x28 */
130 uint16_t MinorOperatingSystemVersion; /**< 0x2a */
131 uint16_t MajorImageVersion; /**< 0x2c */
132 uint16_t MinorImageVersion; /**< 0x2e */
133 uint16_t MajorSubsystemVersion; /**< 0x30 */
134 uint16_t MinorSubsystemVersion; /**< 0x32 */
135 uint32_t Win32VersionValue; /**< 0x34 */
136 uint32_t SizeOfImage; /**< 0x38 */
137 uint32_t SizeOfHeaders; /**< 0x3c */
138 uint32_t CheckSum; /**< 0x40 */
139 uint16_t Subsystem; /**< 0x44 */
140 uint16_t DllCharacteristics; /**< 0x46 */
141 uint32_t SizeOfStackReserve; /**< 0x48 */
142 uint32_t SizeOfStackCommit; /**< 0x4c */
143 uint32_t SizeOfHeapReserve; /**< 0x50 */
144 uint32_t SizeOfHeapCommit; /**< 0x54 */
145 uint32_t LoaderFlags; /**< 0x58 */
146 uint32_t NumberOfRvaAndSizes; /**< 0x5c */
147 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x60; 0x10*8 = 0x80 */
148} IMAGE_OPTIONAL_HEADER32; /* size: 0xe0 */
149AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
150typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
151typedef IMAGE_OPTIONAL_HEADER32 const *PCIMAGE_OPTIONAL_HEADER32;
152
153/**
154 * PE optional header, 64-bit version.
155 */
156typedef struct _IMAGE_OPTIONAL_HEADER64
157{
158 uint16_t Magic; /**< 0x00 */
159 uint8_t MajorLinkerVersion; /**< 0x02 */
160 uint8_t MinorLinkerVersion; /**< 0x03 */
161 uint32_t SizeOfCode; /**< 0x04 */
162 uint32_t SizeOfInitializedData; /**< 0x08 */
163 uint32_t SizeOfUninitializedData; /**< 0x0c */
164 uint32_t AddressOfEntryPoint; /**< 0x10 */
165 uint32_t BaseOfCode; /**< 0x14 */
166 uint64_t ImageBase; /**< 0x18 */
167 uint32_t SectionAlignment; /**< 0x20 */
168 uint32_t FileAlignment; /**< 0x24 */
169 uint16_t MajorOperatingSystemVersion; /**< 0x28 */
170 uint16_t MinorOperatingSystemVersion; /**< 0x2a */
171 uint16_t MajorImageVersion; /**< 0x2c */
172 uint16_t MinorImageVersion; /**< 0x2e */
173 uint16_t MajorSubsystemVersion; /**< 0x30 */
174 uint16_t MinorSubsystemVersion; /**< 0x32 */
175 uint32_t Win32VersionValue; /**< 0x34 */
176 uint32_t SizeOfImage; /**< 0x38 */
177 uint32_t SizeOfHeaders; /**< 0x3c */
178 uint32_t CheckSum; /**< 0x40 */
179 uint16_t Subsystem; /**< 0x44 */
180 uint16_t DllCharacteristics; /**< 0x46 */
181 uint64_t SizeOfStackReserve; /**< 0x48 */
182 uint64_t SizeOfStackCommit; /**< 0x50 */
183 uint64_t SizeOfHeapReserve; /**< 0x58 */
184 uint64_t SizeOfHeapCommit; /**< 0x60 */
185 uint32_t LoaderFlags; /**< 0x68 */
186 uint32_t NumberOfRvaAndSizes; /**< 0x6c */
187 IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x70; 0x10*8 = 0x80 */
188} IMAGE_OPTIONAL_HEADER64; /* size: 0xf0 */
189AssertCompileSize(IMAGE_OPTIONAL_HEADER64, 0xf0);
190typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
191typedef IMAGE_OPTIONAL_HEADER64 const *PCIMAGE_OPTIONAL_HEADER64;
192
193/** @name Optional header magic values.
194 * @{ */
195#define IMAGE_NT_OPTIONAL_HDR32_MAGIC UINT16_C(0x010b)
196#define IMAGE_NT_OPTIONAL_HDR64_MAGIC UINT16_C(0x020b)
197/** @} */
198
199/** @name IMAGE_SUBSYSTEM_XXX - Optional header subsystems.
200 * IMAGE_OPTIONAL_HEADER32::Subsystem, IMAGE_OPTIONAL_HEADER64::Subsystem
201 * @{ */
202#define IMAGE_SUBSYSTEM_UNKNOWN UINT16_C(0x0000)
203#define IMAGE_SUBSYSTEM_NATIVE UINT16_C(0x0001)
204#define IMAGE_SUBSYSTEM_WINDOWS_GUI UINT16_C(0x0002)
205#define IMAGE_SUBSYSTEM_WINDOWS_CUI UINT16_C(0x0003)
206#define IMAGE_SUBSYSTEM_OS2_GUI UINT16_C(0x0004)
207#define IMAGE_SUBSYSTEM_OS2_CUI UINT16_C(0x0005)
208#define IMAGE_SUBSYSTEM_POSIX_CUI UINT16_C(0x0007)
209/** @} */
210
211/** @name Optional header characteristics.
212 * @{ */
213#define IMAGE_LIBRARY_PROCESS_INIT UINT16_C(0x0001)
214#define IMAGE_LIBRARY_PROCESS_TERM UINT16_C(0x0002)
215#define IMAGE_LIBRARY_THREAD_INIT UINT16_C(0x0004)
216#define IMAGE_LIBRARY_THREAD_TERM UINT16_C(0x0008)
217#define IMAGE_DLLCHARACTERISTICS_RESERVED UINT16_C(0x0010)
218#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA UINT16_C(0x0020)
219#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE UINT16_C(0x0040)
220#define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY UINT16_C(0x0080)
221#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT UINT16_C(0x0100)
222#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION UINT16_C(0x0200)
223#define IMAGE_DLLCHARACTERISTICS_NO_SEH UINT16_C(0x0400)
224#define IMAGE_DLLCHARACTERISTICS_NO_BIND UINT16_C(0x0800)
225#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER UINT16_C(0x1000)
226#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER UINT16_C(0x2000)
227#define IMAGE_DLLCHARACTERISTICS_GUARD_CF UINT16_C(0x4000)
228#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE UINT16_C(0x8000)
229/** @} */
230
231
232/** @name IMAGE_DIRECTORY_ENTRY_XXX - Data directory indexes.
233 * Used to index IMAGE_OPTIONAL_HEADER32::DataDirectory and
234 * IMAGE_OPTIONAL_HEADER64::DataDirectory
235 * @{ */
236#define IMAGE_DIRECTORY_ENTRY_EXPORT 0x0
237#define IMAGE_DIRECTORY_ENTRY_IMPORT 0x1
238#define IMAGE_DIRECTORY_ENTRY_RESOURCE 0x2
239#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 0x3
240#define IMAGE_DIRECTORY_ENTRY_SECURITY 0x4
241#define IMAGE_DIRECTORY_ENTRY_BASERELOC 0x5
242#define IMAGE_DIRECTORY_ENTRY_DEBUG 0x6
243#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 0x7
244#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
245#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 0x8
246#define IMAGE_DIRECTORY_ENTRY_TLS 0x9
247#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 0xa
248#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 0xb
249#define IMAGE_DIRECTORY_ENTRY_IAT 0xc
250#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 0xd
251#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 0xe
252/** @} */
253
254
255/**
256 * PE (NT) headers, 32-bit version.
257 */
258typedef struct _IMAGE_NT_HEADERS32
259{
260 uint32_t Signature; /**< 0x00 */
261 IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
262 IMAGE_OPTIONAL_HEADER32 OptionalHeader; /**< 0x18 */
263} IMAGE_NT_HEADERS32; /* size: 0xf8 */
264AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
265AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
266AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
267typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
268typedef IMAGE_NT_HEADERS32 const *PCIMAGE_NT_HEADERS32;
269
270/**
271 * PE (NT) headers, 64-bit version.
272 */
273typedef struct _IMAGE_NT_HEADERS64
274{
275 uint32_t Signature; /**< 0x00 */
276 IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
277 IMAGE_OPTIONAL_HEADER64 OptionalHeader; /**< 0x18 */
278} IMAGE_NT_HEADERS64; /**< 0x108 */
279AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
280AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
281AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
282typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
283typedef IMAGE_NT_HEADERS64 const *PCIMAGE_NT_HEADERS64;
284
285/** The PE signature.
286 * Used by IMAGE_NT_HEADERS32::Signature, IMAGE_NT_HEADERS64::Signature. */
287#define IMAGE_NT_SIGNATURE UINT32_C(0x00004550)
288
289
290/** Section header short name length (IMAGE_SECTION_HEADER::Name). */
291#define IMAGE_SIZEOF_SHORT_NAME 0x8
292
293/**
294 * PE & COFF section header.
295 */
296typedef struct _IMAGE_SECTION_HEADER
297{
298 uint8_t Name[IMAGE_SIZEOF_SHORT_NAME];
299 union
300 {
301 uint32_t PhysicalAddress;
302 uint32_t VirtualSize;
303 } Misc;
304 uint32_t VirtualAddress;
305 uint32_t SizeOfRawData;
306 uint32_t PointerToRawData;
307 uint32_t PointerToRelocations;
308 uint32_t PointerToLinenumbers;
309 uint16_t NumberOfRelocations;
310 uint16_t NumberOfLinenumbers;
311 uint32_t Characteristics;
312} IMAGE_SECTION_HEADER;
313AssertCompileSize(IMAGE_SECTION_HEADER, 40);
314typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
315typedef IMAGE_SECTION_HEADER const *PCIMAGE_SECTION_HEADER;
316
317/** @name IMAGE_SCN_XXX - Section header characteristics.
318 * Used by IMAGE_SECTION_HEADER::Characteristics.
319 * @{ */
320#define IMAGE_SCN_TYPE_REG UINT32_C(0x00000000)
321#define IMAGE_SCN_TYPE_DSECT UINT32_C(0x00000001)
322#define IMAGE_SCN_TYPE_NOLOAD UINT32_C(0x00000002)
323#define IMAGE_SCN_TYPE_GROUP UINT32_C(0x00000004)
324#define IMAGE_SCN_TYPE_NO_PAD UINT32_C(0x00000008)
325#define IMAGE_SCN_TYPE_COPY UINT32_C(0x00000010)
326
327#define IMAGE_SCN_CNT_CODE UINT32_C(0x00000020)
328#define IMAGE_SCN_CNT_INITIALIZED_DATA UINT32_C(0x00000040)
329#define IMAGE_SCN_CNT_UNINITIALIZED_DATA UINT32_C(0x00000080)
330
331#define IMAGE_SCN_LNK_OTHER UINT32_C(0x00000100)
332#define IMAGE_SCN_LNK_INFO UINT32_C(0x00000200)
333#define IMAGE_SCN_TYPE_OVER UINT32_C(0x00000400)
334#define IMAGE_SCN_LNK_REMOVE UINT32_C(0x00000800)
335#define IMAGE_SCN_LNK_COMDAT UINT32_C(0x00001000)
336#define IMAGE_SCN_MEM_PROTECTED UINT32_C(0x00004000)
337#define IMAGE_SCN_NO_DEFER_SPEC_EXC UINT32_C(0x00004000)
338#define IMAGE_SCN_GPREL UINT32_C(0x00008000)
339#define IMAGE_SCN_MEM_FARDATA UINT32_C(0x00008000)
340#define IMAGE_SCN_MEM_SYSHEAP UINT32_C(0x00010000)
341#define IMAGE_SCN_MEM_PURGEABLE UINT32_C(0x00020000)
342#define IMAGE_SCN_MEM_16BIT UINT32_C(0x00020000)
343#define IMAGE_SCN_MEM_LOCKED UINT32_C(0x00040000)
344#define IMAGE_SCN_MEM_PRELOAD UINT32_C(0x00080000)
345
346#define IMAGE_SCN_ALIGN_1BYTES UINT32_C(0x00100000)
347#define IMAGE_SCN_ALIGN_2BYTES UINT32_C(0x00200000)
348#define IMAGE_SCN_ALIGN_4BYTES UINT32_C(0x00300000)
349#define IMAGE_SCN_ALIGN_8BYTES UINT32_C(0x00400000)
350#define IMAGE_SCN_ALIGN_16BYTES UINT32_C(0x00500000)
351#define IMAGE_SCN_ALIGN_32BYTES UINT32_C(0x00600000)
352#define IMAGE_SCN_ALIGN_64BYTES UINT32_C(0x00700000)
353#define IMAGE_SCN_ALIGN_128BYTES UINT32_C(0x00800000)
354#define IMAGE_SCN_ALIGN_256BYTES UINT32_C(0x00900000)
355#define IMAGE_SCN_ALIGN_512BYTES UINT32_C(0x00A00000)
356#define IMAGE_SCN_ALIGN_1024BYTES UINT32_C(0x00B00000)
357#define IMAGE_SCN_ALIGN_2048BYTES UINT32_C(0x00C00000)
358#define IMAGE_SCN_ALIGN_4096BYTES UINT32_C(0x00D00000)
359#define IMAGE_SCN_ALIGN_8192BYTES UINT32_C(0x00E00000)
360#define IMAGE_SCN_ALIGN_MASK UINT32_C(0x00F00000)
361#define IMAGE_SCN_ALIGN_SHIFT 20
362
363#define IMAGE_SCN_LNK_NRELOC_OVFL UINT32_C(0x01000000)
364#define IMAGE_SCN_MEM_DISCARDABLE UINT32_C(0x02000000)
365#define IMAGE_SCN_MEM_NOT_CACHED UINT32_C(0x04000000)
366#define IMAGE_SCN_MEM_NOT_PAGED UINT32_C(0x08000000)
367#define IMAGE_SCN_MEM_SHARED UINT32_C(0x10000000)
368#define IMAGE_SCN_MEM_EXECUTE UINT32_C(0x20000000)
369#define IMAGE_SCN_MEM_READ UINT32_C(0x40000000)
370#define IMAGE_SCN_MEM_WRITE UINT32_C(0x80000000)
371/** @} */
372
373
374/**
375 * PE image base relocations block header.
376 *
377 * This found in IMAGE_DIRECTORY_ENTRY_BASERELOC. Each entry is follow
378 * immediately by an array of 16-bit words, where the lower 12-bits are used
379 * for the page offset and the upper 4-bits for the base relocation type
380 * (IMAGE_REL_BASE_XXX). The block should be padded with
381 * IMAGE_REL_BASED_ABSOLUTE entries to ensure 32-bit alignment of this header.
382 */
383typedef struct _IMAGE_BASE_RELOCATION
384{
385 /** The RVA of the page/block the following ase relocations applies to. */
386 uint32_t VirtualAddress;
387 /** The size of this relocation block, including this header. */
388 uint32_t SizeOfBlock;
389} IMAGE_BASE_RELOCATION;
390AssertCompileSize(IMAGE_BASE_RELOCATION, 8);
391typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
392typedef IMAGE_BASE_RELOCATION const *PCIMAGE_BASE_RELOCATION;
393
394/** @name IMAGE_REL_BASED_XXX - PE base relocations.
395 * Found in the IMAGE_DIRECTORY_ENTRY_BASERELOC data directory.
396 * @{ */
397#define IMAGE_REL_BASED_ABSOLUTE UINT16_C(0x0)
398#define IMAGE_REL_BASED_HIGH UINT16_C(0x1)
399#define IMAGE_REL_BASED_LOW UINT16_C(0x2)
400#define IMAGE_REL_BASED_HIGHLOW UINT16_C(0x3)
401#define IMAGE_REL_BASED_HIGHADJ UINT16_C(0x4)
402#define IMAGE_REL_BASED_MIPS_JMPADDR UINT16_C(0x5)
403#define IMAGE_REL_BASED_MIPS_JMPADDR16 UINT16_C(0x9)
404#define IMAGE_REL_BASED_IA64_IMM64 UINT16_C(0x9)
405#define IMAGE_REL_BASED_DIR64 UINT16_C(0xa)
406#define IMAGE_REL_BASED_HIGH3ADJ UINT16_C(0xb)
407/** @} */
408
409/**
410 * PE export directory entry.
411 */
412typedef struct _IMAGE_EXPORT_DIRECTORY
413{
414 uint32_t Characteristics;
415 uint32_t TimeDateStamp;
416 uint16_t MajorVersion;
417 uint16_t MinorVersion;
418 uint32_t Name;
419 uint32_t Base;
420 uint32_t NumberOfFunctions;
421 uint32_t NumberOfNames;
422 uint32_t AddressOfFunctions;
423 uint32_t AddressOfNames;
424 uint32_t AddressOfNameOrdinals;
425} IMAGE_EXPORT_DIRECTORY;
426AssertCompileSize(IMAGE_EXPORT_DIRECTORY, 40);
427typedef IMAGE_EXPORT_DIRECTORY *PIMAGE_EXPORT_DIRECTORY;
428typedef IMAGE_EXPORT_DIRECTORY const *PCIMAGE_EXPORT_DIRECTORY;
429
430
431/**
432 * PE import directory entry.
433 */
434typedef struct _IMAGE_IMPORT_DESCRIPTOR
435{
436 union
437 {
438 uint32_t Characteristics;
439 uint32_t OriginalFirstThunk;
440 } u;
441 uint32_t TimeDateStamp;
442 uint32_t ForwarderChain;
443 uint32_t Name;
444 uint32_t FirstThunk;
445} IMAGE_IMPORT_DESCRIPTOR;
446AssertCompileSize(IMAGE_IMPORT_DESCRIPTOR, 20);
447typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
448typedef IMAGE_IMPORT_DESCRIPTOR const *PCIMAGE_IMPORT_DESCRIPTOR;
449
450/**
451 * Something we currently don't make use of...
452 */
453typedef struct _IMAGE_IMPORT_BY_NAME
454{
455 uint16_t Hint;
456 uint8_t Name[1];
457} IMAGE_IMPORT_BY_NAME;
458AssertCompileSize(IMAGE_IMPORT_BY_NAME, 4);
459typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
460typedef IMAGE_IMPORT_BY_NAME const *PCIMAGE_IMPORT_BY_NAME;
461
462
463#if 0
464/* The image_thunk_data32/64 structures are not very helpful except for getting RSI.
465 keep them around till all the code has been converted. */
466typedef struct _IMAGE_THUNK_DATA64
467{
468 union
469 {
470 uint64_t ForwarderString;
471 uint64_t Function;
472 uint64_t Ordinal;
473 uint64_t AddressOfData;
474 } u1;
475} IMAGE_THUNK_DATA64;
476typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
477typedef IMAGE_THUNK_DATA64 const *PCIMAGE_THUNK_DATA64;
478
479typedef struct _IMAGE_THUNK_DATA32
480{
481 union
482 {
483 uint32_t ForwarderString;
484 uint32_t Function;
485 uint32_t Ordinal;
486 uint32_t AddressOfData;
487 } u1;
488} IMAGE_THUNK_DATA32;
489typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
490typedef IMAGE_THUNK_DATA32 const *PCIMAGE_THUNK_DATA32;
491#endif
492
493/** @name PE import directory macros.
494 * @{ */
495#define IMAGE_ORDINAL_FLAG32 UINT32_C(0x80000000)
496#define IMAGE_ORDINAL32(ord) ((ord) & UINT32_C(0xffff))
497#define IMAGE_SNAP_BY_ORDINAL32(ord) (!!((ord) & IMAGE_ORDINAL_FLAG32))
498
499#define IMAGE_ORDINAL_FLAG64 UINT64_C(0x8000000000000000)
500#define IMAGE_ORDINAL64(ord) ((ord) & UINT32_C(0xffff))
501#define IMAGE_SNAP_BY_ORDINAL64(ord) (!!((ord) & IMAGE_ORDINAL_FLAG64))
502/** @} */
503
504/** @name Image load config directories
505 * @{ */
506
507/** @since Windows 10 (preview 9879) */
508typedef struct _IMAGE_LOAD_CONFIG_CODE_INTEGRITY
509{
510 uint16_t Flags;
511 uint16_t Catalog;
512 uint32_t CatalogOffset;
513 uint32_t Reserved;
514} IMAGE_LOAD_CONFIG_CODE_INTEGRITY;
515AssertCompileSize(IMAGE_LOAD_CONFIG_CODE_INTEGRITY, 12);
516typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY *PIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
517typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY const *PCIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
518
519typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V1
520{
521 uint32_t Size;
522 uint32_t TimeDateStamp;
523 uint16_t MajorVersion;
524 uint16_t MinorVersion;
525 uint32_t GlobalFlagsClear;
526 uint32_t GlobalFlagsSet;
527 uint32_t CriticalSectionDefaultTimeout;
528 uint32_t DeCommitFreeBlockThreshold;
529 uint32_t DeCommitTotalFreeThreshold;
530 uint32_t LockPrefixTable;
531 uint32_t MaximumAllocationSize;
532 uint32_t VirtualMemoryThreshold;
533 uint32_t ProcessHeapFlags;
534 uint32_t ProcessAffinityMask;
535 uint16_t CSDVersion;
536 uint16_t Reserved1;
537 uint32_t EditList;
538 uint32_t SecurityCookie;
539} IMAGE_LOAD_CONFIG_DIRECTORY32_V1;
540AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V1, 0x40);
541typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V1;
542typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V1;
543
544typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V2
545{
546 uint32_t Size;
547 uint32_t TimeDateStamp;
548 uint16_t MajorVersion;
549 uint16_t MinorVersion;
550 uint32_t GlobalFlagsClear;
551 uint32_t GlobalFlagsSet;
552 uint32_t CriticalSectionDefaultTimeout;
553 uint32_t DeCommitFreeBlockThreshold;
554 uint32_t DeCommitTotalFreeThreshold;
555 uint32_t LockPrefixTable;
556 uint32_t MaximumAllocationSize;
557 uint32_t VirtualMemoryThreshold;
558 uint32_t ProcessHeapFlags;
559 uint32_t ProcessAffinityMask;
560 uint16_t CSDVersion;
561 uint16_t Reserved1;
562 uint32_t EditList;
563 uint32_t SecurityCookie;
564 uint32_t SEHandlerTable;
565 uint32_t SEHandlerCount;
566} IMAGE_LOAD_CONFIG_DIRECTORY32_V2;
567AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V2, 0x48);
568typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V2;
569typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V2;
570
571typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V3
572{
573 uint32_t Size;
574 uint32_t TimeDateStamp;
575 uint16_t MajorVersion;
576 uint16_t MinorVersion;
577 uint32_t GlobalFlagsClear;
578 uint32_t GlobalFlagsSet;
579 uint32_t CriticalSectionDefaultTimeout;
580 uint32_t DeCommitFreeBlockThreshold;
581 uint32_t DeCommitTotalFreeThreshold;
582 uint32_t LockPrefixTable;
583 uint32_t MaximumAllocationSize;
584 uint32_t VirtualMemoryThreshold;
585 uint32_t ProcessHeapFlags;
586 uint32_t ProcessAffinityMask;
587 uint16_t CSDVersion;
588 uint16_t Reserved1;
589 uint32_t EditList;
590 uint32_t SecurityCookie;
591 uint32_t SEHandlerTable;
592 uint32_t SEHandlerCount;
593 uint32_t GuardCFCCheckFunctionPointer;
594 uint32_t Reserved2;
595 uint32_t GuardCFFunctionTable;
596 uint32_t GuardCFFunctionCount;
597 uint32_t GuardFlags;
598} IMAGE_LOAD_CONFIG_DIRECTORY32_V3;
599AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V3, 0x5c);
600typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V3;
601typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V3;
602
603/** @since Windows 10 (preview 9879) */
604typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V4
605{
606 uint32_t Size;
607 uint32_t TimeDateStamp;
608 uint16_t MajorVersion;
609 uint16_t MinorVersion;
610 uint32_t GlobalFlagsClear;
611 uint32_t GlobalFlagsSet;
612 uint32_t CriticalSectionDefaultTimeout;
613 uint32_t DeCommitFreeBlockThreshold;
614 uint32_t DeCommitTotalFreeThreshold;
615 uint32_t LockPrefixTable;
616 uint32_t MaximumAllocationSize;
617 uint32_t VirtualMemoryThreshold;
618 uint32_t ProcessHeapFlags;
619 uint32_t ProcessAffinityMask;
620 uint16_t CSDVersion;
621 uint16_t Reserved1;
622 uint32_t EditList;
623 uint32_t SecurityCookie;
624 uint32_t SEHandlerTable;
625 uint32_t SEHandlerCount;
626 uint32_t GuardCFCCheckFunctionPointer;
627 uint32_t Reserved2;
628 uint32_t GuardCFFunctionTable;
629 uint32_t GuardCFFunctionCount;
630 uint32_t GuardFlags;
631 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
632} IMAGE_LOAD_CONFIG_DIRECTORY32_V4;
633AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V4, 0x68);
634typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V4;
635typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4;
636
637typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 IMAGE_LOAD_CONFIG_DIRECTORY32;
638typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V4 PIMAGE_LOAD_CONFIG_DIRECTORY32;
639typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4 PCIMAGE_LOAD_CONFIG_DIRECTORY32;
640
641/* No _IMAGE_LOAD_CONFIG_DIRECTORY64_V1 exists. */
642
643typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V2
644{
645 uint32_t Size;
646 uint32_t TimeDateStamp;
647 uint16_t MajorVersion;
648 uint16_t MinorVersion;
649 uint32_t GlobalFlagsClear;
650 uint32_t GlobalFlagsSet;
651 uint32_t CriticalSectionDefaultTimeout;
652 uint64_t DeCommitFreeBlockThreshold;
653 uint64_t DeCommitTotalFreeThreshold;
654 uint64_t LockPrefixTable;
655 uint64_t MaximumAllocationSize;
656 uint64_t VirtualMemoryThreshold;
657 uint64_t ProcessAffinityMask;
658 uint32_t ProcessHeapFlags;
659 uint16_t CSDVersion;
660 uint16_t Reserved1;
661 uint64_t EditList;
662 uint64_t SecurityCookie;
663 uint64_t SEHandlerTable;
664 uint64_t SEHandlerCount;
665} IMAGE_LOAD_CONFIG_DIRECTORY64_V2;
666AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V2, 0x70);
667typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V2;
668typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V2;
669
670#pragma pack(4) /* Why not 8 byte alignment, baka microsofties?!? */
671typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V3
672{
673 uint32_t Size;
674 uint32_t TimeDateStamp;
675 uint16_t MajorVersion;
676 uint16_t MinorVersion;
677 uint32_t GlobalFlagsClear;
678 uint32_t GlobalFlagsSet;
679 uint32_t CriticalSectionDefaultTimeout;
680 uint64_t DeCommitFreeBlockThreshold;
681 uint64_t DeCommitTotalFreeThreshold;
682 uint64_t LockPrefixTable;
683 uint64_t MaximumAllocationSize;
684 uint64_t VirtualMemoryThreshold;
685 uint64_t ProcessAffinityMask;
686 uint32_t ProcessHeapFlags;
687 uint16_t CSDVersion;
688 uint16_t Reserved1;
689 uint64_t EditList;
690 uint64_t SecurityCookie;
691 uint64_t SEHandlerTable;
692 uint64_t SEHandlerCount;
693 uint64_t GuardCFCCheckFunctionPointer;
694 uint64_t Reserved2;
695 uint64_t GuardCFFunctionTable;
696 uint64_t GuardCFFunctionCount;
697 uint32_t GuardFlags;
698} IMAGE_LOAD_CONFIG_DIRECTORY64_V3;
699#pragma pack()
700AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V3, 0x94);
701typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V3;
702typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V3;
703
704/** @since Windows 10 (Preview (9879). */
705typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V4
706{
707 uint32_t Size;
708 uint32_t TimeDateStamp;
709 uint16_t MajorVersion;
710 uint16_t MinorVersion;
711 uint32_t GlobalFlagsClear;
712 uint32_t GlobalFlagsSet;
713 uint32_t CriticalSectionDefaultTimeout;
714 uint64_t DeCommitFreeBlockThreshold;
715 uint64_t DeCommitTotalFreeThreshold;
716 uint64_t LockPrefixTable;
717 uint64_t MaximumAllocationSize;
718 uint64_t VirtualMemoryThreshold;
719 uint64_t ProcessAffinityMask;
720 uint32_t ProcessHeapFlags;
721 uint16_t CSDVersion;
722 uint16_t Reserved1;
723 uint64_t EditList;
724 uint64_t SecurityCookie;
725 uint64_t SEHandlerTable;
726 uint64_t SEHandlerCount;
727 uint64_t GuardCFCCheckFunctionPointer;
728 uint64_t Reserved2;
729 uint64_t GuardCFFunctionTable;
730 uint64_t GuardCFFunctionCount;
731 uint32_t GuardFlags;
732 IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity;
733} IMAGE_LOAD_CONFIG_DIRECTORY64_V4;
734AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V4, 0xa0);
735typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
736typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
737
738typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 IMAGE_LOAD_CONFIG_DIRECTORY64;
739typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V4 PIMAGE_LOAD_CONFIG_DIRECTORY64;
740typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4 PCIMAGE_LOAD_CONFIG_DIRECTORY64;
741
742/** @} */
743
744
745/**
746 * PE certificate directory.
747 *
748 * Found in IMAGE_DIRECTORY_ENTRY_SECURITY.
749 */
750typedef struct WIN_CERTIFICATE
751{
752 uint32_t dwLength;
753 uint16_t wRevision;
754 uint16_t wCertificateType;
755 uint8_t bCertificate[8];
756} WIN_CERTIFICATE;
757AssertCompileSize(WIN_CERTIFICATE, 16);
758typedef WIN_CERTIFICATE *PWIN_CERTIFICATE;
759typedef WIN_CERTIFICATE const *PCWIN_CERTIFICATE;
760
761/** @name WIN_CERT_REVISION_XXX - Certificate data directory revision.
762 * Used WIN_CERTIFICATE::wRevision found in the
763 * IMAGE_DIRECTORY_ENTRY_SECURITY data directory. */
764#define WIN_CERT_REVISION_1_0 UINT16_C(0x0100)
765#define WIN_CERT_REVISION_2_0 UINT16_C(0x0200)
766/** @} */
767
768/** @name WIN_CERT_TYPE_XXX - Signature type.
769 * Used by WIN_CERTIFICATE::wCertificateType.
770 * @{ */
771#define WIN_CERT_TYPE_X509 UINT16_C(1)
772#define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2)
773#define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3)
774#define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4)
775#define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0)
776#define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1)
777/** @} */
778
779/** The alignment of the certificate table.
780 * @remarks Found thru signtool experiments. */
781#define WIN_CERTIFICATE_ALIGNMENT UINT32_C(8)
782
783
784/**
785 * Debug directory.
786 *
787 * Found in IMAGE_DIRECTORY_ENTRY_DEBUG.
788 */
789typedef struct _IMAGE_DEBUG_DIRECTORY
790{
791 uint32_t Characteristics;
792 uint32_t TimeDateStamp;
793 uint16_t MajorVersion;
794 uint16_t MinorVersion;
795 uint32_t Type;
796 uint32_t SizeOfData;
797 uint32_t AddressOfRawData;
798 uint32_t PointerToRawData;
799} IMAGE_DEBUG_DIRECTORY;
800AssertCompileSize(IMAGE_DEBUG_DIRECTORY, 28);
801typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
802typedef IMAGE_DEBUG_DIRECTORY const *PCIMAGE_DEBUG_DIRECTORY;
803
804/** @name IMAGE_DEBUG_TYPE_XXX - Debug format types.
805 * Used by IMAGE_DEBUG_DIRECTORY::Type.
806 * @{ */
807#define IMAGE_DEBUG_TYPE_UNKNOWN UINT32_C(0x0)
808#define IMAGE_DEBUG_TYPE_COFF UINT32_C(0x1)
809#define IMAGE_DEBUG_TYPE_CODEVIEW UINT32_C(0x2)
810#define IMAGE_DEBUG_TYPE_FPO UINT32_C(0x3)
811#define IMAGE_DEBUG_TYPE_MISC UINT32_C(0x4)
812#define IMAGE_DEBUG_TYPE_EXCEPTION UINT32_C(0x5)
813#define IMAGE_DEBUG_TYPE_FIXUP UINT32_C(0x6)
814#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC UINT32_C(0x7)
815#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC UINT32_C(0x8)
816#define IMAGE_DEBUG_TYPE_BORLAND UINT32_C(0x9)
817#define IMAGE_DEBUG_TYPE_RESERVED10 UINT32_C(0x10)
818/** @} */
819
820/** @name IMAGE_DEBUG_MISC_XXX - Misc debug data type.
821 * Used by IMAGE_DEBUG_MISC::DataType.
822 * @{ */
823#define IMAGE_DEBUG_MISC_EXENAME UINT32_C(1)
824/** @} */
825
826
827/**
828 * The format of IMAGE_DEBUG_TYPE_MISC debug info.
829 */
830typedef struct _IMAGE_DEBUG_MISC
831{
832 uint32_t DataType;
833 uint32_t Length;
834 uint8_t Unicode;
835 uint8_t Reserved[3];
836 uint8_t Data[1];
837} IMAGE_DEBUG_MISC;
838AssertCompileSize(IMAGE_DEBUG_MISC, 16);
839typedef IMAGE_DEBUG_MISC *PIMAGE_DEBUG_MISC;
840typedef IMAGE_DEBUG_MISC const *PCIMAGE_DEBUG_MISC;
841
842
843
844/**
845 * The header of a .DBG file (NT4).
846 */
847typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
848{
849 uint16_t Signature; /**< 0x00 */
850 uint16_t Flags; /**< 0x02 */
851 uint16_t Machine; /**< 0x04 */
852 uint16_t Characteristics; /**< 0x06 */
853 uint32_t TimeDateStamp; /**< 0x08 */
854 uint32_t CheckSum; /**< 0x0c */
855 uint32_t ImageBase; /**< 0x10 */
856 uint32_t SizeOfImage; /**< 0x14 */
857 uint32_t NumberOfSections; /**< 0x18 */
858 uint32_t ExportedNamesSize; /**< 0x1c */
859 uint32_t DebugDirectorySize; /**< 0x20 */
860 uint32_t SectionAlignment; /**< 0x24 */
861 uint32_t Reserved[2]; /**< 0x28 */
862} IMAGE_SEPARATE_DEBUG_HEADER; /* size: 0x30 */
863AssertCompileSize(IMAGE_SEPARATE_DEBUG_HEADER, 0x30);
864typedef IMAGE_SEPARATE_DEBUG_HEADER *PIMAGE_SEPARATE_DEBUG_HEADER;
865typedef IMAGE_SEPARATE_DEBUG_HEADER const *PCIMAGE_SEPARATE_DEBUG_HEADER;
866
867/** The signature of a IMAGE_SEPARATE_DEBUG_HEADER. */
868#define IMAGE_SEPARATE_DEBUG_SIGNATURE UINT16_C(0x4944)
869
870
871/**
872 * The format of IMAGE_DEBUG_TYPE_COFF debug info.
873 */
874typedef struct _IMAGE_COFF_SYMBOLS_HEADER
875{
876 uint32_t NumberOfSymbols;
877 uint32_t LvaToFirstSymbol;
878 uint32_t NumberOfLinenumbers;
879 uint32_t LvaToFirstLinenumber;
880 uint32_t RvaToFirstByteOfCode;
881 uint32_t RvaToLastByteOfCode;
882 uint32_t RvaToFirstByteOfData;
883 uint32_t RvaToLastByteOfData;
884} IMAGE_COFF_SYMBOLS_HEADER;
885AssertCompileSize(IMAGE_COFF_SYMBOLS_HEADER, 0x20);
886typedef IMAGE_COFF_SYMBOLS_HEADER *PIMAGE_COFF_SYMBOLS_HEADER;
887typedef IMAGE_COFF_SYMBOLS_HEADER const *PCIMAGE_COFF_SYMBOLS_HEADER;
888
889
890/**
891 * Line number format of IMAGE_DEBUG_TYPE_COFF debug info.
892 *
893 * @remarks This has misaligned members.
894 */
895#pragma pack(2)
896typedef struct _IMAGE_LINENUMBER
897{
898 union
899 {
900 uint32_t VirtualAddress;
901 uint32_t SymbolTableIndex;
902 } Type;
903 uint16_t Linenumber;
904} IMAGE_LINENUMBER;
905#pragma pack()
906AssertCompileSize(IMAGE_LINENUMBER, 6);
907typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
908typedef IMAGE_LINENUMBER const *PCIMAGE_LINENUMBER;
909
910
911/** The size of a IMAGE_SYMBOL & IMAGE_AUX_SYMBOL structure. */
912#define IMAGE_SIZE_OF_SYMBOL 18
913/** The size of a IMAGE_SYMBOL_EX & IMAGE_AUX_SYMBOL_EX structure. */
914#define IMAGE_SIZE_OF_SYMBOL_EX 20
915
916/**
917 * COFF symbol.
918 */
919#pragma pack(2)
920typedef struct _IMAGE_SYMBOL
921{
922 union
923 {
924 uint8_t ShortName[8];
925 struct
926 {
927 uint32_t Short;
928 uint32_t Long;
929 } Name;
930 uint32_t LongName[2];
931 } N;
932
933 uint32_t Value;
934 int16_t SectionNumber;
935 uint16_t Type;
936 uint8_t StorageClass;
937 uint8_t NumberOfAuxSymbols;
938} IMAGE_SYMBOL;
939#pragma pack()
940AssertCompileSize(IMAGE_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
941typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
942typedef IMAGE_SYMBOL const *PCIMAGE_SYMBOL;
943
944/**
945 * COFF auxiliary symbol token defintion (whatever that is).
946 */
947#pragma pack(2)
948typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF
949{
950 uint8_t bAuxType;
951 uint8_t bReserved;
952 uint32_t SymbolTableIndex;
953 uint8_t rgbReserved[12];
954} IMAGE_AUX_SYMBOL_TOKEN_DEF;
955#pragma pack()
956AssertCompileSize(IMAGE_AUX_SYMBOL_TOKEN_DEF, IMAGE_SIZE_OF_SYMBOL);
957typedef IMAGE_AUX_SYMBOL_TOKEN_DEF *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
958typedef IMAGE_AUX_SYMBOL_TOKEN_DEF const *PCIMAGE_AUX_SYMBOL_TOKEN_DEF;
959
960/**
961 * COFF auxiliary symbol.
962 */
963#pragma pack(1)
964typedef union _IMAGE_AUX_SYMBOL
965{
966 struct
967 {
968 uint32_t TagIndex;
969 union
970 {
971 struct
972 {
973 uint16_t Linenumber;
974 uint16_t Size;
975 } LnSz;
976 } Misc;
977 union
978 {
979 struct
980 {
981 uint32_t PointerToLinenumber;
982 uint32_t PointerToNextFunction;
983 } Function;
984 struct
985 {
986 uint16_t Dimension[4];
987 } Array;
988 } FcnAry;
989 uint16_t TvIndex;
990 } Sym;
991
992 struct
993 {
994 uint8_t Name[IMAGE_SIZE_OF_SYMBOL];
995 } File;
996
997 struct
998 {
999 uint32_t Length;
1000 uint16_t NumberOfRelocations;
1001 uint16_t NumberOfLinenumbers;
1002 uint32_t CheckSum;
1003 uint16_t Number;
1004 uint8_t Selection;
1005 uint8_t bReserved;
1006 uint16_t HighNumber;
1007 } Section;
1008
1009 IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
1010 struct
1011 {
1012 uint32_t crc;
1013 uint8_t rgbReserved[14];
1014 } CRC;
1015} IMAGE_AUX_SYMBOL;
1016#pragma pack()
1017AssertCompileSize(IMAGE_AUX_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
1018typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
1019typedef IMAGE_AUX_SYMBOL const *PCIMAGE_AUX_SYMBOL;
1020
1021
1022/**
1023 * Extended COFF symbol.
1024 */
1025typedef struct _IMAGE_SYMBOL_EX
1026{
1027 union
1028 {
1029 uint8_t ShortName[8];
1030 struct
1031 {
1032 uint32_t Short;
1033 uint32_t Long;
1034 } Name;
1035 uint32_t LongName[2];
1036 } N;
1037
1038 uint32_t Value;
1039 int32_t SectionNumber; /* The difference from IMAGE_SYMBOL */
1040 uint16_t Type;
1041 uint8_t StorageClass;
1042 uint8_t NumberOfAuxSymbols;
1043} IMAGE_SYMBOL_EX;
1044AssertCompileSize(IMAGE_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
1045typedef IMAGE_SYMBOL_EX *PIMAGE_SYMBOL_EX;
1046typedef IMAGE_SYMBOL_EX const *PCIMAGE_SYMBOL_EX;
1047
1048/**
1049 * Extended COFF auxiliary symbol.
1050 */
1051typedef union _IMAGE_AUX_SYMBOL_EX
1052{
1053 struct
1054 {
1055 uint32_t WeakDefaultSymIndex;
1056 uint32_t WeakSearchType;
1057 uint8_t rgbReserved[12];
1058 } Sym;
1059
1060 struct
1061 {
1062 uint8_t Name[IMAGE_SIZE_OF_SYMBOL_EX];
1063 } File;
1064
1065 struct
1066 {
1067 uint32_t Length;
1068 uint16_t NumberOfRelocations;
1069 uint16_t NumberOfLinenumbers;
1070 uint32_t CheckSum;
1071 uint16_t Number;
1072 uint8_t Selection;
1073 uint8_t bReserved;
1074 uint16_t HighNumber;
1075 uint8_t rgbReserved[2];
1076 } Section;
1077
1078 IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
1079
1080 struct
1081 {
1082 uint32_t crc;
1083 uint8_t rgbReserved[16];
1084 } CRC;
1085} IMAGE_AUX_SYMBOL_EX;
1086AssertCompileSize(IMAGE_AUX_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
1087typedef IMAGE_AUX_SYMBOL_EX *PIMAGE_AUX_SYMBOL_EX;
1088typedef IMAGE_AUX_SYMBOL_EX const *PCIMAGE_AUX_SYMBOL_EX;
1089
1090/** @name Special COFF section numbers.
1091 * Used by IMAGE_SYMBOL::SectionNumber and IMAGE_SYMBOL_EX::SectionNumber
1092 * @{ */
1093#define IMAGE_SYM_UNDEFINED INT16_C(0)
1094#define IMAGE_SYM_ABSOLUTE INT16_C(-1)
1095#define IMAGE_SYM_DEBUG INT16_C(-2)
1096/** @} */
1097
1098/** @name IMAGE_SYM_CLASS_XXX - COFF symbol storage classes.
1099 * @{ */
1100#define IMAGE_SYM_CLASS_END_OF_FUNCTION UINT8_C(0xff) /* -1 */
1101#define IMAGE_SYM_CLASS_NULL UINT8_C(0)
1102#define IMAGE_SYM_CLASS_AUTOMATIC UINT8_C(1)
1103#define IMAGE_SYM_CLASS_EXTERNAL UINT8_C(2)
1104#define IMAGE_SYM_CLASS_STATIC UINT8_C(3)
1105#define IMAGE_SYM_CLASS_REGISTER UINT8_C(4)
1106#define IMAGE_SYM_CLASS_EXTERNAL_DEF UINT8_C(5)
1107#define IMAGE_SYM_CLASS_LABEL UINT8_C(6)
1108#define IMAGE_SYM_CLASS_UNDEFINED_LABEL UINT8_C(7)
1109#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT UINT8_C(8)
1110#define IMAGE_SYM_CLASS_ARGUMENT UINT8_C(9)
1111#define IMAGE_SYM_CLASS_STRUCT_TAG UINT8_C(10)
1112#define IMAGE_SYM_CLASS_MEMBER_OF_UNION UINT8_C(11)
1113#define IMAGE_SYM_CLASS_UNION_TAG UINT8_C(12)
1114#define IMAGE_SYM_CLASS_TYPE_DEFINITION UINT8_C(13)
1115#define IMAGE_SYM_CLASS_UNDEFINED_STATIC UINT8_C(14)
1116#define IMAGE_SYM_CLASS_ENUM_TAG UINT8_C(15)
1117#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM UINT8_C(16)
1118#define IMAGE_SYM_CLASS_REGISTER_PARAM UINT8_C(17)
1119#define IMAGE_SYM_CLASS_BIT_FIELD UINT8_C(18)
1120#define IMAGE_SYM_CLASS_FAR_EXTERNAL UINT8_C(68)
1121#define IMAGE_SYM_CLASS_BLOCK UINT8_C(100)
1122#define IMAGE_SYM_CLASS_FUNCTION UINT8_C(101)
1123#define IMAGE_SYM_CLASS_END_OF_STRUCT UINT8_C(102)
1124#define IMAGE_SYM_CLASS_FILE UINT8_C(103)
1125#define IMAGE_SYM_CLASS_SECTION UINT8_C(104)
1126#define IMAGE_SYM_CLASS_WEAK_EXTERNAL UINT8_C(105)
1127#define IMAGE_SYM_CLASS_CLR_TOKEN UINT8_C(107)
1128/** @} */
1129
1130/** @name IMAGE_SYM_TYPE_XXX - COFF symbol base types
1131 * @{ */
1132#define IMAGE_SYM_TYPE_NULL UINT16_C(0x0000)
1133#define IMAGE_SYM_TYPE_VOID UINT16_C(0x0001)
1134#define IMAGE_SYM_TYPE_CHAR UINT16_C(0x0002)
1135#define IMAGE_SYM_TYPE_SHORT UINT16_C(0x0003)
1136#define IMAGE_SYM_TYPE_INT UINT16_C(0x0004)
1137#define IMAGE_SYM_TYPE_LONG UINT16_C(0x0005)
1138#define IMAGE_SYM_TYPE_FLOAT UINT16_C(0x0006)
1139#define IMAGE_SYM_TYPE_DOUBLE UINT16_C(0x0007)
1140#define IMAGE_SYM_TYPE_STRUCT UINT16_C(0x0008)
1141#define IMAGE_SYM_TYPE_UNION UINT16_C(0x0009)
1142#define IMAGE_SYM_TYPE_ENUM UINT16_C(0x000a)
1143#define IMAGE_SYM_TYPE_MOE UINT16_C(0x000b)
1144#define IMAGE_SYM_TYPE_BYTE UINT16_C(0x000c)
1145#define IMAGE_SYM_TYPE_WORD UINT16_C(0x000d)
1146#define IMAGE_SYM_TYPE_UINT UINT16_C(0x000e)
1147#define IMAGE_SYM_TYPE_DWORD UINT16_C(0x000f)
1148#define IMAGE_SYM_TYPE_PCODE UINT16_C(0x8000)
1149/** @} */
1150
1151/** @name IMAGE_SYM_DTYPE_XXX - COFF symbol complex types
1152 * @{ */
1153#define IMAGE_SYM_DTYPE_NULL UINT16_C(0x0)
1154#define IMAGE_SYM_DTYPE_POINTER UINT16_C(0x1)
1155#define IMAGE_SYM_DTYPE_FUNCTION UINT16_C(0x2)
1156#define IMAGE_SYM_DTYPE_ARRAY UINT16_C(0x3)
1157/** @} */
1158
1159/** @name COFF Symbol type masks and shift counts.
1160 * @{ */
1161#define N_BTMASK UINT16_C(0x000f)
1162#define N_TMASK UINT16_C(0x0030)
1163#define N_TMASK1 UINT16_C(0x00c0)
1164#define N_TMASK2 UINT16_C(0x00f0)
1165#define N_BTSHFT 4
1166#define N_TSHIFT 2
1167/** @} */
1168
1169/** @name COFF Symbol type macros.
1170 * @{ */
1171#define BTYPE(a_Type) ( (a_Type) & N_BTMASK )
1172#define ISPTR(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT) )
1173#define ISFCN(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT) )
1174#define ISARY(a_Type) ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT) )
1175#define ISTAG(a_StorageClass) ( (a_StorageClass) == IMAGE_SYM_CLASS_STRUCT_TAG \
1176 || (a_StorageClass) == IMAGE_SYM_CLASS_UNION_TAG \
1177 || (a_StorageClass) == IMAGE_SYM_CLASS_ENUM_TAG )
1178/** @} */
1179
1180
1181/**
1182 * COFF relocation table entry.
1183 *
1184 * @note The size of the structure is not a multiple of the largest member
1185 * (uint32_t), so odd relocation table entry members will have
1186 * misaligned uint32_t members.
1187 */
1188#pragma pack(1)
1189typedef struct _IMAGE_RELOCATION
1190{
1191 union
1192 {
1193 uint32_t VirtualAddress;
1194 uint32_t RelocCount;
1195 } u;
1196 uint32_t SymbolTableIndex;
1197 uint16_t Type;
1198} IMAGE_RELOCATION;
1199#pragma pack()
1200/** The size of a COFF relocation entry. */
1201#define IMAGE_SIZEOF_RELOCATION 10
1202AssertCompileSize(IMAGE_RELOCATION, IMAGE_SIZEOF_RELOCATION);
1203typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
1204typedef IMAGE_RELOCATION const *PCIMAGE_RELOCATION;
1205
1206
1207/** @name IMAGE_REL_AMD64_XXX - COFF relocations for AMD64 CPUs.
1208 * Used by IMAGE_RELOCATION::Type.
1209 * @{ */
1210#define IMAGE_REL_AMD64_ABSOLUTE UINT16_C(0x0000)
1211#define IMAGE_REL_AMD64_ADDR64 UINT16_C(0x0001)
1212#define IMAGE_REL_AMD64_ADDR32 UINT16_C(0x0002)
1213#define IMAGE_REL_AMD64_ADDR32NB UINT16_C(0x0003)
1214#define IMAGE_REL_AMD64_REL32 UINT16_C(0x0004)
1215#define IMAGE_REL_AMD64_REL32_1 UINT16_C(0x0005)
1216#define IMAGE_REL_AMD64_REL32_2 UINT16_C(0x0006)
1217#define IMAGE_REL_AMD64_REL32_3 UINT16_C(0x0007)
1218#define IMAGE_REL_AMD64_REL32_4 UINT16_C(0x0008)
1219#define IMAGE_REL_AMD64_REL32_5 UINT16_C(0x0009)
1220#define IMAGE_REL_AMD64_SECTION UINT16_C(0x000a)
1221#define IMAGE_REL_AMD64_SECREL UINT16_C(0x000b)
1222#define IMAGE_REL_AMD64_SECREL7 UINT16_C(0x000c)
1223#define IMAGE_REL_AMD64_TOKEN UINT16_C(0x000d)
1224#define IMAGE_REL_AMD64_SREL32 UINT16_C(0x000e)
1225#define IMAGE_REL_AMD64_PAIR UINT16_C(0x000f)
1226#define IMAGE_REL_AMD64_SSPAN32 UINT16_C(0x0010)
1227/** @} */
1228
1229/** @name ARM IMAGE_REL_ARM_XXX - COFF relocations for ARM CPUs.
1230 * Used by IMAGE_RELOCATION::Type.
1231 * @{ */
1232#define IMAGE_REL_ARM_ABSOLUTE UINT16_C(0x0000)
1233#define IMAGE_REL_ARM_ADDR32 UINT16_C(0x0001)
1234#define IMAGE_REL_ARM_ADDR32NB UINT16_C(0x0002)
1235#define IMAGE_REL_ARM_BRANCH24 UINT16_C(0x0003)
1236#define IMAGE_REL_ARM_BRANCH11 UINT16_C(0x0004)
1237#define IMAGE_REL_ARM_TOKEN UINT16_C(0x0005)
1238#define IMAGE_REL_ARM_BLX24 UINT16_C(0x0008)
1239#define IMAGE_REL_ARM_BLX11 UINT16_C(0x0009)
1240#define IMAGE_REL_ARM_SECTION UINT16_C(0x000e)
1241#define IMAGE_REL_ARM_SECREL UINT16_C(0x000f)
1242#define IMAGE_REL_ARM_MOV32A UINT16_C(0x0010)
1243#define IMAGE_REL_ARM_MOV32T UINT16_C(0x0011)
1244#define IMAGE_REL_ARM_BRANCH20T UINT16_C(0x0012)
1245#define IMAGE_REL_ARM_BRANCH24T UINT16_C(0x0014)
1246#define IMAGE_REL_ARM_BLX23T UINT16_C(0x0015)
1247/** @} */
1248
1249/** @name IMAGE_REL_ARM64_XXX - COFF relocations for ARMv8 CPUs (64-bit).
1250 * Used by IMAGE_RELOCATION::Type.
1251 * @{ */
1252#define IMAGE_REL_ARM64_ABSOLUTE UINT16_C(0x0000)
1253#define IMAGE_REL_ARM64_ADDR32 UINT16_C(0x0001)
1254#define IMAGE_REL_ARM64_ADDR32NB UINT16_C(0x0002)
1255#define IMAGE_REL_ARM64_BRANCH26 UINT16_C(0x0003)
1256#define IMAGE_REL_ARM64_PAGEBASE_REL21 UINT16_C(0x0004)
1257#define IMAGE_REL_ARM64_REL21 UINT16_C(0x0005)
1258#define IMAGE_REL_ARM64_PAGEOFFSET_12A UINT16_C(0x0006)
1259#define IMAGE_REL_ARM64_PAGEOFFSET_12L UINT16_C(0x0007)
1260#define IMAGE_REL_ARM64_SECREL UINT16_C(0x0008)
1261#define IMAGE_REL_ARM64_SECREL_LOW12A UINT16_C(0x0009)
1262#define IMAGE_REL_ARM64_SECREL_HIGH12A UINT16_C(0x000a)
1263#define IMAGE_REL_ARM64_SECREL_LOW12L UINT16_C(0x000b)
1264#define IMAGE_REL_ARM64_TOKEN UINT16_C(0x000c)
1265#define IMAGE_REL_ARM64_SECTION UINT16_C(0x000d)
1266#define IMAGE_REL_ARM64_ADDR64 UINT16_C(0x000e)
1267/** @} */
1268
1269/** @name IMAGE_REL_SH3_XXX - COFF relocation for Hitachi SuperH CPUs.
1270 * Used by IMAGE_RELOCATION::Type.
1271 * @{ */
1272#define IMAGE_REL_SH3_ABSOLUTE UINT16_C(0x0000)
1273#define IMAGE_REL_SH3_DIRECT16 UINT16_C(0x0001)
1274#define IMAGE_REL_SH3_DIRECT32 UINT16_C(0x0002)
1275#define IMAGE_REL_SH3_DIRECT8 UINT16_C(0x0003)
1276#define IMAGE_REL_SH3_DIRECT8_WORD UINT16_C(0x0004)
1277#define IMAGE_REL_SH3_DIRECT8_LONG UINT16_C(0x0005)
1278#define IMAGE_REL_SH3_DIRECT4 UINT16_C(0x0006)
1279#define IMAGE_REL_SH3_DIRECT4_WORD UINT16_C(0x0007)
1280#define IMAGE_REL_SH3_DIRECT4_LONG UINT16_C(0x0008)
1281#define IMAGE_REL_SH3_PCREL8_WORD UINT16_C(0x0009)
1282#define IMAGE_REL_SH3_PCREL8_LONG UINT16_C(0x000a)
1283#define IMAGE_REL_SH3_PCREL12_WORD UINT16_C(0x000b)
1284#define IMAGE_REL_SH3_STARTOF_SECTION UINT16_C(0x000c)
1285#define IMAGE_REL_SH3_SIZEOF_SECTION UINT16_C(0x000d)
1286#define IMAGE_REL_SH3_SECTION UINT16_C(0x000e)
1287#define IMAGE_REL_SH3_SECREL UINT16_C(0x000f)
1288#define IMAGE_REL_SH3_DIRECT32_NB UINT16_C(0x0010)
1289#define IMAGE_REL_SH3_GPREL4_LONG UINT16_C(0x0011)
1290#define IMAGE_REL_SH3_TOKEN UINT16_C(0x0012)
1291#define IMAGE_REL_SHM_PCRELPT UINT16_C(0x0013)
1292#define IMAGE_REL_SHM_REFLO UINT16_C(0x0014)
1293#define IMAGE_REL_SHM_REFHALF UINT16_C(0x0015)
1294#define IMAGE_REL_SHM_RELLO UINT16_C(0x0016)
1295#define IMAGE_REL_SHM_RELHALF UINT16_C(0x0017)
1296#define IMAGE_REL_SHM_PAIR UINT16_C(0x0018)
1297#define IMAGE_REL_SHM_NOMODE UINT16_C(0x8000)
1298/** @} */
1299
1300/** @name IMAGE_REL_PPC_XXX - COFF relocations for IBM PowerPC CPUs.
1301 * Used by IMAGE_RELOCATION::Type.
1302 * @{ */
1303#define IMAGE_REL_PPC_ABSOLUTE UINT16_C(0x0000)
1304#define IMAGE_REL_PPC_ADDR64 UINT16_C(0x0001)
1305#define IMAGE_REL_PPC_ADDR32 UINT16_C(0x0002)
1306#define IMAGE_REL_PPC_ADDR24 UINT16_C(0x0003)
1307#define IMAGE_REL_PPC_ADDR16 UINT16_C(0x0004)
1308#define IMAGE_REL_PPC_ADDR14 UINT16_C(0x0005)
1309#define IMAGE_REL_PPC_REL24 UINT16_C(0x0006)
1310#define IMAGE_REL_PPC_REL14 UINT16_C(0x0007)
1311#define IMAGE_REL_PPC_ADDR32NB UINT16_C(0x000a)
1312#define IMAGE_REL_PPC_SECREL UINT16_C(0x000b)
1313#define IMAGE_REL_PPC_SECTION UINT16_C(0x000c)
1314#define IMAGE_REL_PPC_SECREL16 UINT16_C(0x000f)
1315#define IMAGE_REL_PPC_REFHI UINT16_C(0x0010)
1316#define IMAGE_REL_PPC_REFLO UINT16_C(0x0011)
1317#define IMAGE_REL_PPC_PAIR UINT16_C(0x0012)
1318#define IMAGE_REL_PPC_SECRELLO UINT16_C(0x0013)
1319#define IMAGE_REL_PPC_GPREL UINT16_C(0x0015)
1320#define IMAGE_REL_PPC_TOKEN UINT16_C(0x0016)
1321/** @} */
1322
1323/** @name IMAGE_REL_I386_XXX - COFF relocations for x86 CPUs.
1324 * Used by IMAGE_RELOCATION::Type.
1325 * @{ */
1326#define IMAGE_REL_I386_ABSOLUTE UINT16_C(0x0000)
1327#define IMAGE_REL_I386_DIR16 UINT16_C(0x0001)
1328#define IMAGE_REL_I386_REL16 UINT16_C(0x0002)
1329#define IMAGE_REL_I386_DIR32 UINT16_C(0x0006)
1330#define IMAGE_REL_I386_DIR32NB UINT16_C(0x0007)
1331#define IMAGE_REL_I386_SEG12 UINT16_C(0x0009)
1332#define IMAGE_REL_I386_SECTION UINT16_C(0x000A)
1333#define IMAGE_REL_I386_SECREL UINT16_C(0x000B)
1334#define IMAGE_REL_I386_TOKEN UINT16_C(0x000C)
1335#define IMAGE_REL_I386_SECREL7 UINT16_C(0x000D)
1336#define IMAGE_REL_I386_REL32 UINT16_C(0x0014)
1337/** @} */
1338
1339/** @name IMAGE_REL_IA64_XXX - COFF relocations for "Itanic" CPUs.
1340 * @{ */
1341#define IMAGE_REL_IA64_ABSOLUTE UINT16_C(0x0000)
1342#define IMAGE_REL_IA64_IMM14 UINT16_C(0x0001)
1343#define IMAGE_REL_IA64_IMM22 UINT16_C(0x0002)
1344#define IMAGE_REL_IA64_IMM64 UINT16_C(0x0003)
1345#define IMAGE_REL_IA64_DIR32 UINT16_C(0x0004)
1346#define IMAGE_REL_IA64_DIR64 UINT16_C(0x0005)
1347#define IMAGE_REL_IA64_PCREL21B UINT16_C(0x0006)
1348#define IMAGE_REL_IA64_PCREL21M UINT16_C(0x0007)
1349#define IMAGE_REL_IA64_PCREL21F UINT16_C(0x0008)
1350#define IMAGE_REL_IA64_GPREL22 UINT16_C(0x0009)
1351#define IMAGE_REL_IA64_LTOFF22 UINT16_C(0x000a)
1352#define IMAGE_REL_IA64_SECTION UINT16_C(0x000b)
1353#define IMAGE_REL_IA64_SECREL22 UINT16_C(0x000c)
1354#define IMAGE_REL_IA64_SECREL64I UINT16_C(0x000d)
1355#define IMAGE_REL_IA64_SECREL32 UINT16_C(0x000e)
1356#define IMAGE_REL_IA64_DIR32NB UINT16_C(0x0010)
1357#define IMAGE_REL_IA64_SREL14 UINT16_C(0x0011)
1358#define IMAGE_REL_IA64_SREL22 UINT16_C(0x0012)
1359#define IMAGE_REL_IA64_SREL32 UINT16_C(0x0013)
1360#define IMAGE_REL_IA64_UREL32 UINT16_C(0x0014)
1361#define IMAGE_REL_IA64_PCREL60X UINT16_C(0x0015)
1362#define IMAGE_REL_IA64_PCREL60B UINT16_C(0x0016)
1363#define IMAGE_REL_IA64_PCREL60F UINT16_C(0x0017)
1364#define IMAGE_REL_IA64_PCREL60I UINT16_C(0x0018)
1365#define IMAGE_REL_IA64_PCREL60M UINT16_C(0x0019)
1366#define IMAGE_REL_IA64_IMMGPREL64 UINT16_C(0x001a)
1367#define IMAGE_REL_IA64_TOKEN UINT16_C(0x001b)
1368#define IMAGE_REL_IA64_GPREL32 UINT16_C(0x001c)
1369#define IMAGE_REL_IA64_ADDEND UINT16_C(0x001f)
1370/** @} */
1371
1372/** @name IMAGE_REL_MIPS_XXX - COFF relocations for MIPS CPUs.
1373 * Used by IMAGE_RELOCATION::Type.
1374 * @{ */
1375#define IMAGE_REL_MIPS_ABSOLUTE UINT16_C(0x0000)
1376#define IMAGE_REL_MIPS_REFHALF UINT16_C(0x0001)
1377#define IMAGE_REL_MIPS_REFWORD UINT16_C(0x0002)
1378#define IMAGE_REL_MIPS_JMPADDR UINT16_C(0x0003)
1379#define IMAGE_REL_MIPS_REFHI UINT16_C(0x0004)
1380#define IMAGE_REL_MIPS_REFLO UINT16_C(0x0005)
1381#define IMAGE_REL_MIPS_GPREL UINT16_C(0x0006)
1382#define IMAGE_REL_MIPS_LITERAL UINT16_C(0x0007)
1383#define IMAGE_REL_MIPS_SECTION UINT16_C(0x000a)
1384#define IMAGE_REL_MIPS_SECREL UINT16_C(0x000b)
1385#define IMAGE_REL_MIPS_SECRELLO UINT16_C(0x000c)
1386#define IMAGE_REL_MIPS_SECRELHI UINT16_C(0x000d)
1387#define IMAGE_REL_MIPS_JMPADDR16 UINT16_C(0x0010)
1388#define IMAGE_REL_MIPS_REFWORDNB UINT16_C(0x0022)
1389#define IMAGE_REL_MIPS_PAIR UINT16_C(0x0025)
1390/** @} */
1391
1392/** @name IMAGE_REL_M32R_XXX - COFF relocations for Mitsubishi M32R CPUs.
1393 * Used by IMAGE_RELOCATION::Type.
1394 * @{ */
1395#define IMAGE_REL_M32R_ABSOLUTE UINT16_C(0x0000)
1396#define IMAGE_REL_M32R_ADDR32 UINT16_C(0x0001)
1397#define IMAGE_REL_M32R_ADDR32NB UINT16_C(0x0002)
1398#define IMAGE_REL_M32R_ADDR24 UINT16_C(0x0003)
1399#define IMAGE_REL_M32R_GPREL16 UINT16_C(0x0004)
1400#define IMAGE_REL_M32R_PCREL24 UINT16_C(0x0005)
1401#define IMAGE_REL_M32R_PCREL16 UINT16_C(0x0006)
1402#define IMAGE_REL_M32R_PCREL8 UINT16_C(0x0007)
1403#define IMAGE_REL_M32R_REFHALF UINT16_C(0x0008)
1404#define IMAGE_REL_M32R_REFHI UINT16_C(0x0009)
1405#define IMAGE_REL_M32R_REFLO UINT16_C(0x000a)
1406#define IMAGE_REL_M32R_PAIR UINT16_C(0x000b)
1407#define IMAGE_REL_M32R_SECTION UINT16_C(0x000c)
1408#define IMAGE_REL_M32R_SECREL UINT16_C(0x000d)
1409#define IMAGE_REL_M32R_TOKEN UINT16_C(0x000e)
1410/** @} */
1411
1412
1413/** @} */
1414
1415#endif
1416
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