The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/ndis/pe_var.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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  * $FreeBSD$
   35  */
   36 
   37 #ifndef _PE_VAR_H_
   38 #define _PE_VAR_H_
   39 
   40 /*
   41  *  Image Format
   42  */
   43 
   44 #define IMAGE_DOS_SIGNATURE                     0x5A4D      /* MZ */
   45 #define IMAGE_OS2_SIGNATURE                     0x454E      /* NE */
   46 #define IMAGE_OS2_SIGNATURE_LE                  0x454C      /* LE */
   47 #define IMAGE_VXD_SIGNATURE                     0x454C      /* LE */
   48 #define IMAGE_NT_SIGNATURE                      0x00004550  /* PE00 */
   49 
   50 /*
   51  * All PE files have one of these, just so if you attempt to
   52  * run them, they'll print out a message telling you they can
   53  * only be run in Windows.
   54  */
   55 
   56 struct image_dos_header {
   57         uint16_t        idh_magic;      /* Magic number */
   58         uint16_t        idh_cblp;       /* Bytes on last page of file */
   59         uint16_t        idh_cp;         /* Pages in file */
   60         uint16_t        idh_crlc;       /* Relocations */
   61         uint16_t        idh_cparhdr;    /* Size of header in paragraphs */
   62         uint16_t        idh_minalloc;   /* Minimum extra paragraphs needed */
   63         uint16_t        idh_maxalloc;   /* Maximum extra paragraphs needed */
   64         uint16_t        idh_ss;         /* Initial (relative) SS value */
   65         uint16_t        idh_sp;         /* Initial SP value */
   66         uint16_t        idh_csum;       /* Checksum */
   67         uint16_t        idh_ip;         /* Initial IP value */
   68         uint16_t        idh_cs;         /* Initial (relative) CS value */
   69         uint16_t        idh_lfarlc;     /* File address of relocation table */
   70         uint16_t        idh_ovno;       /* Overlay number */
   71         uint16_t        idh_rsvd1[4];   /* Reserved words */
   72         uint16_t        idh_oemid;      /* OEM identifier (for idh_oeminfo) */
   73         uint16_t        idh_oeminfo;    /* OEM information; oemid specific */
   74         uint16_t        idh_rsvd2[10];  /* Reserved words */
   75         uint32_t        idh_lfanew;     /* File address of new exe header */
   76 };
   77 
   78 typedef struct image_dos_header image_dos_header;
   79 
   80 /*
   81  * File header format.
   82  */
   83 
   84 struct image_file_header {
   85         uint16_t        ifh_machine;            /* Machine type */
   86         uint16_t        ifh_numsections;        /* # of sections */
   87         uint32_t        ifh_timestamp;          /* Date/time stamp */
   88         uint32_t        ifh_symtblptr;          /* Offset to symbol table */
   89         uint32_t        ifh_numsyms;            /* # of symbols */
   90         uint16_t        ifh_optionalhdrlen;     /* Size of optional header */
   91         uint16_t        ifh_characteristics;    /* Characteristics */
   92 };
   93 
   94 typedef struct image_file_header image_file_header;
   95 
   96 /* Machine types */
   97 
   98 #define IMAGE_FILE_MACHINE_UNKNOWN      0
   99 #define IMAGE_FILE_MACHINE_I860         0x014d
  100 #define IMAGE_FILE_MACHINE_I386         0x014c
  101 #define IMAGE_FILE_MACHINE_R3000        0x0162
  102 #define IMAGE_FILE_MACHINE_R4000        0x0166
  103 #define IMAGE_FILE_MACHINE_R10000       0x0168
  104 #define IMAGE_FILE_MACHINE_WCEMIPSV2    0x0169
  105 #define IMAGE_FILE_MACHINE_ALPHA        0x0184
  106 #define IMAGE_FILE_MACHINE_SH3          0x01a2
  107 #define IMAGE_FILE_MACHINE_SH3DSP       0x01a3
  108 #define IMAGE_FILE_MACHINE_SH3E         0x01a4
  109 #define IMAGE_FILE_MACHINE_SH4          0x01a6
  110 #define IMAGE_FILE_MACHINE_SH5          0x01a8
  111 #define IMAGE_FILE_MACHINE_ARM          0x01c0
  112 #define IMAGE_FILE_MACHINE_THUMB        0x01c2
  113 #define IMAGE_FILE_MACHINE_AM33         0x01d3
  114 #define IMAGE_FILE_MACHINE_POWERPC      0x01f0
  115 #define IMAGE_FILE_MACHINE_POWERPCFP    0x01f1
  116 #define IMAGE_FILE_MACHINE_MIPS16       0x0266
  117 #define IMAGE_FILE_MACHINE_ALPHA64      0x0284
  118 #define IMAGE_FILE_MACHINE_MIPSFPU      0x0366
  119 #define IMAGE_FILE_MACHINE_MIPSFPU16    0x0466
  120 #define IMAGE_FILE_MACHINE_AXP64        IMAGE_FILE_MACHINE_ALPHA64
  121 #define IMAGE_FILE_MACHINE_TRICORE      0x0520
  122 #define IMAGE_FILE_MACHINE_CEF          0x0cef
  123 #define IMAGE_FILE_MACHINE_EBC          0x0ebc
  124 #define IMAGE_FILE_MACHINE_AMD64        0x8664
  125 #define IMAGE_FILE_MACHINE_M32R         0x9041
  126 #define IMAGE_FILE_MACHINE_CEE          0xc0ee
  127 
  128 /* Characteristics */
  129 
  130 #define IMAGE_FILE_RELOCS_STRIPPED      0x0001 /* No relocation info */
  131 #define IMAGE_FILE_EXECUTABLE_IMAGE     0x0002
  132 #define IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004
  133 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008
  134 #define IMAGE_FILE_AGGRESIVE_WS_TRIM    0x0010
  135 #define IMAGE_FILE_LARGE_ADDRESS_AWARE  0x0020
  136 #define IMAGE_FILE_16BIT_MACHINE        0x0040
  137 #define IMAGE_FILE_BYTES_REVERSED_LO    0x0080
  138 #define IMAGE_FILE_32BIT_MACHINE        0x0100
  139 #define IMAGE_FILE_DEBUG_STRIPPED       0x0200
  140 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP      0x0400
  141 #define IMAGE_FILE_NET_RUN_FROM_SWAP    0x0800
  142 #define IMAGE_FILE_SYSTEM               0x1000
  143 #define IMAGE_FILE_DLL                  0x2000
  144 #define IMAGE_FILE_UP_SYSTEM_ONLY       0x4000
  145 #define IMAGE_FILE_BYTES_REVERSED_HI    0x8000
  146 
  147 #define IMAGE_SIZEOF_FILE_HEADER             20
  148 
  149 /*
  150  * Directory format.
  151  */
  152 
  153 struct image_data_directory {
  154         uint32_t                idd_vaddr;      /* virtual address */
  155         uint32_t                idd_size;       /* size */
  156 };
  157 
  158 typedef struct image_data_directory image_data_directory;
  159 
  160 #define IMAGE_DIRECTORY_ENTRIES_MAX    16
  161 
  162 /*
  163  * Optional header format.
  164  */
  165 
  166 struct image_optional_header {
  167         /* Standard fields */
  168 
  169         uint16_t        ioh_magic;
  170         uint8_t         ioh_linkerver_major;
  171         uint8_t         ioh_linkerver_minor;
  172         uint32_t        ioh_codesize;
  173         uint32_t        ioh_datasize;
  174         uint32_t        ioh_bsssize;
  175         uint32_t        ioh_entryaddr;
  176         uint32_t        ioh_codebaseaddr;
  177 #ifndef __amd64__
  178         uint32_t        ioh_databaseaddr;
  179 #endif
  180 
  181         /* NT-specific fields */
  182 
  183         uintptr_t       ioh_imagebase;
  184         uint32_t        ioh_sectalign;
  185         uint32_t        ioh_filealign;
  186         uint16_t        ioh_osver_major;
  187         uint16_t        ioh_osver_minor;
  188         uint16_t        ioh_imagever_major;
  189         uint16_t        ioh_imagever_minor;
  190         uint16_t        ioh_subsys_major;
  191         uint16_t        ioh_subsys_minor;
  192         uint32_t        ioh_win32ver;
  193         uint32_t        ioh_imagesize;
  194         uint32_t        ioh_headersize;
  195         uint32_t        ioh_csum;
  196         uint16_t        ioh_subsys;
  197         uint16_t        ioh_dll_characteristics;
  198         uintptr_t       ioh_stackreservesize;
  199         uintptr_t       ioh_stackcommitsize;
  200         uintptr_t       ioh_heapreservesize;
  201         uintptr_t       ioh_heapcommitsize;
  202         uint16_t        ioh_loaderflags;
  203         uint32_t        ioh_rva_size_cnt;
  204         image_data_directory    ioh_datadir[IMAGE_DIRECTORY_ENTRIES_MAX];
  205 };
  206 
  207 typedef struct image_optional_header image_optional_header;
  208 
  209 struct image_nt_header {
  210         uint32_t                inh_signature;
  211         image_file_header       inh_filehdr;
  212         image_optional_header   inh_optionalhdr;
  213 };
  214 
  215 typedef 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
  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 
  268 struct 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 
  284 typedef struct image_section_header image_section_header;
  285 
  286 #define IMAGE_SIZEOF_SECTION_HEADER          40
  287 
  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 
  297 struct 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)
  304 
  305 struct 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 
  313 typedef struct image_import_descriptor image_import_descriptor;
  314 
  315 struct image_base_reloc {
  316         uint32_t        ibr_vaddr;
  317         uint32_t        ibr_blocksize;
  318         uint16_t        ibr_rel[1];
  319 };
  320 
  321 typedef struct image_base_reloc image_base_reloc;
  322 
  323 #define IMR_RELTYPE(x)          ((x >> 12) & 0xF)
  324 #define IMR_RELOFFSET(x)        (x & 0xFFF)
  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_DIR64                   10
  337 #define IMAGE_REL_BASED_HIGH3ADJ                11
  338 
  339 struct image_resource_directory_entry {
  340         uint32_t                irde_name;
  341         uint32_t                irde_dataoff;
  342 };
  343 
  344 typedef struct image_resource_directory_entry image_resource_directory_entry;
  345 
  346 #define RESOURCE_NAME_STR       0x80000000
  347 #define RESOURCE_DIR_FLAG       0x80000000
  348 
  349 struct image_resource_directory {
  350         uint32_t                ird_characteristics;
  351         uint32_t                ird_timestamp;
  352         uint16_t                ird_majorver;
  353         uint16_t                ird_minorver;
  354         uint16_t                ird_named_entries;
  355         uint16_t                ird_id_entries;
  356 #ifdef notdef
  357         image_resource_directory_entry  ird_entries[1];
  358 #endif
  359 };
  360 
  361 typedef struct image_resource_directory image_resource_directory;
  362 
  363 struct image_resource_directory_string {
  364         uint16_t                irds_len;
  365         char                    irds_name[1];
  366 };
  367 
  368 typedef struct image_resource_directory_string image_resource_directory_string;
  369 
  370 struct image_resource_directory_string_u {
  371         uint16_t                irds_len;
  372         char                    irds_name[1];
  373 };
  374 
  375 typedef struct image_resource_directory_string_u
  376         image_resource_directory_string_u;
  377 
  378 struct image_resource_data_entry {
  379         uint32_t                irde_offset;
  380         uint32_t                irde_size;
  381         uint32_t                irde_codepage;
  382         uint32_t                irde_rsvd;
  383 };
  384 
  385 typedef struct image_resource_data_entry image_resource_data_entry;
  386 
  387 struct message_resource_data {
  388         uint32_t                mrd_numblocks;
  389 #ifdef notdef
  390         message_resource_block  mrd_blocks[1];
  391 #endif
  392 };
  393 
  394 typedef struct message_resource_data message_resource_data;
  395 
  396 struct message_resource_block {
  397         uint32_t                mrb_lowid;
  398         uint32_t                mrb_highid;
  399         uint32_t                mrb_entryoff;
  400 };
  401 
  402 typedef struct message_resource_block message_resource_block;
  403 
  404 struct message_resource_entry {
  405         uint16_t                mre_len;
  406         uint16_t                mre_flags;
  407         char                    mre_text[];
  408 };
  409 
  410 typedef struct message_resource_entry message_resource_entry;
  411 
  412 #define MESSAGE_RESOURCE_UNICODE        0x0001
  413 
  414 struct image_patch_table {
  415         char            *ipt_name;
  416         void            (*ipt_func)(void);
  417         void            (*ipt_wrap)(void);
  418         int             ipt_argcnt;
  419         int             ipt_ftype;
  420 };
  421 
  422 typedef struct image_patch_table image_patch_table;
  423 
  424 /*
  425  * AMD64 support. Microsoft uses a different calling convention
  426  * than everyone else on the amd64 platform. Sadly, gcc has no
  427  * built-in support for it (yet).
  428  *
  429  * The three major differences we're concerned with are:
  430  *
  431  * - The first 4 register-sized arguments are passed in the
  432  *   %rcx, %rdx, %r8 and %r9 registers, and the rest are pushed
  433  *   onto the stack. (The ELF ABI uses 6 registers, not 4).
  434  *
  435  * - The caller must reserve space on the stack for the 4
  436  *   register arguments in case the callee has to spill them.
  437  *
  438  * - The stack myst be 16-byte aligned by the time the callee
  439  *   executes. A call instruction implicitly pushes an 8 byte
  440  *   return address onto the stack. We have to make sure that
  441  *   the amount of space we consume, plus the return address,
  442  *   is a multiple of 16 bytes in size. This means that in
  443  *   some cases, we may need to chew up an extra 8 bytes on
  444  *   the stack that will be unused.
  445  *
  446  * On the bright side, Microsoft seems to be using just the one
  447  * calling convention for all functions on amd64, unlike x86 where
  448  * they use a mix of _stdcall, _fastcall and _cdecl.
  449  */
  450 
  451 #ifdef __amd64__
  452 
  453 extern uint64_t x86_64_call1(void *, uint64_t);
  454 extern uint64_t x86_64_call2(void *, uint64_t, uint64_t);
  455 extern uint64_t x86_64_call3(void *, uint64_t, uint64_t, uint64_t);
  456 extern uint64_t x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t);
  457 extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t,
  458         uint64_t);
  459 extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
  460         uint64_t, uint64_t);
  461 
  462 uint64_t _x86_64_call1(void *, uint64_t);
  463 uint64_t _x86_64_call2(void *, uint64_t, uint64_t);
  464 uint64_t _x86_64_call3(void *, uint64_t, uint64_t, uint64_t);
  465 uint64_t _x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t);
  466 uint64_t _x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t,
  467     uint64_t);
  468 uint64_t _x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
  469     uint64_t, uint64_t);
  470 
  471 #define MSCALL1(fn, a)                                          \
  472         _x86_64_call1((fn), (uint64_t)(a))
  473 #define MSCALL2(fn, a, b)                                       \
  474         _x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b))
  475 #define MSCALL3(fn, a, b, c)                                    \
  476         _x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b),               \
  477         (uint64_t)(c))
  478 #define MSCALL4(fn, a, b, c, d)                                 \
  479         _x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b),               \
  480         (uint64_t)(c), (uint64_t)(d))
  481 #define MSCALL5(fn, a, b, c, d, e)                              \
  482         _x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b),               \
  483         (uint64_t)(c), (uint64_t)(d), (uint64_t)(e))
  484 #define MSCALL6(fn, a, b, c, d, e, f)                           \
  485         _x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b),               \
  486         (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f))
  487 
  488 #endif /* __amd64__ */
  489 
  490 #ifdef __i386__
  491 
  492 extern uint32_t x86_stdcall_call(void *, int, ...);
  493 
  494 #define MSCALL1(fn, a)          x86_stdcall_call(fn, 1, (a))
  495 #define MSCALL2(fn, a, b)       x86_stdcall_call(fn, 2, (a), (b))
  496 #define MSCALL3(fn, a, b, c)    x86_stdcall_call(fn, 3, (a), (b), (c))
  497 #define MSCALL4(fn, a, b, c, d) x86_stdcall_call(fn, 4, (a), (b), (c), (d))
  498 #define MSCALL5(fn, a, b, c, d, e)      \
  499                 x86_stdcall_call(fn, 5, (a), (b), (c), (d), (e))
  500 #define MSCALL6(fn, a, b, c, d, e, f)   \
  501                 x86_stdcall_call(fn, 6, (a), (b), (c), (d), (e), (f))
  502 
  503 #endif /* __i386__ */
  504 
  505 #define FUNC void(*)(void)
  506 
  507 #ifdef __i386__
  508 #define IMPORT_SFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_STDCALL }
  509 #define IMPORT_SFUNC_MAP(x, y, z)       \
  510                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_STDCALL }
  511 #define IMPORT_FFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_FASTCALL }
  512 #define IMPORT_FFUNC_MAP(x, y, z)       \
  513                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_FASTCALL }
  514 #define IMPORT_RFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_REGPARM }
  515 #define IMPORT_RFUNC_MAP(x, y, z)       \
  516                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_REGPARM }
  517 #define IMPORT_CFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_CDECL }
  518 #define IMPORT_CFUNC_MAP(x, y, z)       \
  519                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_CDECL }
  520 #endif /* __i386__ */
  521 
  522 #ifdef __amd64__
  523 #define IMPORT_SFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
  524 #define IMPORT_SFUNC_MAP(x, y, z)       \
  525                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
  526 #define IMPORT_FFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
  527 #define IMPORT_FFUNC_MAP(x, y, z)       \
  528                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
  529 #define IMPORT_RFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
  530 #define IMPORT_RFUNC_MAP(x, y, z)       \
  531                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
  532 #define IMPORT_CFUNC(x, y)      { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
  533 #define IMPORT_CFUNC_MAP(x, y, z)       \
  534                                 { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
  535 #endif /* __amd64__ */
  536 
  537 __BEGIN_DECLS
  538 extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
  539 extern int pe_is_nt_image(vm_offset_t);
  540 extern int pe_get_optional_header(vm_offset_t, image_optional_header *);
  541 extern int pe_get_file_header(vm_offset_t, image_file_header *);
  542 extern int pe_get_section_header(vm_offset_t, image_section_header *);
  543 extern int pe_numsections(vm_offset_t);
  544 extern vm_offset_t pe_imagebase(vm_offset_t);
  545 extern vm_offset_t pe_directory_offset(vm_offset_t, uint32_t);
  546 extern vm_offset_t pe_translate_addr (vm_offset_t, vm_offset_t);
  547 extern int pe_get_section(vm_offset_t, image_section_header *, const char *);
  548 extern int pe_relocate(vm_offset_t);
  549 extern int pe_get_import_descriptor(vm_offset_t, image_import_descriptor *, char *);
  550 extern int pe_patch_imports(vm_offset_t, char *, image_patch_table *);
  551 extern int pe_get_messagetable(vm_offset_t, message_resource_data **);
  552 extern int pe_get_message(vm_offset_t, uint32_t, char **, int *, uint16_t *);
  553 __END_DECLS
  554 
  555 #endif /* _PE_VAR_H_ */

Cache object: f5298efa4e15baa2a5fe22fdb4779def


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.