1 | ;; @file
|
---|
2 | ; IPRT - Windows PE definitions for YASM/NASM.
|
---|
3 | ;
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
7 | ;
|
---|
8 | ; This file is part of VirtualBox base platform packages, as
|
---|
9 | ; available from https://www.virtualbox.org.
|
---|
10 | ;
|
---|
11 | ; This program is free software; you can redistribute it and/or
|
---|
12 | ; modify it under the terms of the GNU General Public License
|
---|
13 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
14 | ; License.
|
---|
15 | ;
|
---|
16 | ; This program is distributed in the hope that it will be useful, but
|
---|
17 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | ; General Public License for more details.
|
---|
20 | ;
|
---|
21 | ; You should have received a copy of the GNU General Public License
|
---|
22 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | ;
|
---|
24 | ; The contents of this file may alternatively be used under the terms
|
---|
25 | ; of the Common Development and Distribution License Version 1.0
|
---|
26 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | ; CDDL are applicable instead of those of the GPL.
|
---|
29 | ;
|
---|
30 | ; You may elect to license modified versions of this file under the
|
---|
31 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | ;
|
---|
33 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | ;
|
---|
35 |
|
---|
36 | %ifndef ___iprt_format_pe_mac
|
---|
37 | %define ___iprt_format_pe_mac
|
---|
38 |
|
---|
39 |
|
---|
40 | ;*******************************************************************************
|
---|
41 | ;* Header Files *
|
---|
42 | ;*******************************************************************************
|
---|
43 | %include "iprt/asmdefs.mac"
|
---|
44 |
|
---|
45 |
|
---|
46 | ;*******************************************************************************
|
---|
47 | ;* Defined Constants And Macros *
|
---|
48 | ;*******************************************************************************
|
---|
49 | %define IMAGE_NT_SIGNATURE 0x00004550
|
---|
50 |
|
---|
51 | ; file header
|
---|
52 | %define IMAGE_FILE_MACHINE_I386 0x014c
|
---|
53 | %define IMAGE_FILE_MACHINE_AMD64 0x8664
|
---|
54 |
|
---|
55 | %define IMAGE_FILE_RELOCS_STRIPPED 0x0001
|
---|
56 | %define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
|
---|
57 | %define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
|
---|
58 | %define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
|
---|
59 | %define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
|
---|
60 | %define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
|
---|
61 | %define IMAGE_FILE_16BIT_MACHINE 0x0040
|
---|
62 | %define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
|
---|
63 | %define IMAGE_FILE_32BIT_MACHINE 0x0100
|
---|
64 | %define IMAGE_FILE_DEBUG_STRIPPED 0x0200
|
---|
65 | %define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
|
---|
66 | %define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
|
---|
67 | %define IMAGE_FILE_SYSTEM 0x1000
|
---|
68 | %define IMAGE_FILE_DLL 0x2000
|
---|
69 | %define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
|
---|
70 | %define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
|
---|
71 |
|
---|
72 |
|
---|
73 | ; optional header
|
---|
74 | %define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10B
|
---|
75 | %define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20B
|
---|
76 |
|
---|
77 | %define IMAGE_SUBSYSTEM_UNKNOWN 0x0
|
---|
78 | %define IMAGE_SUBSYSTEM_NATIVE 0x1
|
---|
79 | %define IMAGE_SUBSYSTEM_WINDOWS_GUI 0x2
|
---|
80 | %define IMAGE_SUBSYSTEM_WINDOWS_CUI 0x3
|
---|
81 | %define IMAGE_SUBSYSTEM_OS2_GUI 0x4
|
---|
82 | %define IMAGE_SUBSYSTEM_OS2_CUI 0x5
|
---|
83 | %define IMAGE_SUBSYSTEM_POSIX_CUI 0x7
|
---|
84 |
|
---|
85 | %define IMAGE_LIBRARY_PROCESS_INIT 0x0001
|
---|
86 | %define IMAGE_LIBRARY_PROCESS_TERM 0x0002
|
---|
87 | %define IMAGE_LIBRARY_THREAD_INIT 0x0004
|
---|
88 | %define IMAGE_LIBRARY_THREAD_TERM 0x0008
|
---|
89 | %define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
|
---|
90 | %define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
|
---|
91 | %define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
|
---|
92 | %define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
|
---|
93 | %define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
|
---|
94 |
|
---|
95 | %define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 0x10
|
---|
96 |
|
---|
97 | %define IMAGE_DIRECTORY_ENTRY_EXPORT 0x0
|
---|
98 | %define IMAGE_DIRECTORY_ENTRY_IMPORT 0x1
|
---|
99 | %define IMAGE_DIRECTORY_ENTRY_RESOURCE 0x2
|
---|
100 | %define IMAGE_DIRECTORY_ENTRY_EXCEPTION 0x3
|
---|
101 | %define IMAGE_DIRECTORY_ENTRY_SECURITY 0x4
|
---|
102 | %define IMAGE_DIRECTORY_ENTRY_BASERELOC 0x5
|
---|
103 | %define IMAGE_DIRECTORY_ENTRY_DEBUG 0x6
|
---|
104 | %define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 0x7
|
---|
105 | %define IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
|
---|
106 | %define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 0x8
|
---|
107 | %define IMAGE_DIRECTORY_ENTRY_TLS 0x9
|
---|
108 | %define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 0xa
|
---|
109 | %define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 0xb
|
---|
110 | %define IMAGE_DIRECTORY_ENTRY_IAT 0xc
|
---|
111 | %define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 0xd
|
---|
112 | %define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 0xe
|
---|
113 |
|
---|
114 |
|
---|
115 | ; section header
|
---|
116 | %define IMAGE_SIZEOF_SHORT_NAME 0x8
|
---|
117 |
|
---|
118 | %define IMAGE_SCN_TYPE_REG 0x00000000
|
---|
119 | %define IMAGE_SCN_TYPE_DSECT 0x00000001
|
---|
120 | %define IMAGE_SCN_TYPE_NOLOAD 0x00000002
|
---|
121 | %define IMAGE_SCN_TYPE_GROUP 0x00000004
|
---|
122 | %define IMAGE_SCN_TYPE_NO_PAD 0x00000008
|
---|
123 | %define IMAGE_SCN_TYPE_COPY 0x00000010
|
---|
124 |
|
---|
125 | %define IMAGE_SCN_CNT_CODE 0x00000020
|
---|
126 | %define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
|
---|
127 | %define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
|
---|
128 |
|
---|
129 | %define IMAGE_SCN_LNK_OTHER 0x00000100
|
---|
130 | %define IMAGE_SCN_LNK_INFO 0x00000200
|
---|
131 | %define IMAGE_SCN_TYPE_OVER 0x00000400
|
---|
132 | %define IMAGE_SCN_LNK_REMOVE 0x00000800
|
---|
133 | %define IMAGE_SCN_LNK_COMDAT 0x00001000
|
---|
134 | %define IMAGE_SCN_MEM_PROTECTED 0x00004000
|
---|
135 | %define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000
|
---|
136 | %define IMAGE_SCN_GPREL 0x00008000
|
---|
137 | %define IMAGE_SCN_MEM_FARDATA 0x00008000
|
---|
138 | %define IMAGE_SCN_MEM_SYSHEAP 0x00010000
|
---|
139 | %define IMAGE_SCN_MEM_PURGEABLE 0x00020000
|
---|
140 | %define IMAGE_SCN_MEM_16BIT 0x00020000
|
---|
141 | %define IMAGE_SCN_MEM_LOCKED 0x00040000
|
---|
142 | %define IMAGE_SCN_MEM_PRELOAD 0x00080000
|
---|
143 |
|
---|
144 | %define IMAGE_SCN_ALIGN_1BYTES 0x00100000
|
---|
145 | %define IMAGE_SCN_ALIGN_2BYTES 0x00200000
|
---|
146 | %define IMAGE_SCN_ALIGN_4BYTES 0x00300000
|
---|
147 | %define IMAGE_SCN_ALIGN_8BYTES 0x00400000
|
---|
148 | %define IMAGE_SCN_ALIGN_16BYTES 0x00500000
|
---|
149 | %define IMAGE_SCN_ALIGN_32BYTES 0x00600000
|
---|
150 | %define IMAGE_SCN_ALIGN_64BYTES 0x00700000
|
---|
151 | %define IMAGE_SCN_ALIGN_128BYTES 0x00800000
|
---|
152 | %define IMAGE_SCN_ALIGN_256BYTES 0x00900000
|
---|
153 | %define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
|
---|
154 | %define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
|
---|
155 | %define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
|
---|
156 | %define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
|
---|
157 | %define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
|
---|
158 | %define IMAGE_SCN_ALIGN_MASK 0x00F00000
|
---|
159 | %define IMAGE_SCN_ALIGN_SHIFT 20
|
---|
160 |
|
---|
161 | %define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
|
---|
162 | %define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
|
---|
163 | %define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
|
---|
164 | %define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
|
---|
165 | %define IMAGE_SCN_MEM_SHARED 0x10000000
|
---|
166 | %define IMAGE_SCN_MEM_EXECUTE 0x20000000
|
---|
167 | %define IMAGE_SCN_MEM_READ 0x40000000
|
---|
168 | %define IMAGE_SCN_MEM_WRITE 0x80000000
|
---|
169 |
|
---|
170 |
|
---|
171 | ; relocations
|
---|
172 | %define IMAGE_REL_BASED_ABSOLUTE 0x0
|
---|
173 | %define IMAGE_REL_BASED_HIGH 0x1
|
---|
174 | %define IMAGE_REL_BASED_LOW 0x2
|
---|
175 | %define IMAGE_REL_BASED_HIGHLOW 0x3
|
---|
176 | %define IMAGE_REL_BASED_HIGHADJ 0x4
|
---|
177 | %define IMAGE_REL_BASED_MIPS_JMPADDR 0x5
|
---|
178 | %define IMAGE_REL_BASED_MIPS_JMPADDR16 0x9
|
---|
179 | %define IMAGE_REL_BASED_IA64_IMM64 0x9
|
---|
180 | %define IMAGE_REL_BASED_DIR64 0xa
|
---|
181 | %define IMAGE_REL_BASED_HIGH3ADJ 0xb
|
---|
182 |
|
---|
183 |
|
---|
184 | ; imports
|
---|
185 | %define IMAGE_ORDINAL_FLAG32 0x80000000
|
---|
186 | %define IMAGE_ORDINAL_FLAG64 UINT64_MAX(0x8000000000000000)
|
---|
187 |
|
---|
188 |
|
---|
189 | ; debug dir
|
---|
190 | %define IMAGE_DEBUG_TYPE_UNKNOWN UINT32_C(0x0)
|
---|
191 | %define IMAGE_DEBUG_TYPE_COFF UINT32_C(0x1)
|
---|
192 | %define IMAGE_DEBUG_TYPE_CODEVIEW UINT32_C(0x2)
|
---|
193 | %define IMAGE_DEBUG_TYPE_FPO UINT32_C(0x3)
|
---|
194 | %define IMAGE_DEBUG_TYPE_MISC UINT32_C(0x4)
|
---|
195 | %define IMAGE_DEBUG_TYPE_EXCEPTION UINT32_C(0x5)
|
---|
196 | %define IMAGE_DEBUG_TYPE_FIXUP UINT32_C(0x6)
|
---|
197 | %define IMAGE_DEBUG_TYPE_OMAP_TO_SRC UINT32_C(0x7)
|
---|
198 | %define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC UINT32_C(0x8)
|
---|
199 | %define IMAGE_DEBUG_TYPE_BORLAND UINT32_C(0x9)
|
---|
200 | %define IMAGE_DEBUG_TYPE_RESERVED10 UINT32_C(0x10)
|
---|
201 |
|
---|
202 | %define IMAGE_DEBUG_MISC_EXENAME UINT32_C(1)
|
---|
203 |
|
---|
204 | ; security directory
|
---|
205 | %define WIN_CERT_REVISION_1_0 UINT16_C(0x0100)
|
---|
206 | %define WIN_CERT_REVISION_2_0 UINT16_C(0x0200)
|
---|
207 |
|
---|
208 | %define WIN_CERT_TYPE_X509 UINT16_C(1)
|
---|
209 | %define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2)
|
---|
210 | %define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3)
|
---|
211 | %define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4)
|
---|
212 | %define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0)
|
---|
213 | %define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1)
|
---|
214 |
|
---|
215 |
|
---|
216 | ; For .DBG files.
|
---|
217 | %define IMAGE_SEPARATE_DEBUG_SIGNATURE UINT16_C(0x4944)
|
---|
218 |
|
---|
219 | %define IMAGE_SIZE_OF_SYMBOL 18
|
---|
220 | %define IMAGE_SIZE_OF_SYMBOL_EX 20
|
---|
221 |
|
---|
222 | %define IMAGE_SYM_UNDEFINED INT16_C(0)
|
---|
223 | %define IMAGE_SYM_ABSOLUTE INT16_C(-1)
|
---|
224 | %define IMAGE_SYM_DEBUG INT16_C(-2)
|
---|
225 |
|
---|
226 | %define IMAGE_SYM_CLASS_END_OF_FUNCTION UINT8_C(0xff) ; -1
|
---|
227 | %define IMAGE_SYM_CLASS_NULL UINT8_C(0)
|
---|
228 | %define IMAGE_SYM_CLASS_AUTOMATIC UINT8_C(1)
|
---|
229 | %define IMAGE_SYM_CLASS_EXTERNAL UINT8_C(2)
|
---|
230 | %define IMAGE_SYM_CLASS_STATIC UINT8_C(3)
|
---|
231 | %define IMAGE_SYM_CLASS_REGISTER UINT8_C(4)
|
---|
232 | %define IMAGE_SYM_CLASS_EXTERNAL_DEF UINT8_C(5)
|
---|
233 | %define IMAGE_SYM_CLASS_LABEL UINT8_C(6)
|
---|
234 | %define IMAGE_SYM_CLASS_UNDEFINED_LABEL UINT8_C(7)
|
---|
235 | %define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT UINT8_C(8)
|
---|
236 | %define IMAGE_SYM_CLASS_ARGUMENT UINT8_C(9)
|
---|
237 | %define IMAGE_SYM_CLASS_STRUCT_TAG UINT8_C(10)
|
---|
238 | %define IMAGE_SYM_CLASS_MEMBER_OF_UNION UINT8_C(11)
|
---|
239 | %define IMAGE_SYM_CLASS_UNION_TAG UINT8_C(12)
|
---|
240 | %define IMAGE_SYM_CLASS_TYPE_DEFINITION UINT8_C(13)
|
---|
241 | %define IMAGE_SYM_CLASS_UNDEFINED_STATIC UINT8_C(14)
|
---|
242 | %define IMAGE_SYM_CLASS_ENUM_TAG UINT8_C(15)
|
---|
243 | %define IMAGE_SYM_CLASS_MEMBER_OF_ENUM UINT8_C(16)
|
---|
244 | %define IMAGE_SYM_CLASS_REGISTER_PARAM UINT8_C(17)
|
---|
245 | %define IMAGE_SYM_CLASS_BIT_FIELD UINT8_C(18)
|
---|
246 | %define IMAGE_SYM_CLASS_FAR_EXTERNAL UINT8_C(68)
|
---|
247 | %define IMAGE_SYM_CLASS_BLOCK UINT8_C(100)
|
---|
248 | %define IMAGE_SYM_CLASS_FUNCTION UINT8_C(101)
|
---|
249 | %define IMAGE_SYM_CLASS_END_OF_STRUCT UINT8_C(102)
|
---|
250 | %define IMAGE_SYM_CLASS_FILE UINT8_C(103)
|
---|
251 | %define IMAGE_SYM_CLASS_SECTION UINT8_C(104)
|
---|
252 | %define IMAGE_SYM_CLASS_WEAK_EXTERNAL UINT8_C(105)
|
---|
253 | %define IMAGE_SYM_CLASS_CLR_TOKEN UINT8_C(107)
|
---|
254 |
|
---|
255 |
|
---|
256 | %define IMAGE_SYM_TYPE_NULL UINT16_C(0x0000)
|
---|
257 | %define IMAGE_SYM_TYPE_VOID UINT16_C(0x0001)
|
---|
258 | %define IMAGE_SYM_TYPE_CHAR UINT16_C(0x0002)
|
---|
259 | %define IMAGE_SYM_TYPE_SHORT UINT16_C(0x0003)
|
---|
260 | %define IMAGE_SYM_TYPE_INT UINT16_C(0x0004)
|
---|
261 | %define IMAGE_SYM_TYPE_LONG UINT16_C(0x0005)
|
---|
262 | %define IMAGE_SYM_TYPE_FLOAT UINT16_C(0x0006)
|
---|
263 | %define IMAGE_SYM_TYPE_DOUBLE UINT16_C(0x0007)
|
---|
264 | %define IMAGE_SYM_TYPE_STRUCT UINT16_C(0x0008)
|
---|
265 | %define IMAGE_SYM_TYPE_UNION UINT16_C(0x0009)
|
---|
266 | %define IMAGE_SYM_TYPE_ENUM UINT16_C(0x000a)
|
---|
267 | %define IMAGE_SYM_TYPE_MOE UINT16_C(0x000b)
|
---|
268 | %define IMAGE_SYM_TYPE_BYTE UINT16_C(0x000c)
|
---|
269 | %define IMAGE_SYM_TYPE_WORD UINT16_C(0x000d)
|
---|
270 | %define IMAGE_SYM_TYPE_UINT UINT16_C(0x000e)
|
---|
271 | %define IMAGE_SYM_TYPE_DWORD UINT16_C(0x000f)
|
---|
272 | %define IMAGE_SYM_TYPE_PCODE UINT16_C(0x8000)
|
---|
273 |
|
---|
274 | %define IMAGE_SYM_DTYPE_NULL UINT16_C(0x0)
|
---|
275 | %define IMAGE_SYM_DTYPE_POINTER UINT16_C(0x1)
|
---|
276 | %define IMAGE_SYM_DTYPE_FUNCTION UINT16_C(0x2)
|
---|
277 | %define IMAGE_SYM_DTYPE_ARRAY UINT16_C(0x3)
|
---|
278 |
|
---|
279 |
|
---|
280 | %define N_BTMASK UINT16_C(0x000f)
|
---|
281 | %define N_TMASK UINT16_C(0x0030)
|
---|
282 | %define N_TMASK1 UINT16_C(0x00c0)
|
---|
283 | %define N_TMASK2 UINT16_C(0x00f0)
|
---|
284 | %define N_BTSHFT 4
|
---|
285 | %define N_TSHIFT 2
|
---|
286 |
|
---|
287 |
|
---|
288 | ;*******************************************************************************
|
---|
289 | ;* Structures and Typedefs *
|
---|
290 | ;*******************************************************************************
|
---|
291 |
|
---|
292 | struc IMAGE_FILE_HEADER
|
---|
293 | .Machine resw 1 ;;< 0x00
|
---|
294 | .NumberOfSections resw 1 ;;< 0x02
|
---|
295 | .TimeDateStamp resd 1 ;;< 0x04
|
---|
296 | .PointerToSymbolTable resd 1 ;;< 0x08
|
---|
297 | .NumberOfSymbols resd 1 ;;< 0x0c
|
---|
298 | .SizeOfOptionalHeader resw 1 ;;< 0x10
|
---|
299 | .Characteristics resw 1 ;;< 0x12
|
---|
300 | endstruc
|
---|
301 | AssertCompileSize(IMAGE_FILE_HEADER, 0x14)
|
---|
302 |
|
---|
303 | struc IMAGE_DATA_DIRECTORY
|
---|
304 | .VirtualAddress resd 1
|
---|
305 | .Size resd 1
|
---|
306 | endstruc
|
---|
307 |
|
---|
308 |
|
---|
309 | struc IMAGE_OPTIONAL_HEADER32
|
---|
310 | .Magic resw 1 ;;< 0x00
|
---|
311 | .MajorLinkerVersion resb 1 ;;< 0x02
|
---|
312 | .MinorLinkerVersion resb 1 ;;< 0x03
|
---|
313 | .SizeOfCode resd 1 ;;< 0x04
|
---|
314 | .SizeOfInitializedData resd 1 ;;< 0x08
|
---|
315 | .SizeOfUninitializedData resd 1 ;;< 0x0c
|
---|
316 | .AddressOfEntryPoint resd 1 ;;< 0x10
|
---|
317 | .BaseOfCode resd 1 ;;< 0x14
|
---|
318 | .BaseOfData resd 1 ;;< 0x18
|
---|
319 | .ImageBase resd 1 ;;< 0x1c
|
---|
320 | .SectionAlignment resd 1 ;;< 0x20
|
---|
321 | .FileAlignment resd 1 ;;< 0x24
|
---|
322 | .MajorOperatingSystemVersion resw 1 ;;< 0x28
|
---|
323 | .MinorOperatingSystemVersion resw 1 ;;< 0x2a
|
---|
324 | .MajorImageVersion resw 1 ;;< 0x2c
|
---|
325 | .MinorImageVersion resw 1 ;;< 0x2e
|
---|
326 | .MajorSubsystemVersion resw 1 ;;< 0x30
|
---|
327 | .MinorSubsystemVersion resw 1 ;;< 0x32
|
---|
328 | .Win32VersionValue resd 1 ;;< 0x34
|
---|
329 | .SizeOfImage resd 1 ;;< 0x38
|
---|
330 | .SizeOfHeaders resd 1 ;;< 0x3c
|
---|
331 | .CheckSum resd 1 ;;< 0x40
|
---|
332 | .Subsystem resw 1 ;;< 0x44
|
---|
333 | .DllCharacteristics resw 1 ;;< 0x46
|
---|
334 | .SizeOfStackReserve resd 1 ;;< 0x48
|
---|
335 | .SizeOfStackCommit resd 1 ;;< 0x4c
|
---|
336 | .SizeOfHeapReserve resd 1 ;;< 0x50
|
---|
337 | .SizeOfHeapCommit resd 1 ;;< 0x54
|
---|
338 | .LoaderFlags resd 1 ;;< 0x58
|
---|
339 | .NumberOfRvaAndSizes resd 1 ;;< 0x5c
|
---|
340 | .DataDirectory resb IMAGE_DATA_DIRECTORY_size * IMAGE_NUMBEROF_DIRECTORY_ENTRIES ;;< 0x60; 0x10*8 = 0x80
|
---|
341 | endstruc
|
---|
342 | AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
|
---|
343 |
|
---|
344 | struc IMAGE_OPTIONAL_HEADER64
|
---|
345 | .Magic resw 1 ;;< 0x00
|
---|
346 | .MajorLinkerVersion resb 1 ;;< 0x02
|
---|
347 | .MinorLinkerVersion resb 1 ;;< 0x03
|
---|
348 | .SizeOfCode resd 1 ;;< 0x04
|
---|
349 | .SizeOfInitializedData resd 1 ;;< 0x08
|
---|
350 | .SizeOfUninitializedData resd 1 ;;< 0x0c
|
---|
351 | .AddressOfEntryPoint resd 1 ;;< 0x10
|
---|
352 | .BaseOfCode resd 1 ;;< 0x14
|
---|
353 | .ImageBase resq 1 ;;< 0x18
|
---|
354 | .SectionAlignment resd 1 ;;< 0x20
|
---|
355 | .FileAlignment resd 1 ;;< 0x24
|
---|
356 | .MajorOperatingSystemVersion resw 1 ;;< 0x28
|
---|
357 | .MinorOperatingSystemVersion resw 1 ;;< 0x2a
|
---|
358 | .MajorImageVersion resw 1 ;;< 0x2c
|
---|
359 | .MinorImageVersion resw 1 ;;< 0x2e
|
---|
360 | .MajorSubsystemVersion resw 1 ;;< 0x30
|
---|
361 | .MinorSubsystemVersion resw 1 ;;< 0x32
|
---|
362 | .Win32VersionValue resd 1 ;;< 0x34
|
---|
363 | .SizeOfImage resd 1 ;;< 0x38
|
---|
364 | .SizeOfHeaders resd 1 ;;< 0x3c
|
---|
365 | .CheckSum resd 1 ;;< 0x40
|
---|
366 | .Subsystem resw 1 ;;< 0x44
|
---|
367 | .DllCharacteristics resw 1 ;;< 0x46
|
---|
368 | .SizeOfStackReserve resq 1 ;;< 0x48
|
---|
369 | .SizeOfStackCommit resq 1 ;;< 0x50
|
---|
370 | .SizeOfHeapReserve resq 1 ;;< 0x58
|
---|
371 | .SizeOfHeapCommit resq 1 ;;< 0x60
|
---|
372 | .LoaderFlags resd 1 ;;< 0x68
|
---|
373 | .NumberOfRvaAndSizes resd 1 ;;< 0x6c
|
---|
374 | .DataDirectory resb IMAGE_DATA_DIRECTORY_size * IMAGE_NUMBEROF_DIRECTORY_ENTRIES ;;< 0x70; 0x10*8 = 0x80
|
---|
375 | endstruc ; size: 0xf0
|
---|
376 | AssertCompileSize(IMAGE_OPTIONAL_HEADER64, 0xf0);
|
---|
377 |
|
---|
378 |
|
---|
379 | struc IMAGE_NT_HEADERS32
|
---|
380 | .Signature resd 1 ;;< 0x00
|
---|
381 | .FileHeader resb IMAGE_FILE_HEADER_size ; ;;< 0x04
|
---|
382 | .OptionalHeader resb IMAGE_OPTIONAL_HEADER32_size ;;< 0x18
|
---|
383 | endstruc ; size: 0xf8
|
---|
384 | AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
|
---|
385 | AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
|
---|
386 | AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
|
---|
387 |
|
---|
388 | struc IMAGE_NT_HEADERS64
|
---|
389 | .Signature resd 1 ;;< 0x00
|
---|
390 | .FileHeader resb IMAGE_FILE_HEADER_size ;;< 0x04
|
---|
391 | .OptionalHeader resb IMAGE_OPTIONAL_HEADER64_size ;;< 0x18
|
---|
392 | endstruc ; size: 0x108
|
---|
393 | AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
|
---|
394 | AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
|
---|
395 | AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
|
---|
396 |
|
---|
397 |
|
---|
398 | struc IMAGE_SECTION_HEADER
|
---|
399 | .Name resb IMAGE_SIZEOF_SHORT_NAME
|
---|
400 | .Misc.VirtualSize resd 1
|
---|
401 | .VirtualAddress resd 1
|
---|
402 | .SizeOfRawData resd 1
|
---|
403 | .PointerToRawData resd 1
|
---|
404 | .PointerToRelocations resd 1
|
---|
405 | .PointerToLinenumbers resd 1
|
---|
406 | .NumberOfRelocations resw 1
|
---|
407 | .NumberOfLinenumbers resw 1
|
---|
408 | .Characteristics resd 1
|
---|
409 | endstruc
|
---|
410 | %define IMAGE_SECTION_HEADER.Misc.PhysicalAddress IMAGE_SECTION_HEADER.Misc.VirtualSize
|
---|
411 |
|
---|
412 |
|
---|
413 | struc IMAGE_BASE_RELOCATION
|
---|
414 | .VirtualAddress resd 1
|
---|
415 | .SizeOfBlock resd 1
|
---|
416 | endstruc
|
---|
417 |
|
---|
418 |
|
---|
419 | struc IMAGE_EXPORT_DIRECTORY
|
---|
420 | .Characteristics resd 1
|
---|
421 | .TimeDateStamp resd 1
|
---|
422 | .MajorVersion resw 1
|
---|
423 | .MinorVersion resw 1
|
---|
424 | .Name resd 1
|
---|
425 | .Base resd 1
|
---|
426 | .NumberOfFunctions resd 1
|
---|
427 | .NumberOfNames resd 1
|
---|
428 | .AddressOfFunctions resd 1
|
---|
429 | .AddressOfNames resd 1
|
---|
430 | .AddressOfNameOrdinals resd 1
|
---|
431 | endstruc
|
---|
432 |
|
---|
433 |
|
---|
434 | struc IMAGE_IMPORT_DESCRIPTOR
|
---|
435 | .u.Characteristics resd 1
|
---|
436 | .TimeDateStamp resd 1
|
---|
437 | .ForwarderChain resd 1
|
---|
438 | .Name resd 1
|
---|
439 | .FirstThunk resd 1
|
---|
440 | endstruc
|
---|
441 | %define IMAGE_IMPORT_DESCRIPTOR.u.OriginalFirstThunk IMAGE_IMPORT_DESCRIPTOR.u.Characteristics
|
---|
442 |
|
---|
443 | struc IMAGE_IMPORT_BY_NAME
|
---|
444 | .Hint resw 1
|
---|
445 | .Name resb 1
|
---|
446 | endstruc
|
---|
447 |
|
---|
448 |
|
---|
449 | struc IMAGE_THUNK_DATA64
|
---|
450 | .u1.ForwarderString resq 1
|
---|
451 | endstruc
|
---|
452 | %define IMAGE_THUNK_DATA64.u1.Function IMAGE_THUNK_DATA64.u1.ForwarderString
|
---|
453 | %define IMAGE_THUNK_DATA64.u1.Ordinal IMAGE_THUNK_DATA64.u1.ForwarderString
|
---|
454 | %define IMAGE_THUNK_DATA64.u1.AddressOfData IMAGE_THUNK_DATA64.u1.ForwarderString
|
---|
455 |
|
---|
456 | struc IMAGE_THUNK_DATA32
|
---|
457 | .u1.ForwarderString resd 1
|
---|
458 | endstruc
|
---|
459 | %define IMAGE_THUNK_DATA32.u1.Function IMAGE_THUNK_DATA32.u1.ForwarderString
|
---|
460 | %define IMAGE_THUNK_DATA32.u1.Ordinal IMAGE_THUNK_DATA32.u1.ForwarderString
|
---|
461 | %define IMAGE_THUNK_DATA32.u1.AddressOfData IMAGE_THUNK_DATA32.u1.ForwarderString
|
---|
462 |
|
---|
463 |
|
---|
464 | struc IMAGE_LOAD_CONFIG_DIRECTORY32
|
---|
465 | .Size resd 1
|
---|
466 | .TimeDateStamp resd 1
|
---|
467 | .MajorVersion resw 1
|
---|
468 | .MinorVersion resw 1
|
---|
469 | .GlobalFlagsClear resd 1
|
---|
470 | .GlobalFlagsSet resd 1
|
---|
471 | .CriticalSectionDefaultTimeout resd 1
|
---|
472 | .DeCommitFreeBlockThreshold resd 1
|
---|
473 | .DeCommitTotalFreeThreshold resd 1
|
---|
474 | .LockPrefixTable resd 1
|
---|
475 | .MaximumAllocationSize resd 1
|
---|
476 | .VirtualMemoryThreshold resd 1
|
---|
477 | .ProcessHeapFlags resd 1
|
---|
478 | .ProcessAffinityMask resd 1
|
---|
479 | .CSDVersion resw 1
|
---|
480 | .Reserved1 resw 1
|
---|
481 | .EditList resd 1
|
---|
482 | .SecurityCookie resd 1
|
---|
483 | .SEHandlerTable resd 1
|
---|
484 | .SEHandlerCount resd 1
|
---|
485 | endstruc
|
---|
486 |
|
---|
487 | struc IMAGE_LOAD_CONFIG_DIRECTORY64
|
---|
488 | .Size resd 1
|
---|
489 | .TimeDateStamp resd 1
|
---|
490 | .MajorVersion resw 1
|
---|
491 | .MinorVersion resw 1
|
---|
492 | .GlobalFlagsClear resd 1
|
---|
493 | .GlobalFlagsSet resd 1
|
---|
494 | .CriticalSectionDefaultTimeout resd 1
|
---|
495 | .DeCommitFreeBlockThreshold resq 1
|
---|
496 | .DeCommitTotalFreeThreshold resq 1
|
---|
497 | .LockPrefixTable resq 1
|
---|
498 | .MaximumAllocationSize resq 1
|
---|
499 | .VirtualMemoryThreshold resq 1
|
---|
500 | .ProcessAffinityMask resq 1
|
---|
501 | .ProcessHeapFlags resd 1
|
---|
502 | .CSDVersion resw 1
|
---|
503 | .Reserved1 resw 1
|
---|
504 | .EditList resq 1
|
---|
505 | .SecurityCookie resq 1
|
---|
506 | .SEHandlerTable resq 1
|
---|
507 | .SEHandlerCount resq 1
|
---|
508 | endstruc
|
---|
509 |
|
---|
510 |
|
---|
511 | struc IMAGE_DEBUG_DIRECTORY
|
---|
512 | .Characteristics resd 1
|
---|
513 | .TimeDateStamp resd 1
|
---|
514 | .MajorVersion resw 1
|
---|
515 | .MinorVersion resw 1
|
---|
516 | .Type resd 1
|
---|
517 | .SizeOfData resd 1
|
---|
518 | .AddressOfRawData resd 1
|
---|
519 | .PointerToRawData resd 1
|
---|
520 | endstruc
|
---|
521 |
|
---|
522 | struc IMAGE_DEBUG_MISC
|
---|
523 | .DataType resd 1
|
---|
524 | .Length resd 1
|
---|
525 | .Unicode resb 1
|
---|
526 | .Reserved resb 3
|
---|
527 | .Data resb 1
|
---|
528 | endstruc
|
---|
529 |
|
---|
530 |
|
---|
531 | struc WIN_CERTIFICATE
|
---|
532 | .dwLength resd 1
|
---|
533 | .wRevision resw 1
|
---|
534 | .wCertificateType resw 1
|
---|
535 | .bCertificate resb 8
|
---|
536 | endstruc
|
---|
537 |
|
---|
538 | ;; The header of a .DBG file (NT4).
|
---|
539 | struc IMAGE_SEPARATE_DEBUG_HEADER
|
---|
540 | .Signature resw 1 ;;< 0x00
|
---|
541 | .Flags resw 1 ;;< 0x02
|
---|
542 | .Machine resw 1 ;;< 0x04
|
---|
543 | .Characteristics resw 1 ;;< 0x06
|
---|
544 | .TimeDateStamp resd 1 ;;< 0x08
|
---|
545 | .CheckSum resd 1 ;;< 0x0c
|
---|
546 | .ImageBase resd 1 ;;< 0x10
|
---|
547 | .SizeOfImage resd 1 ;;< 0x14
|
---|
548 | .NumberOfSections resd 1 ;;< 0x18
|
---|
549 | .ExportedNamesSize resd 1 ;;< 0x1c
|
---|
550 | .DebugDirectorySize resd 1 ;;< 0x20
|
---|
551 | .SectionAlignment resd 1 ;;< 0x24
|
---|
552 | .Reserved resd 2 ;;< 0x28
|
---|
553 | endstruc ; size: 0x30
|
---|
554 | AssertCompileSize(IMAGE_SEPARATE_DEBUG_HEADER, 0x30);
|
---|
555 |
|
---|
556 |
|
---|
557 | struc IMAGE_COFF_SYMBOLS_HEADER
|
---|
558 | .NumberOfSymbols resd 1
|
---|
559 | .LvaToFirstSymbol resd 1
|
---|
560 | .NumberOfLinenumbers resd 1
|
---|
561 | .LvaToFirstLinenumber resd 1
|
---|
562 | .RvaToFirstByteOfCode resd 1
|
---|
563 | .RvaToLastByteOfCode resd 1
|
---|
564 | .RvaToFirstByteOfData resd 1
|
---|
565 | .RvaToLastByteOfData resd 1
|
---|
566 | endstruc
|
---|
567 | AssertCompileSize(IMAGE_COFF_SYMBOLS_HEADER, 0x20);
|
---|
568 |
|
---|
569 |
|
---|
570 | struc IMAGE_LINENUMBER
|
---|
571 | .Type.VirtualAddress resd 1
|
---|
572 | .Linenumber resw 1
|
---|
573 | endstruc
|
---|
574 | AssertCompileSize(IMAGE_LINENUMBER, 6);
|
---|
575 | %define IMAGE_LINENUMBER.Type.SymbolTableIndex IMAGE_LINENUMBER.Type.VirtualAddress
|
---|
576 |
|
---|
577 |
|
---|
578 | ;;#pragma pack(2)
|
---|
579 | ;;struc IMAGE_SYMBOL
|
---|
580 | ;;{
|
---|
581 | ;; union
|
---|
582 | ;; {
|
---|
583 | ;; uint8_t ShortName[8];
|
---|
584 | ;; struct
|
---|
585 | ;; {
|
---|
586 | ;; .Short resd 1
|
---|
587 | ;; .Long resd 1
|
---|
588 | ;; } Name;
|
---|
589 | ;; uint32_t LongName[2];
|
---|
590 | ;; } N;
|
---|
591 | ;;
|
---|
592 | ;; .Value resd 1
|
---|
593 | ;; int16_t SectionNumber;
|
---|
594 | ;; .Type resw 1
|
---|
595 | ;; .StorageClass resb 1
|
---|
596 | ;; .NumberOfAuxSymbols resb 1
|
---|
597 | ;;} IMAGE_SYMBOL;
|
---|
598 | ;;#pragma pack()
|
---|
599 | ;;AssertCompileSize(IMAGE_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
|
---|
600 | ;;
|
---|
601 | ;;
|
---|
602 | ;;#pragma pack(2)
|
---|
603 | ;;typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF
|
---|
604 | ;;{
|
---|
605 | ;; .bAuxType resb 1
|
---|
606 | ;; .bReserved resb 1
|
---|
607 | ;; .SymbolTableIndex resd 1
|
---|
608 | ;; uint8_t rgbReserved[12];
|
---|
609 | ;;} IMAGE_AUX_SYMBOL_TOKEN_DEF;
|
---|
610 | ;;#pragma pack()
|
---|
611 | ;;AssertCompileSize(IMAGE_AUX_SYMBOL_TOKEN_DEF, IMAGE_SIZE_OF_SYMBOL);
|
---|
612 | ;;
|
---|
613 | ;;
|
---|
614 | ;;#pragma pack(1)
|
---|
615 | ;;typedef union _IMAGE_AUX_SYMBOL
|
---|
616 | ;;{
|
---|
617 | ;; struct
|
---|
618 | ;; {
|
---|
619 | ;; .TagIndex resd 1
|
---|
620 | ;; union
|
---|
621 | ;; {
|
---|
622 | ;; struct
|
---|
623 | ;; {
|
---|
624 | ;; .Linenumber resw 1
|
---|
625 | ;; .Size resw 1
|
---|
626 | ;; } LnSz;
|
---|
627 | ;; } Misc;
|
---|
628 | ;; union
|
---|
629 | ;; {
|
---|
630 | ;; struct
|
---|
631 | ;; {
|
---|
632 | ;; .PointerToLinenumber resd 1
|
---|
633 | ;; .PointerToNextFunction resd 1
|
---|
634 | ;; } Function;
|
---|
635 | ;; struct
|
---|
636 | ;; {
|
---|
637 | ;; uint16_t Dimension[4];
|
---|
638 | ;; } Array;
|
---|
639 | ;; } FcnAry;
|
---|
640 | ;; .TvIndex resw 1
|
---|
641 | ;; } Sym;
|
---|
642 | ;;
|
---|
643 | ;; struct
|
---|
644 | ;; {
|
---|
645 | ;; uint8_t Name[IMAGE_SIZE_OF_SYMBOL];
|
---|
646 | ;; } File;
|
---|
647 | ;;
|
---|
648 | ;; struct
|
---|
649 | ;; {
|
---|
650 | ;; .Length resd 1
|
---|
651 | ;; .NumberOfRelocations resw 1
|
---|
652 | ;; .NumberOfLinenumbers resw 1
|
---|
653 | ;; .CheckSum resd 1
|
---|
654 | ;; .Number resw 1
|
---|
655 | ;; .Selection resb 1
|
---|
656 | ;; .bReserved resb 1
|
---|
657 | ;; .HighNumber resw 1
|
---|
658 | ;; } Section;
|
---|
659 | ;;
|
---|
660 | ;; IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
|
---|
661 | ;; struct
|
---|
662 | ;; {
|
---|
663 | ;; .crc resd 1
|
---|
664 | ;; uint8_t rgbReserved[14];
|
---|
665 | ;; } CRC;
|
---|
666 | ;;} IMAGE_AUX_SYMBOL;
|
---|
667 | ;;#pragma pack()
|
---|
668 | ;;AssertCompileSize(IMAGE_AUX_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
|
---|
669 | ;;
|
---|
670 | ;;
|
---|
671 | ;;
|
---|
672 | ;;struc IMAGE_SYMBOL_EX
|
---|
673 | ;;{
|
---|
674 | ;; union
|
---|
675 | ;; {
|
---|
676 | ;; uint8_t ShortName[8];
|
---|
677 | ;; struct
|
---|
678 | ;; {
|
---|
679 | ;; .Short resd 1
|
---|
680 | ;; .Long resd 1
|
---|
681 | ;; } Name;
|
---|
682 | ;; uint32_t LongName[2];
|
---|
683 | ;; } N;
|
---|
684 | ;;
|
---|
685 | ;; .Value resd 1
|
---|
686 | ;; int32_t SectionNumber; /* The difference from IMAGE_SYMBOL
|
---|
687 | ;; .Type resw 1
|
---|
688 | ;; .StorageClass resb 1
|
---|
689 | ;; .NumberOfAuxSymbols resb 1
|
---|
690 | ;;} IMAGE_SYMBOL_EX;
|
---|
691 | ;;AssertCompileSize(IMAGE_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
|
---|
692 | ;;
|
---|
693 | ;;
|
---|
694 | ;;typedef union _IMAGE_AUX_SYMBOL_EX
|
---|
695 | ;;{
|
---|
696 | ;; struct
|
---|
697 | ;; {
|
---|
698 | ;; .WeakDefaultSymIndex resd 1
|
---|
699 | ;; .WeakSearchType resd 1
|
---|
700 | ;; uint8_t rgbReserved[12];
|
---|
701 | ;; } Sym;
|
---|
702 | ;;
|
---|
703 | ;; struct
|
---|
704 | ;; {
|
---|
705 | ;; uint8_t Name[IMAGE_SIZE_OF_SYMBOL_EX];
|
---|
706 | ;; } File;
|
---|
707 | ;;
|
---|
708 | ;; struct
|
---|
709 | ;; {
|
---|
710 | ;; .Length resd 1
|
---|
711 | ;; .NumberOfRelocations resw 1
|
---|
712 | ;; .NumberOfLinenumbers resw 1
|
---|
713 | ;; .CheckSum resd 1
|
---|
714 | ;; .Number resw 1
|
---|
715 | ;; .Selection resb 1
|
---|
716 | ;; .bReserved resb 1
|
---|
717 | ;; .HighNumber resw 1
|
---|
718 | ;; uint8_t rgbReserved[2];
|
---|
719 | ;; } Section;
|
---|
720 | ;;
|
---|
721 | ;; IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
|
---|
722 | ;;
|
---|
723 | ;; struct
|
---|
724 | ;; {
|
---|
725 | ;; .crc resd 1
|
---|
726 | ;; uint8_t rgbReserved[16];
|
---|
727 | ;; } CRC;
|
---|
728 | ;;} IMAGE_AUX_SYMBOL_EX;
|
---|
729 | ;;AssertCompileSize(IMAGE_AUX_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
|
---|
730 |
|
---|
731 | %endif
|
---|
732 |
|
---|