1 | /* $Id: ldrPE.h 46266 2013-05-25 19:51:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Windows NT PE Structures and Constants.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 ___internal_ldrPE_h
|
---|
28 | #define ___internal_ldrPE_h
|
---|
29 |
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/assert.h>
|
---|
32 |
|
---|
33 | #pragma pack(4) /** @todo Necessary? */
|
---|
34 |
|
---|
35 |
|
---|
36 | /*******************************************************************************
|
---|
37 | * Defined Constants And Macros *
|
---|
38 | *******************************************************************************/
|
---|
39 | #define IMAGE_NT_SIGNATURE 0x00004550
|
---|
40 |
|
---|
41 | /* file header */
|
---|
42 | #define IMAGE_FILE_MACHINE_I386 0x014c
|
---|
43 | #define IMAGE_FILE_MACHINE_AMD64 0x8664
|
---|
44 |
|
---|
45 | #define IMAGE_FILE_RELOCS_STRIPPED 0x0001
|
---|
46 | #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
|
---|
47 | #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
|
---|
48 | #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
|
---|
49 | #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
|
---|
50 | #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
|
---|
51 | #define IMAGE_FILE_16BIT_MACHINE 0x0040
|
---|
52 | #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
|
---|
53 | #define IMAGE_FILE_32BIT_MACHINE 0x0100
|
---|
54 | #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
|
---|
55 | #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
|
---|
56 | #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
|
---|
57 | #define IMAGE_FILE_SYSTEM 0x1000
|
---|
58 | #define IMAGE_FILE_DLL 0x2000
|
---|
59 | #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
|
---|
60 | #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
|
---|
61 |
|
---|
62 |
|
---|
63 | /* optional header */
|
---|
64 | #define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10B
|
---|
65 | #define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20B
|
---|
66 |
|
---|
67 | #define IMAGE_SUBSYSTEM_UNKNOWN 0x0
|
---|
68 | #define IMAGE_SUBSYSTEM_NATIVE 0x1
|
---|
69 | #define IMAGE_SUBSYSTEM_WINDOWS_GUI 0x2
|
---|
70 | #define IMAGE_SUBSYSTEM_WINDOWS_CUI 0x3
|
---|
71 | #define IMAGE_SUBSYSTEM_OS2_GUI 0x4
|
---|
72 | #define IMAGE_SUBSYSTEM_OS2_CUI 0x5
|
---|
73 | #define IMAGE_SUBSYSTEM_POSIX_CUI 0x7
|
---|
74 |
|
---|
75 | #define IMAGE_LIBRARY_PROCESS_INIT 0x0001
|
---|
76 | #define IMAGE_LIBRARY_PROCESS_TERM 0x0002
|
---|
77 | #define IMAGE_LIBRARY_THREAD_INIT 0x0004
|
---|
78 | #define IMAGE_LIBRARY_THREAD_TERM 0x0008
|
---|
79 | #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
|
---|
80 | #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
|
---|
81 | #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
|
---|
82 | #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
|
---|
83 | #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
|
---|
84 |
|
---|
85 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 0x10
|
---|
86 |
|
---|
87 | #define IMAGE_DIRECTORY_ENTRY_EXPORT 0x0
|
---|
88 | #define IMAGE_DIRECTORY_ENTRY_IMPORT 0x1
|
---|
89 | #define IMAGE_DIRECTORY_ENTRY_RESOURCE 0x2
|
---|
90 | #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 0x3
|
---|
91 | #define IMAGE_DIRECTORY_ENTRY_SECURITY 0x4
|
---|
92 | #define IMAGE_DIRECTORY_ENTRY_BASERELOC 0x5
|
---|
93 | #define IMAGE_DIRECTORY_ENTRY_DEBUG 0x6
|
---|
94 | #define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 0x7
|
---|
95 | #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
|
---|
96 | #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 0x8
|
---|
97 | #define IMAGE_DIRECTORY_ENTRY_TLS 0x9
|
---|
98 | #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 0xa
|
---|
99 | #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 0xb
|
---|
100 | #define IMAGE_DIRECTORY_ENTRY_IAT 0xc
|
---|
101 | #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 0xd
|
---|
102 | #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 0xe
|
---|
103 |
|
---|
104 |
|
---|
105 | /* section header */
|
---|
106 | #define IMAGE_SIZEOF_SHORT_NAME 0x8
|
---|
107 |
|
---|
108 | #define IMAGE_SCN_TYPE_REG 0x00000000
|
---|
109 | #define IMAGE_SCN_TYPE_DSECT 0x00000001
|
---|
110 | #define IMAGE_SCN_TYPE_NOLOAD 0x00000002
|
---|
111 | #define IMAGE_SCN_TYPE_GROUP 0x00000004
|
---|
112 | #define IMAGE_SCN_TYPE_NO_PAD 0x00000008
|
---|
113 | #define IMAGE_SCN_TYPE_COPY 0x00000010
|
---|
114 |
|
---|
115 | #define IMAGE_SCN_CNT_CODE 0x00000020
|
---|
116 | #define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
|
---|
117 | #define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
|
---|
118 |
|
---|
119 | #define IMAGE_SCN_LNK_OTHER 0x00000100
|
---|
120 | #define IMAGE_SCN_LNK_INFO 0x00000200
|
---|
121 | #define IMAGE_SCN_TYPE_OVER 0x00000400
|
---|
122 | #define IMAGE_SCN_LNK_REMOVE 0x00000800
|
---|
123 | #define IMAGE_SCN_LNK_COMDAT 0x00001000
|
---|
124 | #define IMAGE_SCN_MEM_PROTECTED 0x00004000
|
---|
125 | #define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000
|
---|
126 | #define IMAGE_SCN_GPREL 0x00008000
|
---|
127 | #define IMAGE_SCN_MEM_FARDATA 0x00008000
|
---|
128 | #define IMAGE_SCN_MEM_SYSHEAP 0x00010000
|
---|
129 | #define IMAGE_SCN_MEM_PURGEABLE 0x00020000
|
---|
130 | #define IMAGE_SCN_MEM_16BIT 0x00020000
|
---|
131 | #define IMAGE_SCN_MEM_LOCKED 0x00040000
|
---|
132 | #define IMAGE_SCN_MEM_PRELOAD 0x00080000
|
---|
133 |
|
---|
134 | #define IMAGE_SCN_ALIGN_1BYTES 0x00100000
|
---|
135 | #define IMAGE_SCN_ALIGN_2BYTES 0x00200000
|
---|
136 | #define IMAGE_SCN_ALIGN_4BYTES 0x00300000
|
---|
137 | #define IMAGE_SCN_ALIGN_8BYTES 0x00400000
|
---|
138 | #define IMAGE_SCN_ALIGN_16BYTES 0x00500000
|
---|
139 | #define IMAGE_SCN_ALIGN_32BYTES 0x00600000
|
---|
140 | #define IMAGE_SCN_ALIGN_64BYTES 0x00700000
|
---|
141 | #define IMAGE_SCN_ALIGN_128BYTES 0x00800000
|
---|
142 | #define IMAGE_SCN_ALIGN_256BYTES 0x00900000
|
---|
143 | #define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
|
---|
144 | #define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
|
---|
145 | #define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
|
---|
146 | #define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
|
---|
147 | #define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
|
---|
148 | #define IMAGE_SCN_ALIGN_MASK 0x00F00000
|
---|
149 | #define IMAGE_SCN_ALIGN_SHIFT 20
|
---|
150 |
|
---|
151 | #define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
|
---|
152 | #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
|
---|
153 | #define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
|
---|
154 | #define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
|
---|
155 | #define IMAGE_SCN_MEM_SHARED 0x10000000
|
---|
156 | #define IMAGE_SCN_MEM_EXECUTE 0x20000000
|
---|
157 | #define IMAGE_SCN_MEM_READ 0x40000000
|
---|
158 | #define IMAGE_SCN_MEM_WRITE 0x80000000
|
---|
159 |
|
---|
160 |
|
---|
161 | /* relocations */
|
---|
162 | #define IMAGE_REL_BASED_ABSOLUTE 0x0
|
---|
163 | #define IMAGE_REL_BASED_HIGH 0x1
|
---|
164 | #define IMAGE_REL_BASED_LOW 0x2
|
---|
165 | #define IMAGE_REL_BASED_HIGHLOW 0x3
|
---|
166 | #define IMAGE_REL_BASED_HIGHADJ 0x4
|
---|
167 | #define IMAGE_REL_BASED_MIPS_JMPADDR 0x5
|
---|
168 | #define IMAGE_REL_BASED_MIPS_JMPADDR16 0x9
|
---|
169 | #define IMAGE_REL_BASED_IA64_IMM64 0x9
|
---|
170 | #define IMAGE_REL_BASED_DIR64 0xa
|
---|
171 | #define IMAGE_REL_BASED_HIGH3ADJ 0xb
|
---|
172 |
|
---|
173 |
|
---|
174 | /* imports */
|
---|
175 | #define IMAGE_ORDINAL_FLAG32 0x80000000
|
---|
176 | #define IMAGE_ORDINAL32(ord) ((ord) & 0xffff)
|
---|
177 | #define IMAGE_SNAP_BY_ORDINAL32(ord) (!!((ord) & IMAGE_ORDINAL_FLAG32))
|
---|
178 |
|
---|
179 | #define IMAGE_ORDINAL_FLAG64 0x8000000000000000ULL
|
---|
180 | #define IMAGE_ORDINAL64(ord) ((ord) & 0xffff)
|
---|
181 | #define IMAGE_SNAP_BY_ORDINAL64(ord) (!!((ord) & IMAGE_ORDINAL_FLAG64))
|
---|
182 |
|
---|
183 |
|
---|
184 | /* debug dir */
|
---|
185 | #define IMAGE_DEBUG_TYPE_UNKNOWN UINT32_C(0x0)
|
---|
186 | #define IMAGE_DEBUG_TYPE_COFF UINT32_C(0x1)
|
---|
187 | #define IMAGE_DEBUG_TYPE_CODEVIEW UINT32_C(0x2)
|
---|
188 | #define IMAGE_DEBUG_TYPE_FPO UINT32_C(0x3)
|
---|
189 | #define IMAGE_DEBUG_TYPE_MISC UINT32_C(0x4)
|
---|
190 | #define IMAGE_DEBUG_TYPE_EXCEPTION UINT32_C(0x5)
|
---|
191 | #define IMAGE_DEBUG_TYPE_FIXUP UINT32_C(0x6)
|
---|
192 | #define IMAGE_DEBUG_TYPE_OMAP_TO_SRC UINT32_C(0x7)
|
---|
193 | #define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC UINT32_C(0x8)
|
---|
194 | #define IMAGE_DEBUG_TYPE_BORLAND UINT32_C(0x9)
|
---|
195 | #define IMAGE_DEBUG_TYPE_RESERVED10 UINT32_C(0x10)
|
---|
196 |
|
---|
197 | #define IMAGE_DEBUG_MISC_EXENAME UINT32_C(1)
|
---|
198 |
|
---|
199 | /* security directory */
|
---|
200 | #define WIN_CERT_REVISION_1_0 UINT16_C(0x0100)
|
---|
201 | #define WIN_CERT_REVISION_2_0 UINT16_C(0x0200)
|
---|
202 |
|
---|
203 | #define WIN_CERT_TYPE_X509 UINT16_C(1)
|
---|
204 | #define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2)
|
---|
205 | #define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3)
|
---|
206 | #define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4)
|
---|
207 | #define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0)
|
---|
208 | #define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1)
|
---|
209 |
|
---|
210 |
|
---|
211 | /* For .DBG files. */
|
---|
212 | #define IMAGE_SEPARATE_DEBUG_SIGNATURE UINT16_C(0x4944)
|
---|
213 |
|
---|
214 |
|
---|
215 |
|
---|
216 | /*******************************************************************************
|
---|
217 | * Structures and Typedefs *
|
---|
218 | *******************************************************************************/
|
---|
219 | typedef struct _IMAGE_FILE_HEADER
|
---|
220 | {
|
---|
221 | uint16_t Machine; /**< 0x00 */
|
---|
222 | uint16_t NumberOfSections; /**< 0x02 */
|
---|
223 | uint32_t TimeDateStamp; /**< 0x04 */
|
---|
224 | uint32_t PointerToSymbolTable; /**< 0x08 */
|
---|
225 | uint32_t NumberOfSymbols; /**< 0x0c */
|
---|
226 | uint16_t SizeOfOptionalHeader; /**< 0x10 */
|
---|
227 | uint16_t Characteristics; /**< 0x12 */
|
---|
228 | } IMAGE_FILE_HEADER; /* size: 0x14 */
|
---|
229 | AssertCompileSize(IMAGE_FILE_HEADER, 0x14);
|
---|
230 | typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
|
---|
231 | typedef IMAGE_FILE_HEADER const *PCIMAGE_FILE_HEADER;
|
---|
232 |
|
---|
233 |
|
---|
234 | typedef struct _IMAGE_DATA_DIRECTORY
|
---|
235 | {
|
---|
236 | uint32_t VirtualAddress;
|
---|
237 | uint32_t Size;
|
---|
238 | } IMAGE_DATA_DIRECTORY;
|
---|
239 | typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
|
---|
240 | typedef IMAGE_DATA_DIRECTORY const *PCIMAGE_DATA_DIRECTORY;
|
---|
241 |
|
---|
242 |
|
---|
243 | typedef struct _IMAGE_OPTIONAL_HEADER32
|
---|
244 | {
|
---|
245 | uint16_t Magic; /**< 0x00 */
|
---|
246 | uint8_t MajorLinkerVersion; /**< 0x02 */
|
---|
247 | uint8_t MinorLinkerVersion; /**< 0x03 */
|
---|
248 | uint32_t SizeOfCode; /**< 0x04 */
|
---|
249 | uint32_t SizeOfInitializedData; /**< 0x08 */
|
---|
250 | uint32_t SizeOfUninitializedData; /**< 0x0c */
|
---|
251 | uint32_t AddressOfEntryPoint; /**< 0x10 */
|
---|
252 | uint32_t BaseOfCode; /**< 0x14 */
|
---|
253 | uint32_t BaseOfData; /**< 0x18 */
|
---|
254 | uint32_t ImageBase; /**< 0x1c */
|
---|
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 | uint32_t SizeOfStackReserve; /**< 0x48 */
|
---|
270 | uint32_t SizeOfStackCommit; /**< 0x4c */
|
---|
271 | uint32_t SizeOfHeapReserve; /**< 0x50 */
|
---|
272 | uint32_t SizeOfHeapCommit; /**< 0x54 */
|
---|
273 | uint32_t LoaderFlags; /**< 0x58 */
|
---|
274 | uint32_t NumberOfRvaAndSizes; /**< 0x5c */
|
---|
275 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x60; 0x10*8 = 0x80 */
|
---|
276 | } IMAGE_OPTIONAL_HEADER32; /* size: 0xe0 */
|
---|
277 | AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
|
---|
278 | typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
|
---|
279 | typedef IMAGE_OPTIONAL_HEADER32 const *PCIMAGE_OPTIONAL_HEADER32;
|
---|
280 |
|
---|
281 | typedef struct _IMAGE_OPTIONAL_HEADER64
|
---|
282 | {
|
---|
283 | uint16_t Magic; /**< 0x00 */
|
---|
284 | uint8_t MajorLinkerVersion; /**< 0x02 */
|
---|
285 | uint8_t MinorLinkerVersion; /**< 0x03 */
|
---|
286 | uint32_t SizeOfCode; /**< 0x04 */
|
---|
287 | uint32_t SizeOfInitializedData; /**< 0x08 */
|
---|
288 | uint32_t SizeOfUninitializedData; /**< 0x0c */
|
---|
289 | uint32_t AddressOfEntryPoint; /**< 0x10 */
|
---|
290 | uint32_t BaseOfCode; /**< 0x14 */
|
---|
291 | uint64_t ImageBase; /**< 0x18 */
|
---|
292 | uint32_t SectionAlignment; /**< 0x20 */
|
---|
293 | uint32_t FileAlignment; /**< 0x24 */
|
---|
294 | uint16_t MajorOperatingSystemVersion; /**< 0x28 */
|
---|
295 | uint16_t MinorOperatingSystemVersion; /**< 0x2a */
|
---|
296 | uint16_t MajorImageVersion; /**< 0x2c */
|
---|
297 | uint16_t MinorImageVersion; /**< 0x2e */
|
---|
298 | uint16_t MajorSubsystemVersion; /**< 0x30 */
|
---|
299 | uint16_t MinorSubsystemVersion; /**< 0x32 */
|
---|
300 | uint32_t Win32VersionValue; /**< 0x34 */
|
---|
301 | uint32_t SizeOfImage; /**< 0x38 */
|
---|
302 | uint32_t SizeOfHeaders; /**< 0x3c */
|
---|
303 | uint32_t CheckSum; /**< 0x40 */
|
---|
304 | uint16_t Subsystem; /**< 0x44 */
|
---|
305 | uint16_t DllCharacteristics; /**< 0x46 */
|
---|
306 | uint64_t SizeOfStackReserve; /**< 0x48 */
|
---|
307 | uint64_t SizeOfStackCommit; /**< 0x50 */
|
---|
308 | uint64_t SizeOfHeapReserve; /**< 0x58 */
|
---|
309 | uint64_t SizeOfHeapCommit; /**< 0x60 */
|
---|
310 | uint32_t LoaderFlags; /**< 0x68 */
|
---|
311 | uint32_t NumberOfRvaAndSizes; /**< 0x6c */
|
---|
312 | IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x70; 0x10*8 = 0x80 */
|
---|
313 | } IMAGE_OPTIONAL_HEADER64; /* size: 0xf0 */
|
---|
314 | typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
|
---|
315 | typedef IMAGE_OPTIONAL_HEADER64 const *PCIMAGE_OPTIONAL_HEADER64;
|
---|
316 |
|
---|
317 |
|
---|
318 | typedef struct _IMAGE_NT_HEADERS
|
---|
319 | {
|
---|
320 | uint32_t Signature; /**< 0x00 */
|
---|
321 | IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
|
---|
322 | IMAGE_OPTIONAL_HEADER32 OptionalHeader; /**< 0x18 */
|
---|
323 | } IMAGE_NT_HEADERS32; /* size: 0xf8 */
|
---|
324 | AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
|
---|
325 | AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
|
---|
326 | AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
|
---|
327 | typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
|
---|
328 | typedef IMAGE_NT_HEADERS32 const *PCIMAGE_NT_HEADERS32;
|
---|
329 |
|
---|
330 | typedef struct _IMAGE_NT_HEADERS64
|
---|
331 | {
|
---|
332 | uint32_t Signature; /**< 0x00 */
|
---|
333 | IMAGE_FILE_HEADER FileHeader; /**< 0x04 */
|
---|
334 | IMAGE_OPTIONAL_HEADER64 OptionalHeader; /**< 0x18 */
|
---|
335 | } IMAGE_NT_HEADERS64; /**< 0x108 */
|
---|
336 | AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
|
---|
337 | AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
|
---|
338 | AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
|
---|
339 | typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
|
---|
340 | typedef IMAGE_NT_HEADERS64 const *PCIMAGE_NT_HEADERS64;
|
---|
341 |
|
---|
342 |
|
---|
343 | typedef struct _IMAGE_SECTION_HEADER
|
---|
344 | {
|
---|
345 | uint8_t Name[IMAGE_SIZEOF_SHORT_NAME];
|
---|
346 | union
|
---|
347 | {
|
---|
348 | uint32_t PhysicalAddress;
|
---|
349 | uint32_t VirtualSize;
|
---|
350 | } Misc;
|
---|
351 | uint32_t VirtualAddress;
|
---|
352 | uint32_t SizeOfRawData;
|
---|
353 | uint32_t PointerToRawData;
|
---|
354 | uint32_t PointerToRelocations;
|
---|
355 | uint32_t PointerToLinenumbers;
|
---|
356 | uint16_t NumberOfRelocations;
|
---|
357 | uint16_t NumberOfLinenumbers;
|
---|
358 | uint32_t Characteristics;
|
---|
359 | } IMAGE_SECTION_HEADER;
|
---|
360 | typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
|
---|
361 | typedef IMAGE_SECTION_HEADER const *PCIMAGE_SECTION_HEADER;
|
---|
362 |
|
---|
363 |
|
---|
364 | typedef struct _IMAGE_BASE_RELOCATION
|
---|
365 | {
|
---|
366 | uint32_t VirtualAddress;
|
---|
367 | uint32_t SizeOfBlock;
|
---|
368 | } IMAGE_BASE_RELOCATION;
|
---|
369 | typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
|
---|
370 | typedef IMAGE_BASE_RELOCATION const *PCIMAGE_BASE_RELOCATION;
|
---|
371 |
|
---|
372 |
|
---|
373 | typedef struct _IMAGE_EXPORT_DIRECTORY
|
---|
374 | {
|
---|
375 | uint32_t Characteristics;
|
---|
376 | uint32_t TimeDateStamp;
|
---|
377 | uint16_t MajorVersion;
|
---|
378 | uint16_t MinorVersion;
|
---|
379 | uint32_t Name;
|
---|
380 | uint32_t Base;
|
---|
381 | uint32_t NumberOfFunctions;
|
---|
382 | uint32_t NumberOfNames;
|
---|
383 | uint32_t AddressOfFunctions;
|
---|
384 | uint32_t AddressOfNames;
|
---|
385 | uint32_t AddressOfNameOrdinals;
|
---|
386 | } IMAGE_EXPORT_DIRECTORY;
|
---|
387 | typedef IMAGE_EXPORT_DIRECTORY *PIMAGE_EXPORT_DIRECTORY;
|
---|
388 | typedef IMAGE_EXPORT_DIRECTORY const *PCIMAGE_EXPORT_DIRECTORY;
|
---|
389 |
|
---|
390 |
|
---|
391 | typedef struct _IMAGE_IMPORT_DESCRIPTOR
|
---|
392 | {
|
---|
393 | union
|
---|
394 | {
|
---|
395 | uint32_t Characteristics;
|
---|
396 | uint32_t OriginalFirstThunk;
|
---|
397 | } u;
|
---|
398 | uint32_t TimeDateStamp;
|
---|
399 | uint32_t ForwarderChain;
|
---|
400 | uint32_t Name;
|
---|
401 | uint32_t FirstThunk;
|
---|
402 | } IMAGE_IMPORT_DESCRIPTOR;
|
---|
403 | typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
|
---|
404 | typedef IMAGE_IMPORT_DESCRIPTOR const *PCIMAGE_IMPORT_DESCRIPTOR;
|
---|
405 |
|
---|
406 |
|
---|
407 | typedef struct _IMAGE_IMPORT_BY_NAME
|
---|
408 | {
|
---|
409 | uint16_t Hint;
|
---|
410 | uint8_t Name[1];
|
---|
411 | } IMAGE_IMPORT_BY_NAME;
|
---|
412 | typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
|
---|
413 | typedef IMAGE_IMPORT_BY_NAME const *PCIMAGE_IMPORT_BY_NAME;
|
---|
414 |
|
---|
415 |
|
---|
416 | /* The image_thunk_data32/64 structures are not very helpful except for getting RSI. keep them around till all the code has been converted. */
|
---|
417 | typedef struct _IMAGE_THUNK_DATA64
|
---|
418 | {
|
---|
419 | union
|
---|
420 | {
|
---|
421 | uint64_t ForwarderString;
|
---|
422 | uint64_t Function;
|
---|
423 | uint64_t Ordinal;
|
---|
424 | uint64_t AddressOfData;
|
---|
425 | } u1;
|
---|
426 | } IMAGE_THUNK_DATA64;
|
---|
427 | typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
|
---|
428 | typedef IMAGE_THUNK_DATA64 const *PCIMAGE_THUNK_DATA64;
|
---|
429 |
|
---|
430 | typedef struct _IMAGE_THUNK_DATA32
|
---|
431 | {
|
---|
432 | union
|
---|
433 | {
|
---|
434 | uint32_t ForwarderString;
|
---|
435 | uint32_t Function;
|
---|
436 | uint32_t Ordinal;
|
---|
437 | uint32_t AddressOfData;
|
---|
438 | } u1;
|
---|
439 | } IMAGE_THUNK_DATA32;
|
---|
440 | typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
|
---|
441 | typedef IMAGE_THUNK_DATA32 const *PCIMAGE_THUNK_DATA32;
|
---|
442 |
|
---|
443 |
|
---|
444 | typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32
|
---|
445 | {
|
---|
446 | uint32_t Size;
|
---|
447 | uint32_t TimeDateStamp;
|
---|
448 | uint16_t MajorVersion;
|
---|
449 | uint16_t MinorVersion;
|
---|
450 | uint32_t GlobalFlagsClear;
|
---|
451 | uint32_t GlobalFlagsSet;
|
---|
452 | uint32_t CriticalSectionDefaultTimeout;
|
---|
453 | uint32_t DeCommitFreeBlockThreshold;
|
---|
454 | uint32_t DeCommitTotalFreeThreshold;
|
---|
455 | uint32_t LockPrefixTable;
|
---|
456 | uint32_t MaximumAllocationSize;
|
---|
457 | uint32_t VirtualMemoryThreshold;
|
---|
458 | uint32_t ProcessHeapFlags;
|
---|
459 | uint32_t ProcessAffinityMask;
|
---|
460 | uint16_t CSDVersion;
|
---|
461 | uint16_t Reserved1;
|
---|
462 | uint32_t EditList;
|
---|
463 | uint32_t SecurityCookie;
|
---|
464 | uint32_t SEHandlerTable;
|
---|
465 | uint32_t SEHandlerCount;
|
---|
466 | } IMAGE_LOAD_CONFIG_DIRECTORY32;
|
---|
467 | typedef IMAGE_LOAD_CONFIG_DIRECTORY32 *PIMAGE_LOAD_CONFIG_DIRECTORY32;
|
---|
468 | typedef IMAGE_LOAD_CONFIG_DIRECTORY32 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32;
|
---|
469 |
|
---|
470 | typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64
|
---|
471 | {
|
---|
472 | uint32_t Size;
|
---|
473 | uint32_t TimeDateStamp;
|
---|
474 | uint16_t MajorVersion;
|
---|
475 | uint16_t MinorVersion;
|
---|
476 | uint32_t GlobalFlagsClear;
|
---|
477 | uint32_t GlobalFlagsSet;
|
---|
478 | uint32_t CriticalSectionDefaultTimeout;
|
---|
479 | uint64_t DeCommitFreeBlockThreshold;
|
---|
480 | uint64_t DeCommitTotalFreeThreshold;
|
---|
481 | uint64_t LockPrefixTable;
|
---|
482 | uint64_t MaximumAllocationSize;
|
---|
483 | uint64_t VirtualMemoryThreshold;
|
---|
484 | uint64_t ProcessAffinityMask;
|
---|
485 | uint32_t ProcessHeapFlags;
|
---|
486 | uint16_t CSDVersion;
|
---|
487 | uint16_t Reserved1;
|
---|
488 | uint64_t EditList;
|
---|
489 | uint64_t SecurityCookie;
|
---|
490 | uint64_t SEHandlerTable;
|
---|
491 | uint64_t SEHandlerCount;
|
---|
492 | } IMAGE_LOAD_CONFIG_DIRECTORY64;
|
---|
493 | typedef IMAGE_LOAD_CONFIG_DIRECTORY64 *PIMAGE_LOAD_CONFIG_DIRECTORY64;
|
---|
494 | typedef IMAGE_LOAD_CONFIG_DIRECTORY64 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64;
|
---|
495 |
|
---|
496 |
|
---|
497 | typedef struct _IMAGE_DEBUG_DIRECTORY
|
---|
498 | {
|
---|
499 | uint32_t Characteristics;
|
---|
500 | uint32_t TimeDateStamp;
|
---|
501 | uint16_t MajorVersion;
|
---|
502 | uint16_t MinorVersion;
|
---|
503 | uint32_t Type;
|
---|
504 | uint32_t SizeOfData;
|
---|
505 | uint32_t AddressOfRawData;
|
---|
506 | uint32_t PointerToRawData;
|
---|
507 | } IMAGE_DEBUG_DIRECTORY;
|
---|
508 | typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
|
---|
509 | typedef IMAGE_DEBUG_DIRECTORY const *PCIMAGE_DEBUG_DIRECTORY;
|
---|
510 |
|
---|
511 | typedef struct _IMAGE_DEBUG_MISC
|
---|
512 | {
|
---|
513 | uint32_t DataType;
|
---|
514 | uint32_t Length;
|
---|
515 | uint8_t Unicode;
|
---|
516 | uint8_t Reserved[3];
|
---|
517 | uint8_t Data[1];
|
---|
518 | } IMAGE_DEBUG_MISC;
|
---|
519 | typedef IMAGE_DEBUG_MISC *PIMAGE_DEBUG_MISC;
|
---|
520 | typedef IMAGE_DEBUG_MISC const *PCIMAGE_DEBUG_MISC;
|
---|
521 |
|
---|
522 |
|
---|
523 | typedef struct WIN_CERTIFICATE
|
---|
524 | {
|
---|
525 | uint32_t dwLength;
|
---|
526 | uint16_t wRevision;
|
---|
527 | uint16_t wCertificateType;
|
---|
528 | uint8_t bCertificate[8];
|
---|
529 | } WIN_CERTIFICATE;
|
---|
530 | typedef WIN_CERTIFICATE *PWIN_CERTIFICATE;
|
---|
531 | typedef WIN_CERTIFICATE const *PCWIN_CERTIFICATE;
|
---|
532 |
|
---|
533 |
|
---|
534 | /** The header of a .DBG file (NT4). */
|
---|
535 | typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
|
---|
536 | {
|
---|
537 | uint16_t Signature; /**< 0x00 */
|
---|
538 | uint16_t Flags; /**< 0x02 */
|
---|
539 | uint16_t Machine; /**< 0x04 */
|
---|
540 | uint16_t Characteristics; /**< 0x06 */
|
---|
541 | uint32_t TimeDateStamp; /**< 0x08 */
|
---|
542 | uint32_t CheckSum; /**< 0x0c */
|
---|
543 | uint32_t ImageBase; /**< 0x10 */
|
---|
544 | uint32_t SizeOfImage; /**< 0x14 */
|
---|
545 | uint32_t NumberOfSections; /**< 0x18 */
|
---|
546 | uint32_t ExportedNamesSize; /**< 0x1c */
|
---|
547 | uint32_t DebugDirectorySize; /**< 0x20 */
|
---|
548 | uint32_t SectionAlignment; /**< 0x24 */
|
---|
549 | uint32_t Reserved[2]; /**< 0x28 */
|
---|
550 | } IMAGE_SEPARATE_DEBUG_HEADER; /* size: 0x30 */
|
---|
551 | typedef IMAGE_SEPARATE_DEBUG_HEADER *PIMAGE_SEPARATE_DEBUG_HEADER;
|
---|
552 | typedef IMAGE_SEPARATE_DEBUG_HEADER const *PCIMAGE_SEPARATE_DEBUG_HEADER;
|
---|
553 |
|
---|
554 |
|
---|
555 | #pragma pack()
|
---|
556 |
|
---|
557 | #endif
|
---|
558 |
|
---|