1 /*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 2003 5 * Bill Paul <wpaul@windriver.com>. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Bill Paul. 18 * 4. Neither the name of the author nor the names of any co-contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef _PE_VAR_H_ 36 #define _PE_VAR_H_ 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 */ 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 54 struct image_dos_header { 55 uint16_t idh_magic; /* Magic number */ 56 uint16_t idh_cblp; /* Bytes on last page of file */ 57 uint16_t idh_cp; /* Pages in file */ 58 uint16_t idh_crlc; /* Relocations */ 59 uint16_t idh_cparhdr; /* Size of header in paragraphs */ 60 uint16_t idh_minalloc; /* Minimum extra paragraphs needed */ 61 uint16_t idh_maxalloc; /* Maximum extra paragraphs needed */ 62 uint16_t idh_ss; /* Initial (relative) SS value */ 63 uint16_t idh_sp; /* Initial SP value */ 64 uint16_t idh_csum; /* Checksum */ 65 uint16_t idh_ip; /* Initial IP value */ 66 uint16_t idh_cs; /* Initial (relative) CS value */ 67 uint16_t idh_lfarlc; /* File address of relocation table */ 68 uint16_t idh_ovno; /* Overlay number */ 69 uint16_t idh_rsvd1[4]; /* Reserved words */ 70 uint16_t idh_oemid; /* OEM identifier (for idh_oeminfo) */ 71 uint16_t idh_oeminfo; /* OEM information; oemid specific */ 72 uint16_t idh_rsvd2[10]; /* Reserved words */ 73 uint32_t idh_lfanew; /* File address of new exe header */ 74 }; 75 76 typedef struct image_dos_header image_dos_header; 77 78 /* 79 * File header format. 80 */ 81 82 struct 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 */ 88 uint16_t ifh_optionalhdrlen; /* Size of optional header */ 89 uint16_t ifh_characteristics; /* Characteristics */ 90 }; 91 92 typedef 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_MIPS16 0x0266 115 #define IMAGE_FILE_MACHINE_ALPHA64 0x0284 116 #define IMAGE_FILE_MACHINE_MIPSFPU 0x0366 117 #define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466 118 #define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64 119 #define IMAGE_FILE_MACHINE_TRICORE 0x0520 120 #define IMAGE_FILE_MACHINE_CEF 0x0cef 121 #define IMAGE_FILE_MACHINE_EBC 0x0ebc 122 #define IMAGE_FILE_MACHINE_AMD64 0x8664 123 #define IMAGE_FILE_MACHINE_M32R 0x9041 124 #define IMAGE_FILE_MACHINE_CEE 0xc0ee 125 126 /* Characteristics */ 127 128 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */ 129 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 130 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 131 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 132 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010 133 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 134 #define IMAGE_FILE_16BIT_MACHINE 0x0040 135 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 136 #define IMAGE_FILE_32BIT_MACHINE 0x0100 137 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200 138 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 139 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 140 #define IMAGE_FILE_SYSTEM 0x1000 141 #define IMAGE_FILE_DLL 0x2000 142 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 143 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 144 145 #define IMAGE_SIZEOF_FILE_HEADER 20 146 147 /* 148 * Directory format. 149 */ 150 151 struct image_data_directory { 152 uint32_t idd_vaddr; /* virtual address */ 153 uint32_t idd_size; /* size */ 154 }; 155 156 typedef struct image_data_directory image_data_directory; 157 158 #define IMAGE_DIRECTORY_ENTRIES_MAX 16 159 160 /* 161 * Optional header format. 162 */ 163 164 struct image_optional_header { 165 /* Standard fields */ 166 167 uint16_t ioh_magic; 168 uint8_t ioh_linkerver_major; 169 uint8_t ioh_linkerver_minor; 170 uint32_t ioh_codesize; 171 uint32_t ioh_datasize; 172 uint32_t ioh_bsssize; 173 uint32_t ioh_entryaddr; 174 uint32_t ioh_codebaseaddr; 175 #ifndef __amd64__ 176 uint32_t ioh_databaseaddr; 177 #endif 178 179 /* NT-specific fields */ 180 181 uintptr_t ioh_imagebase; 182 uint32_t ioh_sectalign; 183 uint32_t ioh_filealign; 184 uint16_t ioh_osver_major; 185 uint16_t ioh_osver_minor; 186 uint16_t ioh_imagever_major; 187 uint16_t ioh_imagever_minor; 188 uint16_t ioh_subsys_major; 189 uint16_t ioh_subsys_minor; 190 uint32_t ioh_win32ver; 191 uint32_t ioh_imagesize; 192 uint32_t ioh_headersize; 193 uint32_t ioh_csum; 194 uint16_t ioh_subsys; 195 uint16_t ioh_dll_characteristics; 196 uintptr_t ioh_stackreservesize; 197 uintptr_t ioh_stackcommitsize; 198 uintptr_t ioh_heapreservesize; 199 uintptr_t ioh_heapcommitsize; 200 uint16_t ioh_loaderflags; 201 uint32_t ioh_rva_size_cnt; 202 image_data_directory ioh_datadir[IMAGE_DIRECTORY_ENTRIES_MAX]; 203 }; 204 205 typedef struct image_optional_header image_optional_header; 206 207 struct image_nt_header { 208 uint32_t inh_signature; 209 image_file_header inh_filehdr; 210 image_optional_header inh_optionalhdr; 211 }; 212 213 typedef struct image_nt_header image_nt_header; 214 215 #define IMAGE_SIZEOF_NT_HEADER(nthdr) \ 216 (offsetof(image_nt_header, inh_optionalhdr) + \ 217 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen) 218 219 /* Directory Entries */ 220 221 #define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */ 222 #define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */ 223 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */ 224 #define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */ 225 #define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */ 226 #define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */ 227 #define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */ 228 #define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 /* Description String */ 229 #define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* Machine Value (MIPS GP) */ 230 #define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */ 231 #define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */ 232 #define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */ 233 #define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */ 234 #define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 235 #define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 236 237 /* Resource types */ 238 239 #define RT_CURSOR 1 240 #define RT_BITMAP 2 241 #define RT_ICON 3 242 #define RT_MENU 4 243 #define RT_DIALOG 5 244 #define RT_STRING 6 245 #define RT_FONTDIR 7 246 #define RT_FONT 8 247 #define RT_ACCELERATOR 9 248 #define RT_RCDATA 10 249 #define RT_MESSAGETABLE 11 250 #define RT_GROUP_CURSOR 12 251 #define RT_GROUP_ICON 14 252 #define RT_VERSION 16 253 #define RT_DLGINCLUDE 17 254 #define RT_PLUGPLAY 19 255 #define RT_VXD 20 256 #define RT_ANICURSOR 21 257 #define RT_ANIICON 22 258 #define RT_HTML 23 259 260 /* 261 * Section header format. 262 */ 263 264 #define IMAGE_SHORT_NAME_LEN 8 265 266 struct image_section_header { 267 uint8_t ish_name[IMAGE_SHORT_NAME_LEN]; 268 union { 269 uint32_t ish_paddr; 270 uint32_t ish_vsize; 271 } ish_misc; 272 uint32_t ish_vaddr; 273 uint32_t ish_rawdatasize; 274 uint32_t ish_rawdataaddr; 275 uint32_t ish_relocaddr; 276 uint32_t ish_linenumaddr; 277 uint16_t ish_numrelocs; 278 uint16_t ish_numlinenums; 279 uint32_t ish_characteristics; 280 }; 281 282 typedef struct image_section_header image_section_header; 283 284 #define IMAGE_SIZEOF_SECTION_HEADER 40 285 286 #define IMAGE_FIRST_SECTION(nthdr) \ 287 ((image_section_header *)((vm_offset_t)(nthdr) + \ 288 offsetof(image_nt_header, inh_optionalhdr) + \ 289 ((image_nt_header *)(nthdr))->inh_filehdr.ifh_optionalhdrlen)) 290 291 /* 292 * Import format 293 */ 294 295 struct image_import_by_name { 296 uint16_t iibn_hint; 297 uint8_t iibn_name[1]; 298 }; 299 300 #define IMAGE_ORDINAL_FLAG 0x80000000 301 #define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) 302 303 struct image_import_descriptor { 304 uint32_t iid_import_name_table_addr; 305 uint32_t iid_timestamp; 306 uint32_t iid_forwardchain; 307 uint32_t iid_nameaddr; 308 uint32_t iid_import_address_table_addr; 309 }; 310 311 typedef struct image_import_descriptor image_import_descriptor; 312 313 struct image_base_reloc { 314 uint32_t ibr_vaddr; 315 uint32_t ibr_blocksize; 316 uint16_t ibr_rel[1]; 317 }; 318 319 typedef struct image_base_reloc image_base_reloc; 320 321 #define IMR_RELTYPE(x) ((x >> 12) & 0xF) 322 #define IMR_RELOFFSET(x) (x & 0xFFF) 323 324 /* generic relocation types */ 325 #define IMAGE_REL_BASED_ABSOLUTE 0 326 #define IMAGE_REL_BASED_HIGH 1 327 #define IMAGE_REL_BASED_LOW 2 328 #define IMAGE_REL_BASED_HIGHLOW 3 329 #define IMAGE_REL_BASED_HIGHADJ 4 330 #define IMAGE_REL_BASED_MIPS_JMPADDR 5 331 #define IMAGE_REL_BASED_SECTION 6 332 #define IMAGE_REL_BASED_REL 7 333 #define IMAGE_REL_BASED_MIPS_JMPADDR16 9 334 #define IMAGE_REL_BASED_DIR64 10 335 #define IMAGE_REL_BASED_HIGH3ADJ 11 336 337 struct image_resource_directory_entry { 338 uint32_t irde_name; 339 uint32_t irde_dataoff; 340 }; 341 342 typedef struct image_resource_directory_entry image_resource_directory_entry; 343 344 #define RESOURCE_NAME_STR 0x80000000 345 #define RESOURCE_DIR_FLAG 0x80000000 346 347 struct image_resource_directory { 348 uint32_t ird_characteristics; 349 uint32_t ird_timestamp; 350 uint16_t ird_majorver; 351 uint16_t ird_minorver; 352 uint16_t ird_named_entries; 353 uint16_t ird_id_entries; 354 #ifdef notdef 355 image_resource_directory_entry ird_entries[1]; 356 #endif 357 }; 358 359 typedef struct image_resource_directory image_resource_directory; 360 361 struct image_resource_directory_string { 362 uint16_t irds_len; 363 char irds_name[1]; 364 }; 365 366 typedef struct image_resource_directory_string image_resource_directory_string; 367 368 struct image_resource_directory_string_u { 369 uint16_t irds_len; 370 char irds_name[1]; 371 }; 372 373 typedef struct image_resource_directory_string_u 374 image_resource_directory_string_u; 375 376 struct image_resource_data_entry { 377 uint32_t irde_offset; 378 uint32_t irde_size; 379 uint32_t irde_codepage; 380 uint32_t irde_rsvd; 381 }; 382 383 typedef struct image_resource_data_entry image_resource_data_entry; 384 385 struct message_resource_data { 386 uint32_t mrd_numblocks; 387 #ifdef notdef 388 message_resource_block mrd_blocks[1]; 389 #endif 390 }; 391 392 typedef struct message_resource_data message_resource_data; 393 394 struct message_resource_block { 395 uint32_t mrb_lowid; 396 uint32_t mrb_highid; 397 uint32_t mrb_entryoff; 398 }; 399 400 typedef struct message_resource_block message_resource_block; 401 402 struct message_resource_entry { 403 uint16_t mre_len; 404 uint16_t mre_flags; 405 char mre_text[]; 406 }; 407 408 typedef struct message_resource_entry message_resource_entry; 409 410 #define MESSAGE_RESOURCE_UNICODE 0x0001 411 412 struct image_patch_table { 413 char *ipt_name; 414 void (*ipt_func)(void); 415 void (*ipt_wrap)(void); 416 int ipt_argcnt; 417 int ipt_ftype; 418 }; 419 420 typedef struct image_patch_table image_patch_table; 421 422 /* 423 * AMD64 support. Microsoft uses a different calling convention 424 * than everyone else on the amd64 platform. Sadly, gcc has no 425 * built-in support for it (yet). 426 * 427 * The three major differences we're concerned with are: 428 * 429 * - The first 4 register-sized arguments are passed in the 430 * %rcx, %rdx, %r8 and %r9 registers, and the rest are pushed 431 * onto the stack. (The ELF ABI uses 6 registers, not 4). 432 * 433 * - The caller must reserve space on the stack for the 4 434 * register arguments in case the callee has to spill them. 435 * 436 * - The stack myst be 16-byte aligned by the time the callee 437 * executes. A call instruction implicitly pushes an 8 byte 438 * return address onto the stack. We have to make sure that 439 * the amount of space we consume, plus the return address, 440 * is a multiple of 16 bytes in size. This means that in 441 * some cases, we may need to chew up an extra 8 bytes on 442 * the stack that will be unused. 443 * 444 * On the bright side, Microsoft seems to be using just the one 445 * calling convention for all functions on amd64, unlike x86 where 446 * they use a mix of _stdcall, _fastcall and _cdecl. 447 */ 448 449 #ifdef __amd64__ 450 451 extern uint64_t x86_64_call1(void *, uint64_t); 452 extern uint64_t x86_64_call2(void *, uint64_t, uint64_t); 453 extern uint64_t x86_64_call3(void *, uint64_t, uint64_t, uint64_t); 454 extern uint64_t x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t); 455 extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t, 456 uint64_t); 457 extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t, 458 uint64_t, uint64_t); 459 460 uint64_t _x86_64_call1(void *, uint64_t); 461 uint64_t _x86_64_call2(void *, uint64_t, uint64_t); 462 uint64_t _x86_64_call3(void *, uint64_t, uint64_t, uint64_t); 463 uint64_t _x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t); 464 uint64_t _x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t, 465 uint64_t); 466 uint64_t _x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t, 467 uint64_t, uint64_t); 468 469 #define MSCALL1(fn, a) \ 470 _x86_64_call1((fn), (uint64_t)(a)) 471 #define MSCALL2(fn, a, b) \ 472 _x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b)) 473 #define MSCALL3(fn, a, b, c) \ 474 _x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b), \ 475 (uint64_t)(c)) 476 #define MSCALL4(fn, a, b, c, d) \ 477 _x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b), \ 478 (uint64_t)(c), (uint64_t)(d)) 479 #define MSCALL5(fn, a, b, c, d, e) \ 480 _x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b), \ 481 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e)) 482 #define MSCALL6(fn, a, b, c, d, e, f) \ 483 _x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \ 484 (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f)) 485 486 #endif /* __amd64__ */ 487 488 #ifdef __i386__ 489 490 extern uint32_t x86_stdcall_call(void *, int, ...); 491 492 #define MSCALL1(fn, a) x86_stdcall_call(fn, 1, (a)) 493 #define MSCALL2(fn, a, b) x86_stdcall_call(fn, 2, (a), (b)) 494 #define MSCALL3(fn, a, b, c) x86_stdcall_call(fn, 3, (a), (b), (c)) 495 #define MSCALL4(fn, a, b, c, d) x86_stdcall_call(fn, 4, (a), (b), (c), (d)) 496 #define MSCALL5(fn, a, b, c, d, e) \ 497 x86_stdcall_call(fn, 5, (a), (b), (c), (d), (e)) 498 #define MSCALL6(fn, a, b, c, d, e, f) \ 499 x86_stdcall_call(fn, 6, (a), (b), (c), (d), (e), (f)) 500 501 #endif /* __i386__ */ 502 503 #define FUNC void(*)(void) 504 505 #ifdef __i386__ 506 #define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_STDCALL } 507 #define IMPORT_SFUNC_MAP(x, y, z) \ 508 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_STDCALL } 509 #define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_FASTCALL } 510 #define IMPORT_FFUNC_MAP(x, y, z) \ 511 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_FASTCALL } 512 #define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_REGPARM } 513 #define IMPORT_RFUNC_MAP(x, y, z) \ 514 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_REGPARM } 515 #define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_CDECL } 516 #define IMPORT_CFUNC_MAP(x, y, z) \ 517 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_CDECL } 518 #endif /* __i386__ */ 519 520 #ifdef __amd64__ 521 #define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 } 522 #define IMPORT_SFUNC_MAP(x, y, z) \ 523 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 } 524 #define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 } 525 #define IMPORT_FFUNC_MAP(x, y, z) \ 526 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 } 527 #define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 } 528 #define IMPORT_RFUNC_MAP(x, y, z) \ 529 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 } 530 #define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 } 531 #define IMPORT_CFUNC_MAP(x, y, z) \ 532 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 } 533 #endif /* __amd64__ */ 534 535 __BEGIN_DECLS 536 extern int pe_get_dos_header(vm_offset_t, image_dos_header *); 537 extern int pe_is_nt_image(vm_offset_t); 538 extern int pe_get_optional_header(vm_offset_t, image_optional_header *); 539 extern int pe_get_file_header(vm_offset_t, image_file_header *); 540 extern int pe_get_section_header(vm_offset_t, image_section_header *); 541 extern int pe_numsections(vm_offset_t); 542 extern vm_offset_t pe_imagebase(vm_offset_t); 543 extern vm_offset_t pe_directory_offset(vm_offset_t, uint32_t); 544 extern vm_offset_t pe_translate_addr (vm_offset_t, vm_offset_t); 545 extern int pe_get_section(vm_offset_t, image_section_header *, const char *); 546 extern int pe_relocate(vm_offset_t); 547 extern int pe_get_import_descriptor(vm_offset_t, image_import_descriptor *, char *); 548 extern int pe_patch_imports(vm_offset_t, char *, image_patch_table *); 549 extern int pe_get_messagetable(vm_offset_t, message_resource_data **); 550 extern int pe_get_message(vm_offset_t, uint32_t, char **, int *, uint16_t *); 551 __END_DECLS 552 553 #endif /* _PE_VAR_H_ */ 554