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
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
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: src/sys/compat/ndis/pe_var.h,v 1.8.2.2 2005/02/18 16:30:09 wpaul Exp $
33 */
34
35#ifndef _PE_VAR_H_
36#define _PE_VAR_H_
37
38#ifdef __NetBSD__
39#include "nbcompat.h"
40#endif
41
42/*
43 *  Image Format
44 */
45
46#define IMAGE_DOS_SIGNATURE			0x5A4D      /* MZ */
47#define IMAGE_OS2_SIGNATURE			0x454E      /* NE */
48#define IMAGE_OS2_SIGNATURE_LE			0x454C      /* LE */
49#define IMAGE_VXD_SIGNATURE			0x454C      /* LE */
50#define IMAGE_NT_SIGNATURE			0x00004550  /* PE00 */
51
52/*
53 * All PE files have one of these, just so if you attempt to
54 * run them, they'll print out a message telling you they can
55 * only be run in Windows.
56 */
57
58struct image_dos_header {
59	uint16_t	idh_magic;	/* Magic number */
60	uint16_t	idh_cblp;	/* Bytes on last page of file */
61	uint16_t	idh_cp;		/* Pages in file */
62	uint16_t	idh_crlc;	/* Relocations */
63	uint16_t	idh_cparhdr;	/* Size of header in paragraphs */
64	uint16_t	idh_minalloc;	/* Minimum extra paragraphs needed */
65	uint16_t	idh_maxalloc;	/* Maximum extra paragraphs needed */
66	uint16_t	idh_ss;		/* Initial (relative) SS value */
67	uint16_t	idh_sp;		/* Initial SP value */
68	uint16_t	idh_csum;	/* Checksum */
69	uint16_t	idh_ip;		/* Initial IP value */
70	uint16_t	idh_cs;		/* Initial (relative) CS value */
71	uint16_t	idh_lfarlc;	/* File address of relocation table */
72	uint16_t	idh_ovno;	/* Overlay number */
73	uint16_t	idh_rsvd1[4];	/* Reserved words */
74	uint16_t	idh_oemid;	/* OEM identifier (for idh_oeminfo) */
75	uint16_t	idh_oeminfo;	/* OEM information; oemid specific */
76	uint16_t	idh_rsvd2[10];	/* Reserved words */
77	uint32_t	idh_lfanew;	/* File address of new exe header */
78};
79
80typedef struct image_dos_header image_dos_header;
81
82/*
83 * File header format.
84 */
85
86struct image_file_header {
87	uint16_t	ifh_machine;		/* Machine type */
88	uint16_t	ifh_numsections;	/* # of sections */
89	uint32_t	ifh_timestamp;		/* Date/time stamp */
90	uint32_t	ifh_symtblptr;		/* Offset to symbol table */
91	uint32_t	ifh_numsyms; 		/* # of symbols */
92	uint16_t	ifh_optionalhdrlen;	/* Size of optional header */
93	uint16_t	ifh_characteristics;	/* Characteristics */
94};
95
96typedef struct image_file_header image_file_header;
97
98/* Machine types */
99
100#define IMAGE_FILE_MACHINE_UNKNOWN      0
101#define IMAGE_FILE_MACHINE_I860         0x014d
102#define IMAGE_FILE_MACHINE_I386         0x014c
103#define IMAGE_FILE_MACHINE_R3000        0x0162
104#define IMAGE_FILE_MACHINE_R4000        0x0166
105#define IMAGE_FILE_MACHINE_R10000       0x0168
106#define IMAGE_FILE_MACHINE_WCEMIPSV2    0x0169
107#define IMAGE_FILE_MACHINE_ALPHA        0x0184
108#define IMAGE_FILE_MACHINE_SH3          0x01a2
109#define IMAGE_FILE_MACHINE_SH3DSP       0x01a3
110#define IMAGE_FILE_MACHINE_SH3E         0x01a4
111#define IMAGE_FILE_MACHINE_SH4          0x01a6
112#define IMAGE_FILE_MACHINE_SH5          0x01a8
113#define IMAGE_FILE_MACHINE_ARM          0x01c0
114#define IMAGE_FILE_MACHINE_THUMB        0x01c2
115#define IMAGE_FILE_MACHINE_AM33         0x01d3
116#define IMAGE_FILE_MACHINE_POWERPC      0x01f0
117#define IMAGE_FILE_MACHINE_POWERPCFP    0x01f1
118#define IMAGE_FILE_MACHINE_IA64         0x0200
119#define IMAGE_FILE_MACHINE_MIPS16       0x0266
120#define IMAGE_FILE_MACHINE_ALPHA64      0x0284
121#define IMAGE_FILE_MACHINE_MIPSFPU      0x0366
122#define IMAGE_FILE_MACHINE_MIPSFPU16    0x0466
123#define IMAGE_FILE_MACHINE_AXP64        IMAGE_FILE_MACHINE_ALPHA64
124#define IMAGE_FILE_MACHINE_TRICORE      0x0520
125#define IMAGE_FILE_MACHINE_CEF          0x0cef
126#define IMAGE_FILE_MACHINE_EBC          0x0ebc
127#define IMAGE_FILE_MACHINE_AMD64        0x8664
128#define IMAGE_FILE_MACHINE_M32R         0x9041
129#define IMAGE_FILE_MACHINE_CEE          0xc0ee
130
131/* Characteristics */
132
133#define IMAGE_FILE_RELOCS_STRIPPED      0x0001 /* No relocation info */
134#define IMAGE_FILE_EXECUTABLE_IMAGE     0x0002
135#define IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004
136#define IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
137#define IMAGE_FILE_AGGRESIVE_WS_TRIM    0x0010
138#define IMAGE_FILE_LARGE_ADDRESS_AWARE  0x0020
139#define IMAGE_FILE_16BIT_MACHINE        0x0040
140#define IMAGE_FILE_BYTES_REVERSED_LO    0x0080
141#define IMAGE_FILE_32BIT_MACHINE        0x0100
142#define IMAGE_FILE_DEBUG_STRIPPED       0x0200
143#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP      0x0400
144#define IMAGE_FILE_NET_RUN_FROM_SWAP    0x0800
145#define IMAGE_FILE_SYSTEM               0x1000
146#define IMAGE_FILE_DLL                  0x2000
147#define IMAGE_FILE_UP_SYSTEM_ONLY       0x4000
148#define IMAGE_FILE_BYTES_REVERSED_HI    0x8000
149
150#define IMAGE_SIZEOF_FILE_HEADER             20
151
152/*
153 * Directory format.
154 */
155
156struct image_data_directory {
157	uint32_t		idd_vaddr;	/* virtual address */
158	uint32_t		idd_size;	/* size */
159};
160
161typedef struct image_data_directory image_data_directory;
162
163#define IMAGE_DIRECTORY_ENTRIES_MAX    16
164
165/*
166 * Optional header format.
167 */
168
169struct image_optional_header {
170
171	/* Standard fields */
172
173	uint16_t	ioh_magic;
174	uint8_t		ioh_linkerver_major;
175	uint8_t		ioh_linkerver_minor;
176	uint32_t	ioh_codesize;
177	uint32_t	ioh_datasize;
178	uint32_t	ioh_bsssize;
179	uint32_t	ioh_entryaddr;
180	uint32_t	ioh_codebaseaddr;
181#ifndef __amd64__
182	uint32_t	ioh_databaseaddr;
183#endif
184
185	/* NT-specific fields */
186
187	uintptr_t	ioh_imagebase;
188	uint32_t	ioh_sectalign;
189	uint32_t	ioh_filealign;
190	uint16_t	ioh_osver_major;
191	uint16_t	ioh_osver_minor;
192	uint16_t	ioh_imagever_major;
193	uint16_t	ioh_imagever_minor;
194	uint16_t	ioh_subsys_major;
195	uint16_t	ioh_subsys_minor;
196	uint32_t	ioh_win32ver;
197	uint32_t	ioh_imagesize;
198	uint32_t	ioh_headersize;
199	uint32_t	ioh_csum;
200	uint16_t	ioh_subsys;
201	uint16_t	ioh_dll_characteristics;
202	uintptr_t	ioh_stackreservesize;
203	uintptr_t	ioh_stackcommitsize;
204	uintptr_t	ioh_heapreservesize;
205	uintptr_t	ioh_heapcommitsize;
206	uint16_t	ioh_loaderflags;
207	uint32_t	ioh_rva_size_cnt;
208	image_data_directory	ioh_datadir[IMAGE_DIRECTORY_ENTRIES_MAX];
209};
210
211typedef struct image_optional_header image_optional_header;
212
213struct image_nt_header {
214	uint32_t		inh_signature;
215	image_file_header	inh_filehdr;
216	image_optional_header	inh_optionalhdr;
217};
218
219typedef struct image_nt_header image_nt_header;
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
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
261
262/*
263 * Section header format.
264 */
265
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
286#define IMAGE_SIZEOF_SECTION_HEADER          40
287
288/*
289 * Import format
290 */
291
292struct image_import_by_name {
293	uint16_t	iibn_hint;
294	uint8_t		iibn_name[1];
295};
296
297#define IMAGE_ORDINAL_FLAG 0x80000000
298#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
299
300struct image_import_descriptor {
301	uint32_t	iid_import_name_table_addr;
302	uint32_t	iid_timestamp;
303	uint32_t	iid_forwardchain;
304	uint32_t	iid_nameaddr;
305	uint32_t	iid_import_address_table_addr;
306};
307
308typedef struct image_import_descriptor image_import_descriptor;
309
310struct image_base_reloc {
311	uint32_t	ibr_vaddr;
312	uint32_t	ibr_blocksize;
313	uint16_t	ibr_rel[1];
314};
315
316typedef struct image_base_reloc image_base_reloc;
317
318#define IMR_RELTYPE(x)		((x >> 12) & 0xF)
319#define IMR_RELOFFSET(x)	(x & 0xFFF)
320
321/* generic relocation types */
322#define IMAGE_REL_BASED_ABSOLUTE                0
323#define IMAGE_REL_BASED_HIGH                    1
324#define IMAGE_REL_BASED_LOW                     2
325#define IMAGE_REL_BASED_HIGHLOW                 3
326#define IMAGE_REL_BASED_HIGHADJ                 4
327#define IMAGE_REL_BASED_MIPS_JMPADDR            5
328#define IMAGE_REL_BASED_SECTION                 6
329#define IMAGE_REL_BASED_REL                     7
330#define IMAGE_REL_BASED_MIPS_JMPADDR16          9
331#define IMAGE_REL_BASED_IA64_IMM64              9 /* yes, 9 too */
332#define IMAGE_REL_BASED_DIR64                   10
333#define IMAGE_REL_BASED_HIGH3ADJ                11
334
335struct image_resource_directory_entry {
336	uint32_t		irde_name;
337	uint32_t		irde_dataoff;
338};
339
340typedef struct image_resource_directory_entry image_resource_directory_entry;
341
342#define RESOURCE_NAME_STR	0x80000000
343#define RESOURCE_DIR_FLAG	0x80000000
344
345struct image_resource_directory {
346	uint32_t		ird_characteristics;
347	uint32_t		ird_timestamp;
348	uint16_t		ird_majorver;
349	uint16_t		ird_minorver;
350	uint16_t		ird_named_entries;
351	uint16_t		ird_id_entries;
352#ifdef notdef
353	image_resource_directory_entry	ird_entries[1];
354#endif
355};
356
357typedef struct image_resource_directory image_resource_directory;
358
359struct image_resource_directory_string {
360	uint16_t		irds_len;
361	char			irds_name[1];
362};
363
364typedef struct image_resource_directory_string image_resource_directory_string;
365
366struct image_resource_directory_string_u {
367	uint16_t		irds_len;
368	char			irds_name[1];
369};
370
371typedef struct image_resource_directory_string_u
372	image_resource_directory_string_u;
373
374struct image_resource_data_entry {
375	uint32_t		irde_offset;
376	uint32_t		irde_size;
377	uint32_t		irde_codepage;
378	uint32_t		irde_rsvd;
379};
380
381typedef struct image_resource_data_entry image_resource_data_entry;
382
383struct message_resource_data {
384	uint32_t		mrd_numblocks;
385#ifdef notdef
386	message_resource_block	mrd_blocks[1];
387#endif
388};
389
390typedef struct message_resource_data message_resource_data;
391
392struct message_resource_block {
393	uint32_t		mrb_lowid;
394	uint32_t		mrb_highid;
395	uint32_t		mrb_entryoff;
396};
397
398typedef struct message_resource_block message_resource_block;
399
400struct message_resource_entry {
401	uint16_t		mre_len;
402	uint16_t		mre_flags;
403	char			mre_text[];
404};
405
406typedef struct message_resource_entry message_resource_entry;
407
408#define MESSAGE_RESOURCE_UNICODE	0x0001
409
410struct image_patch_table {
411	const char		*ipt_name;
412	void			(*ipt_func)(void);
413	void			(*ipt_wrap)(void);
414};
415
416typedef struct image_patch_table image_patch_table;
417
418/*
419 * Note: Windows uses the _stdcall calling convention. This means
420 * that the callback functions provided in the function table must
421 * be declared using __attribute__((__stdcall__)), otherwise the
422 * Windows code will likely screw up the %esp register and cause
423 * us to jump to an invalid address when it returns.
424 */
425
426#ifdef __amd64__
427#define	__stdcall
428#define __regcall
429#define __fastcall
430#define REGARGS1(decl1)		decl1
431#define REGARGS2(decl1, decl2)	decl1, decl2
432#define REGCALL1(arg1)		arg1
433#define REGCALL2(arg1, arg2)	arg1, arg2
434#else
435#define	__stdcall __attribute__((__stdcall__))
436#define __regcall __attribute__((__regparm__(3)))
437#define __fastcall __stdcall __regcall
438#define REGARGS1(decl1)		int dummy1, int dummy2, decl1
439#define REGARGS2(decl1, decl2)	int dummy1, decl2, decl1
440#define REGCALL1(arg1)		0, 0, arg1
441#define REGCALL2(arg1, arg2)	0, arg2, arg1
442#endif
443
444
445/*
446 * This mess allows us to call a _fastcall style routine with our
447 * version of gcc, which lacks __attribute__((__fastcall__)). Only
448 * has meaning on x86; everywhere else, it's a no-op.
449 */
450
451#ifdef __i386__
452typedef __fastcall int (*fcall1)(REGARGS1(uint32_t));
453typedef __fastcall int (*fcall2)(REGARGS2(uint32_t, uint32_t));
454typedef __fastcall int (*fcall3)(REGARGS2(uint32_t, uint32_t), uint32_t);
455
456static __inline uint32_t
457fastcall1(fcall1 f, uint32_t a)
458{
459	return(f(REGCALL1(a)));
460}
461
462static __inline uint32_t
463fastcall2(fcall2 f, uint32_t a, uint32_t b)
464{
465	return(f(REGCALL2(a, b)));
466}
467
468static __inline uint32_t
469fastcall3(fcall3 f, uint32_t a, uint32_t b, uint32_t c)
470{
471	return(f(REGCALL2(a, b), c));
472}
473
474#define FASTCALL1(f, a)		\
475	fastcall1((fcall1)(f), (uint32_t)(a))
476#define FASTCALL2(f, a, b)	\
477	fastcall2((fcall2)(f), (uint32_t)(a), (uint32_t)(b))
478#define FASTCALL3(f, a, b, c)	\
479	fastcall3((fcall3)(f), (uint32_t)(a), (uint32_t)(b), (uint32_t)(c))
480#else
481#define FASTCALL1(f, a) (f)((a))
482#define FASTCALL2(f, a, b) (f)((a), (b))
483#define FASTCALL3(f, a, b, c) (f)((a), (b), (c))
484#endif /* __i386__ */
485
486
487/*
488 * AMD64 support. Microsoft uses a different calling convention
489 * than everyone else on the amd64 platform. Sadly, gcc has no
490 * built-in support for it (yet).
491 *
492 * The three major differences we're concerned with are:
493 *
494 * - The first 4 register-sized arguments are passed in the
495 *   %rcx, %rdx, %r8 and %r9 registers, and the rest are pushed
496 *   onto the stack. (The ELF ABI uses 6 registers, not 4).
497 *
498 * - The caller must reserve space on the stack for the 4
499 *   register arguments in case the callee has to spill them.
500 *
501 * - The stack myst be 16-byte aligned by the time the callee
502 *   executes. A call instruction implicitly pushes an 8 byte
503 *   return address onto the stack. We have to make sure that
504 *   the amount of space we consume, plus the return address,
505 *   is a multiple of 16 bytes in size. This means that in
506 *   some cases, we may need to chew up an extra 8 bytes on
507 *   the stack that will be unused.
508 *
509 * On the bright side, Microsoft seems to be using just the one
510 * calling convention for all functions on amd64, unlike x86 where
511 * they use a mix of _stdcall, _fastcall and _cdecl.
512 */
513
514#ifdef __amd64__
515
516extern uint64_t x86_64_call1(void *, uint64_t);
517extern uint64_t x86_64_call2(void *, uint64_t, uint64_t);
518extern uint64_t x86_64_call3(void *, uint64_t, uint64_t, uint64_t);
519extern uint64_t x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t);
520extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t,
521	uint64_t);
522extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
523	uint64_t, uint64_t);
524
525
526#define MSCALL1(fn, a)						\
527	x86_64_call1((fn), (uint64_t)(a))
528#define MSCALL2(fn, a, b)					\
529	x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b))
530#define MSCALL3(fn, a, b, c)					\
531	x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b),		\
532	(uint64_t)(c))
533#define MSCALL4(fn, a, b, c, d)					\
534	x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b),		\
535	(uint64_t)(c), (uint64_t)(d))
536#define MSCALL5(fn, a, b, c, d, e)				\
537	x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b),		\
538	(uint64_t)(c), (uint64_t)(d), (uint64_t)(e))
539#define MSCALL6(fn, a, b, c, d, e, f)				\
540	x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b),		\
541	(uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f))
542
543#else /* __amd64__ */
544
545#define MSCALL1(fn, a)			(fn)((a))
546#define MSCALL2(fn, a, b)		(fn)((a), (b))
547#define MSCALL3(fn, a, b, c)		(fn)((a), (b), (c))
548#define MSCALL4(fn, a, b, c, d)		(fn)((a), (b), (c), (d))
549#define MSCALL5(fn, a, b, c, d, e)	(fn)((a), (b), (c), (d), (e))
550#define MSCALL6(fn, a, b, c, d, e, f)	(fn)((a), (b), (c), (d), (e), (f))
551
552#endif /* __amd64__ */
553
554
555#define FUNC void(*)(void)
556#define IMPORT_FUNC(x)		{ #x, (FUNC)x, NULL }
557#define IMPORT_FUNC_MAP(x, y)	{ #x, (FUNC)y, NULL }
558
559__BEGIN_DECLS
560extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
561extern int pe_is_nt_image(vm_offset_t);
562extern int pe_get_optional_header(vm_offset_t, image_optional_header *);
563extern int pe_get_file_header(vm_offset_t, image_file_header *);
564extern int pe_get_section_header(vm_offset_t, image_section_header *);
565extern int pe_numsections(vm_offset_t);
566extern vm_offset_t pe_imagebase(vm_offset_t);
567extern vm_offset_t pe_directory_offset(vm_offset_t, uint32_t);
568extern vm_offset_t pe_translate_addr (vm_offset_t, vm_offset_t);
569extern int pe_get_section(vm_offset_t, image_section_header *, const char *);
570extern int pe_relocate(vm_offset_t);
571extern int pe_get_import_descriptor(vm_offset_t, image_import_descriptor *, const char *);
572extern int pe_patch_imports(vm_offset_t, const char *, image_patch_table *);
573extern int pe_get_messagetable(vm_offset_t, message_resource_data **);
574extern int pe_get_message(vm_offset_t, uint32_t, char **, int *, uint16_t *);
575__END_DECLS
576
577#endif /* _PE_VAR_H_ */
578