Rizin
unix-like reverse engineering framework and cli tools
pe_specs.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2008 nibble <nibble.ds@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #undef PE_
5 #undef ILT_MASK1
6 #undef ILT_MASK2
7 #undef PE_Word
8 #undef PE_DWord
9 #undef PE_VWord
10 #undef RZ_BUF_READ_PE_DWORD_AT
11 #undef PE_DWORD_MAX
12 
13 #ifdef RZ_BIN_PE64
14 #define PE_(name) Pe64_##name
15 #define ILT_MASK1 0x8000000000000000LL
16 #define ILT_MASK2 0x7fffffffffffffffLL
17 #define PE_Word ut16
18 #define PE_DWord ut64
19 #define PE_VWord ut32
20 #define RZ_BUF_READ_PE_DWORD_AT rz_buf_read_le64_at
21 #define PE_DWORD_MAX UT64_MAX
22 #else
23 #define PE_(name) Pe32_##name
24 #define ILT_MASK1 0x80000000
25 #define ILT_MASK2 0x7fffffff
26 #define PE_Word ut16
27 #define PE_DWord ut32
28 #define PE_VWord ut32
29 #define RZ_BUF_READ_PE_DWORD_AT rz_buf_read_le32_at
30 #define PE_DWORD_MAX UT32_MAX
31 #endif
32 
33 #ifndef _INCLUDE_RZ_BIN_PE_SPECS_H_
34 #define _INCLUDE_RZ_BIN_PE_SPECS_H_
35 
36 #define PE_NAME_LENGTH 256
37 #define PE_STRING_LENGTH 256
38 
39 typedef struct {
40  ut16 e_magic; /* 00: MZ Header signature */
41  ut16 e_cblp; /* 02: Bytes on last page of file */
42  ut16 e_cp; /* 04: Pages in file */
43  ut16 e_crlc; /* 06: Relocations */
44  ut16 e_cparhdr; /* 08: Size of header in paragraphs */
45  ut16 e_minalloc; /* 0a: Minimum extra paragraphs needed */
46  ut16 e_maxalloc; /* 0c: Maximum extra paragraphs needed */
47  ut16 e_ss; /* 0e: Initial (relative) SS value */
48  ut16 e_sp; /* 10: Initial SP value */
49  ut16 e_csum; /* 12: Checksum */
50  ut16 e_ip; /* 14: Initial IP value */
51  ut16 e_cs; /* 16: Initial (relative) CS value */
52  ut16 e_lfarlc; /* 18: File address of relocation table */
53  ut16 e_ovno; /* 1a: Overlay number */
54  ut16 e_res[4]; /* 1c: Reserved words */
55  ut16 e_oemid; /* 24: OEM identifier (for e_oeminfo) */
56  ut16 e_oeminfo; /* 26: OEM information; e_oemid specific */
57  ut16 e_res2[10]; /* 28: Reserved words */
58  ut32 e_lfanew; /* 3c: Offset to extended header */
60 
61 #define PE_IMAGE_FILE_TYPE_PE32 0x10b
62 #define PE_IMAGE_FILE_TYPE_PE32PLUS 0x20b
63 
64 #define PE_IMAGE_FILE_MACHINE_UNKNOWN 0x0000
65 #define PE_IMAGE_FILE_MACHINE_ALPHA 0x0184
66 #define PE_IMAGE_FILE_MACHINE_ALPHA64 0x0284
67 #define PE_IMAGE_FILE_MACHINE_AM33 0x01d3
68 #define PE_IMAGE_FILE_MACHINE_AMD64 0x8664
69 #define PE_IMAGE_FILE_MACHINE_ARM 0x01c0
70 #define PE_IMAGE_FILE_MACHINE_ARMNT 0x01c4
71 #define PE_IMAGE_FILE_MACHINE_ARM64 0xaa64
72 #define PE_IMAGE_FILE_MACHINE_AXP64 PE_IMAGE_FILE_MACHINE_ALPHA64
73 #define PE_IMAGE_FILE_MACHINE_CEE 0xc0ee
74 #define PE_IMAGE_FILE_MACHINE_CEF 0x0cef
75 #define PE_IMAGE_FILE_MACHINE_EBC 0x0ebc
76 #define PE_IMAGE_FILE_MACHINE_I386 0x014c
77 #define PE_IMAGE_FILE_MACHINE_IA64 0x0200
78 #define PE_IMAGE_FILE_MACHINE_M32R 0x9041
79 #define PE_IMAGE_FILE_MACHINE_M68K 0x0268
80 #define PE_IMAGE_FILE_MACHINE_MIPS16 0x0266
81 #define PE_IMAGE_FILE_MACHINE_MIPSFPU 0x0366
82 #define PE_IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
83 #define PE_IMAGE_FILE_MACHINE_POWERPC 0x01f0
84 #define PE_IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
85 #define PE_IMAGE_FILE_MACHINE_R10000 0x0168
86 #define PE_IMAGE_FILE_MACHINE_R3000 0x0162
87 #define PE_IMAGE_FILE_MACHINE_R4000 0x0166
88 #define PE_IMAGE_FILE_MACHINE_SH3 0x01a2
89 #define PE_IMAGE_FILE_MACHINE_SH3DSP 0x01a3
90 #define PE_IMAGE_FILE_MACHINE_SH3E 0x01a4
91 #define PE_IMAGE_FILE_MACHINE_SH4 0x01a6
92 #define PE_IMAGE_FILE_MACHINE_SH5 0x01a8
93 #define PE_IMAGE_FILE_MACHINE_THUMB 0x01c2
94 #define PE_IMAGE_FILE_MACHINE_TRICORE 0x0520
95 #define PE_IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
96 #define PE_IMAGE_FILE_MACHINE_RISCV32 0x5032
97 #define PE_IMAGE_FILE_MACHINE_RISCV64 0x5064
98 #define PE_IMAGE_FILE_MACHINE_RISCV128 0x5128
99 
100 #define PE_IMAGE_FILE_RELOCS_STRIPPED 0x0001
101 #define PE_IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
102 #define PE_IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
103 #define PE_IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
104 #define PE_IMAGE_FILE_AGGRESSIVE_WS_TRIM 0x0010
105 #define PE_IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
106 #define PE_IMAGE_FILE_16BIT_MACHINE 0x0040
107 #define PE_IMAGE_FILE_BYTES_REVERSED_LO 0x0080
108 #define PE_IMAGE_FILE_32BIT_MACHINE 0x0100
109 #define PE_IMAGE_FILE_DEBUG_STRIPPED 0x0200
110 #define PE_IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
111 #define PE_IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
112 #define PE_IMAGE_FILE_SYSTEM 0x1000
113 #define PE_IMAGE_FILE_DLL 0x2000
114 #define PE_IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
115 #define PE_IMAGE_FILE_BYTES_REVERSED_HI 0x8000
116 
117 #define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA 0x0020
118 #define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE 0x0040
119 #define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY 0x0080
120 #define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT 0x0100
121 #define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
122 #define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
123 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
124 #define IMAGE_DLLCHARACTERISTICS_APPCONTAINER 0x1000
125 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
126 #define IMAGE_DLLCHARACTERISTICS_GUARD_CF 0x4000
127 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
128 
129 #define IMAGE_DEBUG_TYPE_CODEVIEW 2
130 #define IMAGE_DEBUG_TYPE_MISC 4
131 
132 typedef struct {
141 
142 #define PE_IMAGE_DIRECTORY_ENTRIES 16
143 #define PE_IMAGE_DIRECTORY_ENTRY_EXPORT 0
144 #define PE_IMAGE_DIRECTORY_ENTRY_IMPORT 1
145 #define PE_IMAGE_DIRECTORY_ENTRY_RESOURCE 2
146 #define PE_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
147 #define PE_IMAGE_DIRECTORY_ENTRY_SECURITY 4
148 #define PE_IMAGE_DIRECTORY_ENTRY_BASERELOC 5
149 #define PE_IMAGE_DIRECTORY_ENTRY_DEBUG 6
150 #define PE_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
151 #define PE_IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7
152 #define PE_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
153 #define PE_IMAGE_DIRECTORY_ENTRY_TLS 9
154 #define PE_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
155 #define PE_IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
156 #define PE_IMAGE_DIRECTORY_ENTRY_IAT 12
157 #define PE_IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
158 #define PE_IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
159 
160 #define PE_IMAGE_SUBSYSTEM_UNKNOWN 0
161 #define PE_IMAGE_SUBSYSTEM_NATIVE 1
162 #define PE_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
163 #define PE_IMAGE_SUBSYSTEM_WINDOWS_CUI 3
164 #define PE_IMAGE_SUBSYSTEM_POSIX_CUI 7
165 #define PE_IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
166 #define PE_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
167 #define PE_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
168 #define PE_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
169 #define PE_IMAGE_SUBSYSTEM_EFI_ROM 13
170 #define PE_IMAGE_SUBSYSTEM_XBOX 14
171 
172 // language
173 
174 #define PE_LANG_NEUTRAL 0x00
175 #define PE_LANG_INVARIANT 0x7f
176 #define PE_LANG_AFRIKAANS 0x36
177 #define PE_LANG_ALBANIAN 0x1c
178 #define PE_LANG_ARABIC 0x01
179 #define PE_LANG_ARMENIAN 0x2b
180 #define PE_LANG_ASSAMESE 0x4d
181 #define PE_LANG_AZERI 0x2c
182 #define PE_LANG_BASQUE 0x2d
183 #define PE_LANG_BELARUSIAN 0x23
184 #define PE_LANG_BENGALI 0x45
185 #define PE_LANG_BULGARIAN 0x02
186 #define PE_LANG_CATALAN 0x03
187 #define PE_LANG_CHINESE 0x04
188 #define PE_LANG_CROATIAN 0x1a
189 #define PE_LANG_CZECH 0x05
190 #define PE_LANG_DANISH 0x06
191 #define PE_LANG_DIVEHI 0x65
192 #define PE_LANG_DUTCH 0x13
193 #define PE_LANG_ENGLISH 0x09
194 #define PE_LANG_ESTONIAN 0x25
195 #define PE_LANG_FAEROESE 0x38
196 #define PE_LANG_FARSI 0x29
197 #define PE_LANG_FINNISH 0x0b
198 #define PE_LANG_FRENCH 0x0c
199 #define PE_LANG_GALICIAN 0x56
200 #define PE_LANG_GEORGIAN 0x37
201 #define PE_LANG_GERMAN 0x07
202 #define PE_LANG_GREEK 0x08
203 #define PE_LANG_GUJARATI 0x47
204 #define PE_LANG_HEBREW 0x0d
205 #define PE_LANG_HINDI 0x39
206 #define PE_LANG_HUNGARIAN 0x0e
207 #define PE_LANG_ICELANDIC 0x0f
208 #define PE_LANG_INDONESIAN 0x21
209 #define PE_LANG_ITALIAN 0x10
210 #define PE_LANG_JAPANESE 0x11
211 #define PE_LANG_KANNADA 0x4b
212 #define PE_LANG_KASHMIRI 0x60
213 #define PE_LANG_KAZAK 0x3f
214 #define PE_LANG_KONKANI 0x57
215 #define PE_LANG_KOREAN 0x12
216 #define PE_LANG_KYRGYZ 0x40
217 #define PE_LANG_LATVIAN 0x26
218 #define PE_LANG_LITHUANIAN 0x27
219 #define PE_LANG_MACEDONIAN 0x2f
220 #define PE_LANG_MALAY 0x3e
221 #define PE_LANG_MALAYALAM 0x4c
222 #define PE_LANG_MANIPURI 0x58
223 #define PE_LANG_MARATHI 0x4e
224 #define PE_LANG_MONGOLIAN 0x50
225 #define PE_LANG_NEPALI 0x61
226 #define PE_LANG_NORWEGIAN 0x14
227 #define PE_LANG_ORIYA 0x48
228 #define PE_LANG_POLISH 0x15
229 #define PE_LANG_PORTUGUESE 0x16
230 #define PE_LANG_PUNJABI 0x46
231 #define PE_LANG_ROMANIAN 0x18
232 #define PE_LANG_RUSSIAN 0x19
233 #define PE_LANG_SANSKRIT 0x4f
234 #define PE_LANG_SERBIAN 0x1a
235 #define PE_LANG_SINDHI 0x59
236 #define PE_LANG_SLOVAK 0x1b
237 #define PE_LANG_SLOVENIAN 0x24
238 #define PE_LANG_SPANISH 0x0a
239 #define PE_LANG_SWAHILI 0x41
240 #define PE_LANG_SWEDISH 0x1d
241 #define PE_LANG_SYRIAC 0x5a
242 #define PE_LANG_TAMIL 0x49
243 #define PE_LANG_TATAR 0x44
244 #define PE_LANG_TELUGU 0x4a
245 #define PE_LANG_THAI 0x1e
246 #define PE_LANG_TURKISH 0x1f
247 #define PE_LANG_UKRAINIAN 0x22
248 #define PE_LANG_URDU 0x20
249 #define PE_LANG_UZBEK 0x43
250 #define PE_LANG_VIETNAMESE 0x2a
251 #define PE_LANG_GAELIC 0x3c
252 #define PE_LANG_MALTESE 0x3a
253 #define PE_LANG_MAORI 0x28
254 #define PE_LANG_RHAETO_ROMANCE 0x17
255 #define PE_LANG_SAAMI 0x3b
256 #define PE_LANG_SORBIAN 0x2e
257 #define PE_LANG_SUTU 0x30
258 #define PE_LANG_TSONGA 0x31
259 #define PE_LANG_TSWANA 0x32
260 #define PE_LANG_VENDA 0x33
261 #define PE_LANG_XHOSA 0x34
262 #define PE_LANG_ZULU 0x35
263 #define PE_LANG_ESPERANTO 0x8f
264 #define PE_LANG_WALON 0x90
265 #define PE_LANG_CORNISH 0x91
266 #define PE_LANG_WELSH 0x92
267 #define PE_LANG_BRETON 0x93
268 
269 typedef struct {
273 
274 typedef struct {
275  /* Standard fields */
285  /* NT additional fields */
309 
310 typedef struct {
311  /* Standard fields */
320  /* NT additional fields */
344 
345 typedef struct {
349  char *productName;
351 
352 #define PE_IMAGE_SIZEOF_SHORT_NAME 8
353 
354 #define PE_IMAGE_SCN_MEM_SHARED 0x10000000
355 #define PE_IMAGE_SCN_MEM_EXECUTE 0x20000000
356 #define PE_IMAGE_SCN_MEM_READ 0x40000000
357 #define PE_IMAGE_SCN_MEM_WRITE 0x80000000
358 
359 typedef struct {
361  union {
364  } Misc;
374 
375 typedef struct {
388 
389 typedef struct {
396 
397 typedef struct {
407 
408 typedef struct {
416 
417 typedef struct {
423 
424 typedef struct {
428 
429 #define PE_WIN_CERT_REVISION_1_0 0x0100
430 #define PE_WIN_CERT_REVISION_2_0 0x0200
431 
432 #define PE_WIN_CERT_TYPE_X509 0x0001
433 #define PE_WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
434 #define PE_WIN_CERT_TYPE_RESERVED_1 0x0003
435 #define PE_WIN_CERT_TYPE_TS_STACK_SIGNED 0x0004
436 
437 typedef struct {
442 
443 typedef struct {
448 
449 typedef struct {
459 
460 typedef struct {
468 
469 typedef struct {
470  union {
471  // struct {
472  // ut32 NameOffset: 31;
473  // ut32 NameIsString: 1;
474  // } s;
475  // ut16 Id;
477  } u1;
478  union {
479  // struct {
480  // ut32 OffsetToDirectory: 31;
481  // ut32 DataIsDirectory: 1;
482  // } s;
484  } u2;
486 
487 // Pe_image_resource_directory_string is unused. Did not find any PE with ASCII resource name.
488 // Refer to https://msdn.microsoft.com/en-us/library/ms809762.aspx
489 // "Peering Inside the PE: A Tour of the Win32 Portable Executable File Format"
490 // "Yes, even PE files intended for non-UNICODE Win32 implementations use UNICODE here."
491 typedef struct {
493  char *NameString;
495 
496 typedef struct {
500 
501 typedef struct {
507 
508 // resource types
509 #define RZ_PE_MAX_RESOURCES 2056
510 #define PE_RESOURCE_ENTRY_CURSOR 1
511 #define PE_RESOURCE_ENTRY_BITMAP 2
512 #define PE_RESOURCE_ENTRY_ICON 3
513 #define PE_RESOURCE_ENTRY_MENU 4
514 #define PE_RESOURCE_ENTRY_DIALOG 5
515 #define PE_RESOURCE_ENTRY_STRING 6
516 #define PE_RESOURCE_ENTRY_FONTDIR 7
517 #define PE_RESOURCE_ENTRY_FONT 8
518 #define PE_RESOURCE_ENTRY_ACCELERATOR 9
519 #define PE_RESOURCE_ENTRY_RCDATA 10
520 #define PE_RESOURCE_ENTRY_MESSAGETABLE 11
521 #define PE_RESOURCE_ENTRY_GROUP_CURSOR 12
522 #define PE_RESOURCE_ENTRY_GROUP_ICON 14
523 #define PE_RESOURCE_ENTRY_VERSION 16
524 #define PE_RESOURCE_ENTRY_DLGINCLUDE 17
525 #define PE_RESOURCE_ENTRY_PLUGPLAY 19
526 #define PE_RESOURCE_ENTRY_VXD 20
527 #define PE_RESOURCE_ENTRY_ANICURSOR 21
528 #define PE_RESOURCE_ENTRY_ANIICON 22
529 #define PE_RESOURCE_ENTRY_HTML 23
530 #define PE_RESOURCE_ENTRY_MANIFEST 24
531 
532 #define STRINGFILEINFO_TEXT "StringFileInfo"
533 #define TRANSLATION_TEXT "Translation"
534 #define VARFILEINFO_TEXT "VarFileInfo"
535 #define VS_VERSION_INFO_TEXT "VS_VERSION_INFO"
536 
537 #define STRINGFILEINFO_TEXT_LEN sizeof(STRINGFILEINFO_TEXT)
538 #define TRANSLATION_TEXT_LEN sizeof(TRANSLATION_TEXT)
539 #define VARFILEINFO_TEXT_LEN sizeof(VARFILEINFO_TEXT)
540 #define VS_VERSION_INFO_TEXT_LEN sizeof(VS_VERSION_INFO_TEXT)
541 
542 #define EIGHT_HEX_DIG_UTF_16_LEN ((8 + 1) * 2)
543 
544 #define STRINGFILEINFO_UTF_16 "S\0t\0r\0i\0n\0g\0F\0i\0l\0e\0I\0n\0f\0o\0\0"
545 #define TRANSLATION_UTF_16 "T\0r\0a\0n\0s\0l\0a\0t\0i\0o\0n\0\0"
546 #define VARFILEINFO_UTF_16 "V\0a\0r\0F\0i\0l\0e\0I\0n\0f\0o\0\0"
547 #define VS_VERSION_INFO_UTF_16 "V\0S\0_\0V\0E\0R\0S\0I\0O\0N\0_\0I\0N\0F\0O\0\0"
548 
549 #define STRINGFILEINFO_UTF_16_LEN sizeof(STRINGFILEINFO_UTF_16)
550 #define TRANSLATION_UTF_16_LEN sizeof(TRANSLATION_UTF_16)
551 #define VARFILEINFO_UTF_16_LEN sizeof(VARFILEINFO_UTF_16)
552 #define VS_VERSION_INFO_UTF_16_LEN sizeof(VS_VERSION_INFO_UTF_16)
553 
554 typedef struct {
555  ut16 wLength; // The length, in bytes, of this String structure.
556  ut16 wValueLength; // The size, in words, of the Value member.
557  ut16 wType; // 1 text; 0 binary
559  ut16 *szKey; // An arbitrary Unicode string
560  // ut16 Padding;
561  ut16 *Value; // A zero-terminated string.
562 } String;
563 
564 typedef struct {
565  ut16 wLength; // The length, in bytes, of this StringTable structure, including all structures indicated by the Children member.
566  ut16 wValueLength; // always 0
567  ut16 wType; // 1 text; 0 binary
569  // An 8-digit hexadecimal number stored as a Unicode string.
570  // The four most significant digits represent the language identifier.
571  // The four least significant digits represent the code page for which the data is formatted
572  // ut16 Padding;
574  String **Children; // An array of one or more String structures
575 } StringTable;
576 
577 typedef struct {
578  ut16 wLength; // The length, in bytes, of the entire StringFileInfo block, including all structures indicated by the Children member.
579  ut16 wValueLength; // always 0
580  ut16 wType; // 1 text; 0 binary
581  ut16 *szKey; // L"StringFileInfo"
582  // ut16 Padding;
584  StringTable **Children; // An array of one or more StringTable structures
586 
587 typedef struct {
588  ut16 wLength; // The length, in bytes, of the Var structure. (with pad)
589  ut16 wValueLength; // The length, in bytes, of the Value member.
590  ut16 wType; // 1 text; 0 binary
591  ut16 *szKey; // L"Translation"
592  // ut16 Padding;
594  ut32 *Value; // An array of one or more values that are language and code page identifier pairs
595 } Var;
596 
597 typedef struct {
598  ut16 wLength; // The length, in bytes, of the entire VarFileInfo block, including all structures indicated by the Children member. (with pad)
599  ut16 wValueLength; // always 0
600  ut16 wType; // 1 text; 0 binary
601  ut16 *szKey; // L"VarFileInfo"
602  // ut16 Padding;
604  Var **Children; // Typically contains a list of languages that the application or DLL supports.
605 } VarFileInfo;
606 
607 #define PE_VS_FF_DEBUG 0x00000001L
608 #define PE_VS_FF_PRERELEASE 0x00000002L
609 #define PE_VS_FF_PATCHED 0x00000004L
610 #define PE_VS_FF_PRIVATEBUILD 0x00000008L
611 #define PE_VS_FF_INFOINFERRED 0x00000010L
612 #define PE_VS_FF_SPECIALBUILD 0x00000020L
613 
614 #define PE_VOS_DOS 0x00010000L
615 #define PE_VOS_NT 0x00040000L
616 #define PE_VOS__WINDOWS16 0x00000001L
617 #define PE_VOS__WINDOWS32 0x00000004L
618 #define PE_VOS_OS216 0x00020000L
619 #define PE_VOS_OS232 0x00030000L
620 #define PE_VOS__PM16 0x00000002L
621 #define PE_VOS__PM32 0x00000003L
622 #define PE_VOS_UNKNOWN 0x00000000L
623 
624 #define PE_VOS_DOS_WINDOWS16 0x00010001L
625 #define PE_VOS_DOS_WINDOWS32 0x00010004L
626 #define PE_VOS_NT_WINDOWS32 0x00040004L
627 #define PE_VOS_OS216_PM16 0x00020002L
628 #define PE_VOS_OS232_PM32 0x00030003L
629 
630 #define PE_VFT_APP 0x00000001L
631 #define PE_VFT_DLL 0x00000002L
632 #define PE_VFT_DRV 0x00000003L
633 #define PE_VFT_FONT 0x00000004L
634 #define PE_VFT_STATIC_LIB 0x00000007L
635 #define PE_VFT_UNKNOWN 0x00000000L
636 #define PE_VFT_VXD 0x00000005L
637 
638 #define PE_VFT2_DRV_COMM 0x0000000AL
639 #define PE_VFT2_DRV_DISPLAY 0x00000004L
640 #define PE_VFT2_DRV_INSTALLABLE 0x00000008L
641 #define PE_VFT2_DRV_KEYBOARD 0x00000002L
642 #define PE_VFT2_DRV_LANGUAGE 0x00000003L
643 #define PE_VFT2_DRV_MOUSE 0x00000005L
644 #define PE_VFT2_DRV_NETWORK 0x00000006L
645 #define PE_VFT2_DRV_PRINTER 0x00000001L
646 #define PE_VFT2_DRV_SOUND 0x00000009L
647 #define PE_VFT2_DRV_SYSTEM 0x00000007L
648 #define PE_VFT2_DRV_VERSIONED_PRINTER 0x0000000CL
649 #define PE_VFT2_UNKNOWN 0x00000000L
650 
651 #define PE_VFT2_FONT_RASTER 0x00000001L
652 #define PE_VFT2_FONT_TRUETYPE 0x00000003L
653 #define PE_VFT2_FONT_VECTOR 0x00000002L
654 #define PE_VFT2_UNKNOWN 0x00000000L
655 
656 typedef struct {
657  ut32 dwSignature; // Contains the value 0xFEEF04BD
671 
672 typedef struct {
673  ut16 wLength; // whole structure size (padding not included (in case of multiply version info structures))
674  ut16 wValueLength; // if 0 there is no Value
675  ut16 wType; // 1 text; 0 binary
676  ut16 *szKey; // L"VS_VERSION_INFO"
677  // ut16 Padding1; //pad for 32 boundary
679  // ut16 Padding2; //pad for 32 boundary
680  VarFileInfo *varFileInfo; // 0 or 1 elements
681  StringFileInfo *stringFileInfo; // 0 or 1 elements
683 
684 // Specific for x64 SEH
685 
686 typedef enum {
687  UWOP_PUSH_NONVOL = 0, /* info == register number */
688  UWOP_ALLOC_LARGE, /* no info, alloc size in next 2 slots */
689  UWOP_ALLOC_SMALL, /* info == size of allocation / 8 - 1 */
690  UWOP_SET_FPREG, /* no info, FP = RSP + UNWIND_INFO.FPRegOffset*16 */
691  UWOP_SAVE_NONVOL, /* info == register number, offset in next slot */
692  UWOP_SAVE_NONVOL_FAR, /* info == register number, offset in next 2 slots */
693  UWOP_UNKNOWN1, /* 1 extra slot */
694  UWOP_UNKNOWN2, /* 2 extra slots */
695  UWOP_SAVE_XMM128, /* info == XMM reg number, offset in next slot */
696  UWOP_SAVE_XMM128_FAR, /* info == XMM reg number, offset in next 2 slots */
697  UWOP_PUSH_MACHFRAME /* info == 0: no error-code, 1: error-code */
699 
700 #define PE64_UNW_FLAG_NHANDLER 0
701 #define PE64_UNW_FLAG_EHANDLER 1
702 #define PE64_UNW_FLAG_UHANDLER 2
703 #define PE64_UNW_FLAG_CHAININFO 4
704 
705 typedef struct {
706  ut32 BeginAddress; // Function start address
707  ut32 EndAddress; // Function end address
708  union {
711  };
713 
714 typedef union {
715  struct {
718  ut8 OpInfo : 4;
719  };
722 
723 typedef struct {
725  ut8 Flags : 5;
730  PE64_UNWIND_CODE UnwindCode[];
731  /*
732  union {
733  ut32 ExceptionHandler; // if (flags & UNW_FLAG_EHANDLER)
734  PE64_RUNTIME_FUNCTION FunctionEntry; // else if (flags & UNW_FLAG_CHAININFO)
735  };
736  ut32 ExceptionData[]; // if (flags & UNW_FLAG_EHANDLER)
737  */
739 
740 typedef struct {
746 
747 typedef struct {
749  PE64_SCOPE_RECORD ScopeRecord[];
751 
756 
761 
762 #endif
uint16_t ut16
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
#define header(is_bt, len_min, ret_op)
void Pe64_write_image_section_header(RzBuffer *b, ut64 addr, Pe64_image_section_header *section_header)
#define PE_IMAGE_SIZEOF_SHORT_NAME
Definition: pe_specs.h:352
struct Pe32_image_file_header Pe64_image_file_header
bool Pe32_read_image_section_header(RzBuffer *b, ut64 addr, Pe32_image_section_header *section_header)
PE64_UNWIND_CODE_OPS
Definition: pe_specs.h:686
@ UWOP_SET_FPREG
Definition: pe_specs.h:690
@ UWOP_UNKNOWN2
Definition: pe_specs.h:694
@ UWOP_SAVE_XMM128_FAR
Definition: pe_specs.h:696
@ UWOP_ALLOC_LARGE
Definition: pe_specs.h:688
@ UWOP_PUSH_MACHFRAME
Definition: pe_specs.h:697
@ UWOP_SAVE_XMM128
Definition: pe_specs.h:695
@ UWOP_SAVE_NONVOL_FAR
Definition: pe_specs.h:692
@ UWOP_PUSH_NONVOL
Definition: pe_specs.h:687
@ UWOP_ALLOC_SMALL
Definition: pe_specs.h:689
@ UWOP_SAVE_NONVOL
Definition: pe_specs.h:691
@ UWOP_UNKNOWN1
Definition: pe_specs.h:693
struct Pe32_image_data_directory Pe64_image_data_directory
struct Pe32_image_section_header Pe64_image_section_header
bool Pe32_read_dos_header(RzBuffer *buf, Pe32_image_dos_header *header)
bool Pe32_read_nt_headers(RzBuffer *buf, ut64 addr, Pe32_image_nt_headers *headers)
bool Pe64_read_image_section_header(RzBuffer *b, ut64 addr, Pe64_image_section_header *section_header)
bool Pe64_read_dos_header(RzBuffer *buf, Pe64_image_dos_header *header)
struct Pe32_image_import_directory Pe64_image_import_directory
struct Pe32_image_delay_import_directory Pe64_image_delay_import_directory
void Pe32_write_image_section_header(RzBuffer *b, ut64 addr, Pe32_image_section_header *section_header)
struct Pe32_image_export_directory Pe64_image_export_directory
#define PE_IMAGE_DIRECTORY_ENTRIES
Definition: pe_specs.h:142
struct Pe32_image_dos_header Pe64_image_dos_header
bool Pe64_read_nt_headers(RzBuffer *buf, ut64 addr, Pe64_image_nt_headers *headers)
struct Pe32_image_debug_directory_entry Pe64_image_debug_directory_entry
struct Pe32_image_tls_directory Pe64_image_tls_directory
#define b(i)
Definition: sha256.c:42
VarFileInfo * varFileInfo
Definition: pe_specs.h:680
StringFileInfo * stringFileInfo
Definition: pe_specs.h:681
PE_VS_FIXEDFILEINFO * Value
Definition: pe_specs.h:678
Definition: pe_specs.h:449
ut32 PointerToRawData
Definition: pe_specs.h:457
ut32 TimeDateStamp
Definition: pe_specs.h:451
ut16 MinorVersion
Definition: pe_specs.h:453
ut32 AddressOfRawData
Definition: pe_specs.h:456
ut32 SizeOfData
Definition: pe_specs.h:455
ut32 Type
Definition: pe_specs.h:454
ut16 MajorVersion
Definition: pe_specs.h:452
ut32 Characteristics
Definition: pe_specs.h:450
Pe32_image_file_header file_header
Definition: pe_specs.h:439
Pe32_image_optional_header optional_header
Definition: pe_specs.h:440
Pe64_image_file_header file_header
Definition: pe_specs.h:445
Pe64_image_optional_header optional_header
Definition: pe_specs.h:446
ut8 * bCertificate
Definition: pe_specs.h:421
ut16 wRevision
Definition: pe_specs.h:419
ut16 wCertificateType
Definition: pe_specs.h:420
Definition: pe_specs.h:501
ut32 Size
Definition: pe_specs.h:503
ut32 OffsetToData
Definition: pe_specs.h:502
ut32 Reserved
Definition: pe_specs.h:505
ut32 CodePage
Definition: pe_specs.h:504
Definition: pe_specs.h:469
ut32 Name
Definition: pe_specs.h:476
ut32 OffsetToData
Definition: pe_specs.h:483
Definition: pe_specs.h:345
ut16 productId
Definition: pe_specs.h:346
ut32 timesUsed
Definition: pe_specs.h:348
char * productName
Definition: pe_specs.h:349
ut16 minVersion
Definition: pe_specs.h:347
Pe_certificate ** certificates
Definition: pe_specs.h:426
ut32 numOfChildren
Definition: pe_specs.h:583
ut16 wValueLength
Definition: pe_specs.h:579
ut16 * szKey
Definition: pe_specs.h:581
StringTable ** Children
Definition: pe_specs.h:584
ut16 wValueLength
Definition: pe_specs.h:566
ut32 numOfChildren
Definition: pe_specs.h:573
ut16 * szKey
Definition: pe_specs.h:568
String ** Children
Definition: pe_specs.h:574
ut16 wType
Definition: pe_specs.h:567
ut16 wLength
Definition: pe_specs.h:565
ut16 wKeyLen
Definition: pe_specs.h:558
ut16 wValueLength
Definition: pe_specs.h:556
ut16 * Value
Definition: pe_specs.h:561
ut16 * szKey
Definition: pe_specs.h:559
ut16 wType
Definition: pe_specs.h:557
ut16 wLength
Definition: pe_specs.h:555
ut16 wLength
Definition: pe_specs.h:598
ut16 * szKey
Definition: pe_specs.h:601
Var ** Children
Definition: pe_specs.h:604
ut32 numOfChildren
Definition: pe_specs.h:603
ut16 wType
Definition: pe_specs.h:600
ut16 wValueLength
Definition: pe_specs.h:599
Definition: pe_specs.h:587
ut16 wLength
Definition: pe_specs.h:588
ut32 numOfValues
Definition: pe_specs.h:593
ut16 wValueLength
Definition: pe_specs.h:589
ut16 wType
Definition: pe_specs.h:590
ut16 * szKey
Definition: pe_specs.h:591
ut32 * Value
Definition: pe_specs.h:594
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58