Deleted Added
full compact
pe_var.h (151703) pe_var.h (189488)
1/*-
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
1/*-
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/compat/ndis/pe_var.h 151703 2005-10-26 18:46:27Z wpaul $
32 * $FreeBSD: head/sys/compat/ndis/pe_var.h 189488 2009-03-07 07:26:22Z weongyo $
33 */
34
35#ifndef _PE_VAR_H_
33 */
34
35#ifndef _PE_VAR_H_
36#define _PE_VAR_H_
36#define _PE_VAR_H_
37
38/*
39 * Image Format
40 */
41
37
38/*
39 * Image Format
40 */
41
42#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
43#define IMAGE_OS2_SIGNATURE 0x454E /* NE */
44#define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
45#define IMAGE_VXD_SIGNATURE 0x454C /* LE */
46#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
42#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
43#define IMAGE_OS2_SIGNATURE 0x454E /* NE */
44#define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
45#define IMAGE_VXD_SIGNATURE 0x454C /* LE */
46#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
47
48/*
49 * All PE files have one of these, just so if you attempt to
50 * run them, they'll print out a message telling you they can
51 * only be run in Windows.
52 */
53
54struct image_dos_header {

--- 24 unchanged lines hidden (view full) ---

79 * File header format.
80 */
81
82struct image_file_header {
83 uint16_t ifh_machine; /* Machine type */
84 uint16_t ifh_numsections; /* # of sections */
85 uint32_t ifh_timestamp; /* Date/time stamp */
86 uint32_t ifh_symtblptr; /* Offset to symbol table */
47
48/*
49 * All PE files have one of these, just so if you attempt to
50 * run them, they'll print out a message telling you they can
51 * only be run in Windows.
52 */
53
54struct image_dos_header {

--- 24 unchanged lines hidden (view full) ---

79 * File header format.
80 */
81
82struct image_file_header {
83 uint16_t ifh_machine; /* Machine type */
84 uint16_t ifh_numsections; /* # of sections */
85 uint32_t ifh_timestamp; /* Date/time stamp */
86 uint32_t ifh_symtblptr; /* Offset to symbol table */
87 uint32_t ifh_numsyms; /* # of symbols */
87 uint32_t ifh_numsyms; /* # of symbols */
88 uint16_t ifh_optionalhdrlen; /* Size of optional header */
89 uint16_t ifh_characteristics; /* Characteristics */
90};
91
92typedef struct image_file_header image_file_header;
93
94/* Machine types */
95
88 uint16_t ifh_optionalhdrlen; /* Size of optional header */
89 uint16_t ifh_characteristics; /* Characteristics */
90};
91
92typedef struct image_file_header image_file_header;
93
94/* Machine types */
95
96#define IMAGE_FILE_MACHINE_UNKNOWN 0
97#define IMAGE_FILE_MACHINE_I860 0x014d
98#define IMAGE_FILE_MACHINE_I386 0x014c
99#define IMAGE_FILE_MACHINE_R3000 0x0162
100#define IMAGE_FILE_MACHINE_R4000 0x0166
101#define IMAGE_FILE_MACHINE_R10000 0x0168
102#define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
103#define IMAGE_FILE_MACHINE_ALPHA 0x0184
104#define IMAGE_FILE_MACHINE_SH3 0x01a2
105#define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
106#define IMAGE_FILE_MACHINE_SH3E 0x01a4
107#define IMAGE_FILE_MACHINE_SH4 0x01a6
108#define IMAGE_FILE_MACHINE_SH5 0x01a8
109#define IMAGE_FILE_MACHINE_ARM 0x01c0
110#define IMAGE_FILE_MACHINE_THUMB 0x01c2
111#define IMAGE_FILE_MACHINE_AM33 0x01d3
112#define IMAGE_FILE_MACHINE_POWERPC 0x01f0
113#define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
114#define IMAGE_FILE_MACHINE_IA64 0x0200
115#define IMAGE_FILE_MACHINE_MIPS16 0x0266
116#define IMAGE_FILE_MACHINE_ALPHA64 0x0284
117#define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
118#define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
119#define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
120#define IMAGE_FILE_MACHINE_TRICORE 0x0520
121#define IMAGE_FILE_MACHINE_CEF 0x0cef
122#define IMAGE_FILE_MACHINE_EBC 0x0ebc
123#define IMAGE_FILE_MACHINE_AMD64 0x8664
124#define IMAGE_FILE_MACHINE_M32R 0x9041
125#define IMAGE_FILE_MACHINE_CEE 0xc0ee
96#define IMAGE_FILE_MACHINE_UNKNOWN 0
97#define IMAGE_FILE_MACHINE_I860 0x014d
98#define IMAGE_FILE_MACHINE_I386 0x014c
99#define IMAGE_FILE_MACHINE_R3000 0x0162
100#define IMAGE_FILE_MACHINE_R4000 0x0166
101#define IMAGE_FILE_MACHINE_R10000 0x0168
102#define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
103#define IMAGE_FILE_MACHINE_ALPHA 0x0184
104#define IMAGE_FILE_MACHINE_SH3 0x01a2
105#define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
106#define IMAGE_FILE_MACHINE_SH3E 0x01a4
107#define IMAGE_FILE_MACHINE_SH4 0x01a6
108#define IMAGE_FILE_MACHINE_SH5 0x01a8
109#define IMAGE_FILE_MACHINE_ARM 0x01c0
110#define IMAGE_FILE_MACHINE_THUMB 0x01c2
111#define IMAGE_FILE_MACHINE_AM33 0x01d3
112#define IMAGE_FILE_MACHINE_POWERPC 0x01f0
113#define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
114#define IMAGE_FILE_MACHINE_IA64 0x0200
115#define IMAGE_FILE_MACHINE_MIPS16 0x0266
116#define IMAGE_FILE_MACHINE_ALPHA64 0x0284
117#define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
118#define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
119#define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
120#define IMAGE_FILE_MACHINE_TRICORE 0x0520
121#define IMAGE_FILE_MACHINE_CEF 0x0cef
122#define IMAGE_FILE_MACHINE_EBC 0x0ebc
123#define IMAGE_FILE_MACHINE_AMD64 0x8664
124#define IMAGE_FILE_MACHINE_M32R 0x9041
125#define IMAGE_FILE_MACHINE_CEE 0xc0ee
126
127/* Characteristics */
128
126
127/* Characteristics */
128
129#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
130#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
131#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
132#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
133#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
134#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
135#define IMAGE_FILE_16BIT_MACHINE 0x0040
136#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
137#define IMAGE_FILE_32BIT_MACHINE 0x0100
138#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
139#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
140#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
141#define IMAGE_FILE_SYSTEM 0x1000
142#define IMAGE_FILE_DLL 0x2000
143#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
144#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
129#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
130#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
131#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
132#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
133#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
134#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
135#define IMAGE_FILE_16BIT_MACHINE 0x0040
136#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
137#define IMAGE_FILE_32BIT_MACHINE 0x0100
138#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
139#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
140#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
141#define IMAGE_FILE_SYSTEM 0x1000
142#define IMAGE_FILE_DLL 0x2000
143#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
144#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
145
145
146#define IMAGE_SIZEOF_FILE_HEADER 20
146#define IMAGE_SIZEOF_FILE_HEADER 20
147
148/*
149 * Directory format.
150 */
151
152struct image_data_directory {
153 uint32_t idd_vaddr; /* virtual address */
154 uint32_t idd_size; /* size */
155};
156
157typedef struct image_data_directory image_data_directory;
158
147
148/*
149 * Directory format.
150 */
151
152struct image_data_directory {
153 uint32_t idd_vaddr; /* virtual address */
154 uint32_t idd_size; /* size */
155};
156
157typedef struct image_data_directory image_data_directory;
158
159#define IMAGE_DIRECTORY_ENTRIES_MAX 16
159#define IMAGE_DIRECTORY_ENTRIES_MAX 16
160
161/*
162 * Optional header format.
163 */
164
165struct image_optional_header {
166
167 /* Standard fields */

--- 47 unchanged lines hidden (view full) ---

215typedef struct image_nt_header image_nt_header;
216
217#define IMAGE_SIZEOF_NT_HEADER(nthdr) \
218 (offsetof(image_nt_header, inh_optionalhdr) + \
219 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen)
220
221/* Directory Entries */
222
160
161/*
162 * Optional header format.
163 */
164
165struct image_optional_header {
166
167 /* Standard fields */

--- 47 unchanged lines hidden (view full) ---

215typedef struct image_nt_header image_nt_header;
216
217#define IMAGE_SIZEOF_NT_HEADER(nthdr) \
218 (offsetof(image_nt_header, inh_optionalhdr) + \
219 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen)
220
221/* Directory Entries */
222
223#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */
224#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */
225#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */
226#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */
227#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */
228#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */
229#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */
230#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 /* Description String */
231#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* Machine Value (MIPS GP) */
232#define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */
233#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */
234#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */
235#define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
236#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
237#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
223#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */
224#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */
225#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */
226#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */
227#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */
228#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */
229#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */
230#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 /* Description String */
231#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* Machine Value (MIPS GP) */
232#define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */
233#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */
234#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */
235#define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
236#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
237#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
238
239/* Resource types */
240
238
239/* Resource types */
240
241#define RT_CURSOR 1
242#define RT_BITMAP 2
243#define RT_ICON 3
244#define RT_MENU 4
245#define RT_DIALOG 5
246#define RT_STRING 6
247#define RT_FONTDIR 7
248#define RT_FONT 8
249#define RT_ACCELERATOR 9
250#define RT_RCDATA 10
251#define RT_MESSAGETABLE 11
252#define RT_GROUP_CURSOR 12
253#define RT_GROUP_ICON 14
254#define RT_VERSION 16
255#define RT_DLGINCLUDE 17
256#define RT_PLUGPLAY 19
257#define RT_VXD 20
258#define RT_ANICURSOR 21
259#define RT_ANIICON 22
260#define RT_HTML 23
241#define RT_CURSOR 1
242#define RT_BITMAP 2
243#define RT_ICON 3
244#define RT_MENU 4
245#define RT_DIALOG 5
246#define RT_STRING 6
247#define RT_FONTDIR 7
248#define RT_FONT 8
249#define RT_ACCELERATOR 9
250#define RT_RCDATA 10
251#define RT_MESSAGETABLE 11
252#define RT_GROUP_CURSOR 12
253#define RT_GROUP_ICON 14
254#define RT_VERSION 16
255#define RT_DLGINCLUDE 17
256#define RT_PLUGPLAY 19
257#define RT_VXD 20
258#define RT_ANICURSOR 21
259#define RT_ANIICON 22
260#define RT_HTML 23
261
262/*
263 * Section header format.
264 */
265
261
262/*
263 * Section header format.
264 */
265
266#define IMAGE_SHORT_NAME_LEN 8
266#define IMAGE_SHORT_NAME_LEN 8
267
268struct image_section_header {
269 uint8_t ish_name[IMAGE_SHORT_NAME_LEN];
270 union {
271 uint32_t ish_paddr;
272 uint32_t ish_vsize;
273 } ish_misc;
274 uint32_t ish_vaddr;
275 uint32_t ish_rawdatasize;
276 uint32_t ish_rawdataaddr;
277 uint32_t ish_relocaddr;
278 uint32_t ish_linenumaddr;
279 uint16_t ish_numrelocs;
280 uint16_t ish_numlinenums;
281 uint32_t ish_characteristics;
282};
283
284typedef struct image_section_header image_section_header;
285
267
268struct image_section_header {
269 uint8_t ish_name[IMAGE_SHORT_NAME_LEN];
270 union {
271 uint32_t ish_paddr;
272 uint32_t ish_vsize;
273 } ish_misc;
274 uint32_t ish_vaddr;
275 uint32_t ish_rawdatasize;
276 uint32_t ish_rawdataaddr;
277 uint32_t ish_relocaddr;
278 uint32_t ish_linenumaddr;
279 uint16_t ish_numrelocs;
280 uint16_t ish_numlinenums;
281 uint32_t ish_characteristics;
282};
283
284typedef struct image_section_header image_section_header;
285
286#define IMAGE_SIZEOF_SECTION_HEADER 40
286#define IMAGE_SIZEOF_SECTION_HEADER 40
287
287
288#define IMAGE_FIRST_SECTION(nthdr) \
288#define IMAGE_FIRST_SECTION(nthdr) \
289 ((image_section_header *)((vm_offset_t)(nthdr) + \
290 offsetof(image_nt_header, inh_optionalhdr) + \
291 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen))
292
293/*
294 * Import format
295 */
296
297struct image_import_by_name {
298 uint16_t iibn_hint;
299 uint8_t iibn_name[1];
300};
301
289 ((image_section_header *)((vm_offset_t)(nthdr) + \
290 offsetof(image_nt_header, inh_optionalhdr) + \
291 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen))
292
293/*
294 * Import format
295 */
296
297struct image_import_by_name {
298 uint16_t iibn_hint;
299 uint8_t iibn_name[1];
300};
301
302#define IMAGE_ORDINAL_FLAG 0x80000000
303#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
302#define IMAGE_ORDINAL_FLAG 0x80000000
303#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
304
305struct image_import_descriptor {
306 uint32_t iid_import_name_table_addr;
307 uint32_t iid_timestamp;
308 uint32_t iid_forwardchain;
309 uint32_t iid_nameaddr;
310 uint32_t iid_import_address_table_addr;
311};
312
313typedef struct image_import_descriptor image_import_descriptor;
314
315struct image_base_reloc {
316 uint32_t ibr_vaddr;
317 uint32_t ibr_blocksize;
318 uint16_t ibr_rel[1];
319};
320
321typedef struct image_base_reloc image_base_reloc;
322
304
305struct image_import_descriptor {
306 uint32_t iid_import_name_table_addr;
307 uint32_t iid_timestamp;
308 uint32_t iid_forwardchain;
309 uint32_t iid_nameaddr;
310 uint32_t iid_import_address_table_addr;
311};
312
313typedef struct image_import_descriptor image_import_descriptor;
314
315struct image_base_reloc {
316 uint32_t ibr_vaddr;
317 uint32_t ibr_blocksize;
318 uint16_t ibr_rel[1];
319};
320
321typedef struct image_base_reloc image_base_reloc;
322
323#define IMR_RELTYPE(x) ((x >> 12) & 0xF)
324#define IMR_RELOFFSET(x) (x & 0xFFF)
323#define IMR_RELTYPE(x) ((x >> 12) & 0xF)
324#define IMR_RELOFFSET(x) (x & 0xFFF)
325
326/* generic relocation types */
325
326/* generic relocation types */
327#define IMAGE_REL_BASED_ABSOLUTE 0
328#define IMAGE_REL_BASED_HIGH 1
329#define IMAGE_REL_BASED_LOW 2
330#define IMAGE_REL_BASED_HIGHLOW 3
331#define IMAGE_REL_BASED_HIGHADJ 4
332#define IMAGE_REL_BASED_MIPS_JMPADDR 5
333#define IMAGE_REL_BASED_SECTION 6
334#define IMAGE_REL_BASED_REL 7
335#define IMAGE_REL_BASED_MIPS_JMPADDR16 9
336#define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
337#define IMAGE_REL_BASED_DIR64 10
338#define IMAGE_REL_BASED_HIGH3ADJ 11
327#define IMAGE_REL_BASED_ABSOLUTE 0
328#define IMAGE_REL_BASED_HIGH 1
329#define IMAGE_REL_BASED_LOW 2
330#define IMAGE_REL_BASED_HIGHLOW 3
331#define IMAGE_REL_BASED_HIGHADJ 4
332#define IMAGE_REL_BASED_MIPS_JMPADDR 5
333#define IMAGE_REL_BASED_SECTION 6
334#define IMAGE_REL_BASED_REL 7
335#define IMAGE_REL_BASED_MIPS_JMPADDR16 9
336#define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
337#define IMAGE_REL_BASED_DIR64 10
338#define IMAGE_REL_BASED_HIGH3ADJ 11
339
340struct image_resource_directory_entry {
341 uint32_t irde_name;
342 uint32_t irde_dataoff;
343};
344
345typedef struct image_resource_directory_entry image_resource_directory_entry;
346
339
340struct image_resource_directory_entry {
341 uint32_t irde_name;
342 uint32_t irde_dataoff;
343};
344
345typedef struct image_resource_directory_entry image_resource_directory_entry;
346
347#define RESOURCE_NAME_STR 0x80000000
348#define RESOURCE_DIR_FLAG 0x80000000
347#define RESOURCE_NAME_STR 0x80000000
348#define RESOURCE_DIR_FLAG 0x80000000
349
350struct image_resource_directory {
351 uint32_t ird_characteristics;
352 uint32_t ird_timestamp;
353 uint16_t ird_majorver;
354 uint16_t ird_minorver;
355 uint16_t ird_named_entries;
356 uint16_t ird_id_entries;

--- 48 unchanged lines hidden (view full) ---

405struct message_resource_entry {
406 uint16_t mre_len;
407 uint16_t mre_flags;
408 char mre_text[];
409};
410
411typedef struct message_resource_entry message_resource_entry;
412
349
350struct image_resource_directory {
351 uint32_t ird_characteristics;
352 uint32_t ird_timestamp;
353 uint16_t ird_majorver;
354 uint16_t ird_minorver;
355 uint16_t ird_named_entries;
356 uint16_t ird_id_entries;

--- 48 unchanged lines hidden (view full) ---

405struct message_resource_entry {
406 uint16_t mre_len;
407 uint16_t mre_flags;
408 char mre_text[];
409};
410
411typedef struct message_resource_entry message_resource_entry;
412
413#define MESSAGE_RESOURCE_UNICODE 0x0001
413#define MESSAGE_RESOURCE_UNICODE 0x0001
414
415struct image_patch_table {
416 char *ipt_name;
417 void (*ipt_func)(void);
418 void (*ipt_wrap)(void);
419 int ipt_argcnt;
420 int ipt_ftype;
421};

--- 34 unchanged lines hidden (view full) ---

456extern uint64_t x86_64_call3(void *, uint64_t, uint64_t, uint64_t);
457extern uint64_t x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t);
458extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t,
459 uint64_t);
460extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
461 uint64_t, uint64_t);
462
463
414
415struct image_patch_table {
416 char *ipt_name;
417 void (*ipt_func)(void);
418 void (*ipt_wrap)(void);
419 int ipt_argcnt;
420 int ipt_ftype;
421};

--- 34 unchanged lines hidden (view full) ---

456extern uint64_t x86_64_call3(void *, uint64_t, uint64_t, uint64_t);
457extern uint64_t x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t);
458extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t,
459 uint64_t);
460extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
461 uint64_t, uint64_t);
462
463
464#define MSCALL1(fn, a) \
464#define MSCALL1(fn, a) \
465 x86_64_call1((fn), (uint64_t)(a))
465 x86_64_call1((fn), (uint64_t)(a))
466#define MSCALL2(fn, a, b) \
466#define MSCALL2(fn, a, b) \
467 x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b))
467 x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b))
468#define MSCALL3(fn, a, b, c) \
468#define MSCALL3(fn, a, b, c) \
469 x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b), \
470 (uint64_t)(c))
469 x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b), \
470 (uint64_t)(c))
471#define MSCALL4(fn, a, b, c, d) \
471#define MSCALL4(fn, a, b, c, d) \
472 x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b), \
473 (uint64_t)(c), (uint64_t)(d))
472 x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b), \
473 (uint64_t)(c), (uint64_t)(d))
474#define MSCALL5(fn, a, b, c, d, e) \
474#define MSCALL5(fn, a, b, c, d, e) \
475 x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b), \
476 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e))
475 x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b), \
476 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e))
477#define MSCALL6(fn, a, b, c, d, e, f) \
477#define MSCALL6(fn, a, b, c, d, e, f) \
478 x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \
479 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f))
480
481#endif /* __amd64__ */
482
483#ifdef __i386__
484
485extern uint32_t x86_stdcall_call(void *, int, ...);
486
478 x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \
479 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f))
480
481#endif /* __amd64__ */
482
483#ifdef __i386__
484
485extern uint32_t x86_stdcall_call(void *, int, ...);
486
487#define MSCALL1(fn, a) x86_stdcall_call(fn, 1, (a))
488#define MSCALL2(fn, a, b) x86_stdcall_call(fn, 2, (a), (b))
489#define MSCALL3(fn, a, b, c) x86_stdcall_call(fn, 3, (a), (b), (c))
490#define MSCALL4(fn, a, b, c, d) x86_stdcall_call(fn, 4, (a), (b), (c), (d))
491#define MSCALL5(fn, a, b, c, d, e) \
487#define MSCALL1(fn, a) x86_stdcall_call(fn, 1, (a))
488#define MSCALL2(fn, a, b) x86_stdcall_call(fn, 2, (a), (b))
489#define MSCALL3(fn, a, b, c) x86_stdcall_call(fn, 3, (a), (b), (c))
490#define MSCALL4(fn, a, b, c, d) x86_stdcall_call(fn, 4, (a), (b), (c), (d))
491#define MSCALL5(fn, a, b, c, d, e) \
492 x86_stdcall_call(fn, 5, (a), (b), (c), (d), (e))
492 x86_stdcall_call(fn, 5, (a), (b), (c), (d), (e))
493#define MSCALL6(fn, a, b, c, d, e, f) \
493#define MSCALL6(fn, a, b, c, d, e, f) \
494 x86_stdcall_call(fn, 6, (a), (b), (c), (d), (e), (f))
495
496#endif /* __i386__ */
497
498
494 x86_stdcall_call(fn, 6, (a), (b), (c), (d), (e), (f))
495
496#endif /* __i386__ */
497
498
499#define FUNC void(*)(void)
499#define FUNC void(*)(void)
500
501#ifdef __i386__
500
501#ifdef __i386__
502#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_STDCALL }
503#define IMPORT_SFUNC_MAP(x, y, z) \
502#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_STDCALL }
503#define IMPORT_SFUNC_MAP(x, y, z) \
504 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_STDCALL }
504 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_STDCALL }
505#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_FASTCALL }
506#define IMPORT_FFUNC_MAP(x, y, z) \
505#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_FASTCALL }
506#define IMPORT_FFUNC_MAP(x, y, z) \
507 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_FASTCALL }
507 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_FASTCALL }
508#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_REGPARM }
509#define IMPORT_RFUNC_MAP(x, y, z) \
508#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_REGPARM }
509#define IMPORT_RFUNC_MAP(x, y, z) \
510 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_REGPARM }
510 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_REGPARM }
511#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_CDECL }
512#define IMPORT_CFUNC_MAP(x, y, z) \
511#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_CDECL }
512#define IMPORT_CFUNC_MAP(x, y, z) \
513 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_CDECL }
514#endif /* __i386__ */
515
516#ifdef __amd64__
513 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_CDECL }
514#endif /* __i386__ */
515
516#ifdef __amd64__
517#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
518#define IMPORT_SFUNC_MAP(x, y, z) \
517#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
518#define IMPORT_SFUNC_MAP(x, y, z) \
519 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
519 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
520#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
521#define IMPORT_FFUNC_MAP(x, y, z) \
520#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
521#define IMPORT_FFUNC_MAP(x, y, z) \
522 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
522 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
523#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
524#define IMPORT_RFUNC_MAP(x, y, z) \
523#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
524#define IMPORT_RFUNC_MAP(x, y, z) \
525 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
525 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
526#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
527#define IMPORT_CFUNC_MAP(x, y, z) \
526#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
527#define IMPORT_CFUNC_MAP(x, y, z) \
528 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
529#endif /* __amd64__ */
530
531__BEGIN_DECLS
532extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
533extern int pe_is_nt_image(vm_offset_t);
534extern int pe_get_optional_header(vm_offset_t, image_optional_header *);
535extern int pe_get_file_header(vm_offset_t, image_file_header *);

--- 14 unchanged lines hidden ---
528 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
529#endif /* __amd64__ */
530
531__BEGIN_DECLS
532extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
533extern int pe_is_nt_image(vm_offset_t);
534extern int pe_get_optional_header(vm_offset_t, image_optional_header *);
535extern int pe_get_file_header(vm_offset_t, image_file_header *);

--- 14 unchanged lines hidden ---