#ifndef __LINUX_PE_H
#define __LINUX_PE_H
#include <linux/types.h>
#define LINUX_EFISTUB_MAJOR_VERSION …
#define LINUX_EFISTUB_MINOR_VERSION …
#define LINUX_PE_MAGIC …
#define MZ_MAGIC …
#define PE_MAGIC …
#define PE_OPT_MAGIC_PE32 …
#define PE_OPT_MAGIC_PE32_ROM …
#define PE_OPT_MAGIC_PE32PLUS …
#define IMAGE_FILE_MACHINE_UNKNOWN …
#define IMAGE_FILE_MACHINE_AM33 …
#define IMAGE_FILE_MACHINE_AMD64 …
#define IMAGE_FILE_MACHINE_ARM …
#define IMAGE_FILE_MACHINE_ARMV7 …
#define IMAGE_FILE_MACHINE_ARM64 …
#define IMAGE_FILE_MACHINE_EBC …
#define IMAGE_FILE_MACHINE_I386 …
#define IMAGE_FILE_MACHINE_IA64 …
#define IMAGE_FILE_MACHINE_M32R …
#define IMAGE_FILE_MACHINE_MIPS16 …
#define IMAGE_FILE_MACHINE_MIPSFPU …
#define IMAGE_FILE_MACHINE_MIPSFPU16 …
#define IMAGE_FILE_MACHINE_POWERPC …
#define IMAGE_FILE_MACHINE_POWERPCFP …
#define IMAGE_FILE_MACHINE_R4000 …
#define IMAGE_FILE_MACHINE_RISCV32 …
#define IMAGE_FILE_MACHINE_RISCV64 …
#define IMAGE_FILE_MACHINE_RISCV128 …
#define IMAGE_FILE_MACHINE_SH3 …
#define IMAGE_FILE_MACHINE_SH3DSP …
#define IMAGE_FILE_MACHINE_SH3E …
#define IMAGE_FILE_MACHINE_SH4 …
#define IMAGE_FILE_MACHINE_SH5 …
#define IMAGE_FILE_MACHINE_THUMB …
#define IMAGE_FILE_MACHINE_WCEMIPSV2 …
#define IMAGE_FILE_MACHINE_LOONGARCH32 …
#define IMAGE_FILE_MACHINE_LOONGARCH64 …
#define IMAGE_FILE_RELOCS_STRIPPED …
#define IMAGE_FILE_EXECUTABLE_IMAGE …
#define IMAGE_FILE_LINE_NUMS_STRIPPED …
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED …
#define IMAGE_FILE_AGGRESSIVE_WS_TRIM …
#define IMAGE_FILE_LARGE_ADDRESS_AWARE …
#define IMAGE_FILE_16BIT_MACHINE …
#define IMAGE_FILE_BYTES_REVERSED_LO …
#define IMAGE_FILE_32BIT_MACHINE …
#define IMAGE_FILE_DEBUG_STRIPPED …
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP …
#define IMAGE_FILE_NET_RUN_FROM_SWAP …
#define IMAGE_FILE_SYSTEM …
#define IMAGE_FILE_DLL …
#define IMAGE_FILE_UP_SYSTEM_ONLY …
#define IMAGE_FILE_BYTES_REVERSED_HI …
#define IMAGE_FILE_OPT_ROM_MAGIC …
#define IMAGE_FILE_OPT_PE32_MAGIC …
#define IMAGE_FILE_OPT_PE32_PLUS_MAGIC …
#define IMAGE_SUBSYSTEM_UNKNOWN …
#define IMAGE_SUBSYSTEM_NATIVE …
#define IMAGE_SUBSYSTEM_WINDOWS_GUI …
#define IMAGE_SUBSYSTEM_WINDOWS_CUI …
#define IMAGE_SUBSYSTEM_POSIX_CUI …
#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI …
#define IMAGE_SUBSYSTEM_EFI_APPLICATION …
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER …
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER …
#define IMAGE_SUBSYSTEM_EFI_ROM_IMAGE …
#define IMAGE_SUBSYSTEM_XBOX …
#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE …
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY …
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT …
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION …
#define IMAGE_DLLCHARACTERISTICS_NO_SEH …
#define IMAGE_DLLCHARACTERISTICS_NO_BIND …
#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER …
#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE …
#define IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT …
#define IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT …
#define IMAGE_SCN_RESERVED_0 …
#define IMAGE_SCN_RESERVED_1 …
#define IMAGE_SCN_RESERVED_2 …
#define IMAGE_SCN_TYPE_NO_PAD …
#define IMAGE_SCN_RESERVED_3 …
#define IMAGE_SCN_CNT_CODE …
#define IMAGE_SCN_CNT_INITIALIZED_DATA …
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA …
#define IMAGE_SCN_LNK_OTHER …
#define IMAGE_SCN_LNK_INFO …
#define IMAGE_SCN_RESERVED_4 …
#define IMAGE_SCN_LNK_REMOVE …
#define IMAGE_SCN_LNK_COMDAT …
#define IMAGE_SCN_RESERVED_5 …
#define IMAGE_SCN_RESERVED_6 …
#define IMAGE_SCN_GPREL …
#define IMAGE_SCN_MEM_PURGEABLE …
#define IMAGE_SCN_16BIT …
#define IMAGE_SCN_LOCKED …
#define IMAGE_SCN_PRELOAD …
#define IMAGE_SCN_ALIGN_1BYTES …
#define IMAGE_SCN_ALIGN_2BYTES …
#define IMAGE_SCN_ALIGN_4BYTES …
#define IMAGE_SCN_ALIGN_8BYTES …
#define IMAGE_SCN_ALIGN_16BYTES …
#define IMAGE_SCN_ALIGN_32BYTES …
#define IMAGE_SCN_ALIGN_64BYTES …
#define IMAGE_SCN_ALIGN_128BYTES …
#define IMAGE_SCN_ALIGN_256BYTES …
#define IMAGE_SCN_ALIGN_512BYTES …
#define IMAGE_SCN_ALIGN_1024BYTES …
#define IMAGE_SCN_ALIGN_2048BYTES …
#define IMAGE_SCN_ALIGN_4096BYTES …
#define IMAGE_SCN_ALIGN_8192BYTES …
#define IMAGE_SCN_LNK_NRELOC_OVFL …
#define IMAGE_SCN_MEM_DISCARDABLE …
#define IMAGE_SCN_MEM_NOT_CACHED …
#define IMAGE_SCN_MEM_NOT_PAGED …
#define IMAGE_SCN_MEM_SHARED …
#define IMAGE_SCN_MEM_EXECUTE …
#define IMAGE_SCN_MEM_READ …
#define IMAGE_SCN_MEM_WRITE …
#define IMAGE_DEBUG_TYPE_CODEVIEW …
#define IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS …
#ifndef __ASSEMBLY__
struct mz_hdr {
uint16_t magic;
uint16_t lbsize;
uint16_t blocks;
uint16_t relocs;
uint16_t hdrsize;
uint16_t min_extra_pps;
uint16_t max_extra_pps;
uint16_t ss;
uint16_t sp;
uint16_t checksum;
uint16_t ip;
uint16_t cs;
uint16_t reloc_table_offset;
uint16_t overlay_num;
uint16_t reserved0[4];
uint16_t oem_id;
uint16_t oem_info;
uint16_t reserved1[10];
uint32_t peaddr;
char message[];
};
struct mz_reloc {
uint16_t offset;
uint16_t segment;
};
struct pe_hdr {
uint32_t magic;
uint16_t machine;
uint16_t sections;
uint32_t timestamp;
uint32_t symbol_table;
uint32_t symbols;
uint16_t opt_hdr_size;
uint16_t flags;
};
struct pe32_opt_hdr {
uint16_t magic;
uint8_t ld_major;
uint8_t ld_minor;
uint32_t text_size;
uint32_t data_size;
uint32_t bss_size;
uint32_t entry_point;
uint32_t code_base;
uint32_t data_base;
uint32_t image_base;
uint32_t section_align;
uint32_t file_align;
uint16_t os_major;
uint16_t os_minor;
uint16_t image_major;
uint16_t image_minor;
uint16_t subsys_major;
uint16_t subsys_minor;
uint32_t win32_version;
uint32_t image_size;
uint32_t header_size;
uint32_t csum;
uint16_t subsys;
uint16_t dll_flags;
uint32_t stack_size_req;
uint32_t stack_size;
uint32_t heap_size_req;
uint32_t heap_size;
uint32_t loader_flags;
uint32_t data_dirs;
};
struct pe32plus_opt_hdr {
uint16_t magic;
uint8_t ld_major;
uint8_t ld_minor;
uint32_t text_size;
uint32_t data_size;
uint32_t bss_size;
uint32_t entry_point;
uint32_t code_base;
uint64_t image_base;
uint32_t section_align;
uint32_t file_align;
uint16_t os_major;
uint16_t os_minor;
uint16_t image_major;
uint16_t image_minor;
uint16_t subsys_major;
uint16_t subsys_minor;
uint32_t win32_version;
uint32_t image_size;
uint32_t header_size;
uint32_t csum;
uint16_t subsys;
uint16_t dll_flags;
uint64_t stack_size_req;
uint64_t stack_size;
uint64_t heap_size_req;
uint64_t heap_size;
uint32_t loader_flags;
uint32_t data_dirs;
};
struct data_dirent {
uint32_t virtual_address;
uint32_t size;
};
struct data_directory {
struct data_dirent exports;
struct data_dirent imports;
struct data_dirent resources;
struct data_dirent exceptions;
struct data_dirent certs;
struct data_dirent base_relocations;
struct data_dirent debug;
struct data_dirent arch;
struct data_dirent global_ptr;
struct data_dirent tls;
struct data_dirent load_config;
struct data_dirent bound_imports;
struct data_dirent import_addrs;
struct data_dirent delay_imports;
struct data_dirent clr_runtime_hdr;
struct data_dirent reserved;
};
struct section_header {
char name[8];
uint32_t virtual_size;
uint32_t virtual_address;
uint32_t raw_data_size;
uint32_t data_addr;
uint32_t relocs;
uint32_t line_numbers;
uint16_t num_relocs;
uint16_t num_lin_numbers;
uint32_t flags;
};
enum x64_coff_reloc_type {
IMAGE_REL_AMD64_ABSOLUTE = 0,
IMAGE_REL_AMD64_ADDR64,
IMAGE_REL_AMD64_ADDR32,
IMAGE_REL_AMD64_ADDR32N,
IMAGE_REL_AMD64_REL32,
IMAGE_REL_AMD64_REL32_1,
IMAGE_REL_AMD64_REL32_2,
IMAGE_REL_AMD64_REL32_3,
IMAGE_REL_AMD64_REL32_4,
IMAGE_REL_AMD64_REL32_5,
IMAGE_REL_AMD64_SECTION,
IMAGE_REL_AMD64_SECREL,
IMAGE_REL_AMD64_SECREL7,
IMAGE_REL_AMD64_TOKEN,
IMAGE_REL_AMD64_SREL32,
IMAGE_REL_AMD64_PAIR,
IMAGE_REL_AMD64_SSPAN32,
};
enum arm_coff_reloc_type {
IMAGE_REL_ARM_ABSOLUTE,
IMAGE_REL_ARM_ADDR32,
IMAGE_REL_ARM_ADDR32N,
IMAGE_REL_ARM_BRANCH2,
IMAGE_REL_ARM_BRANCH1,
IMAGE_REL_ARM_SECTION,
IMAGE_REL_ARM_SECREL,
};
enum sh_coff_reloc_type {
IMAGE_REL_SH3_ABSOLUTE,
IMAGE_REL_SH3_DIRECT16,
IMAGE_REL_SH3_DIRECT32,
IMAGE_REL_SH3_DIRECT8,
IMAGE_REL_SH3_DIRECT8_WORD,
IMAGE_REL_SH3_DIRECT8_LONG,
IMAGE_REL_SH3_DIRECT4,
IMAGE_REL_SH3_DIRECT4_WORD,
IMAGE_REL_SH3_DIRECT4_LONG,
IMAGE_REL_SH3_PCREL8_WORD,
IMAGE_REL_SH3_PCREL8_LONG,
IMAGE_REL_SH3_PCREL12_WORD,
IMAGE_REL_SH3_STARTOF_SECTION,
IMAGE_REL_SH3_SIZEOF_SECTION,
IMAGE_REL_SH3_SECTION,
IMAGE_REL_SH3_SECREL,
IMAGE_REL_SH3_DIRECT32_NB,
IMAGE_REL_SH3_GPREL4_LONG,
IMAGE_REL_SH3_TOKEN,
IMAGE_REL_SHM_PCRELPT,
IMAGE_REL_SHM_REFLO,
IMAGE_REL_SHM_REFHALF,
IMAGE_REL_SHM_RELLO,
IMAGE_REL_SHM_RELHALF,
IMAGE_REL_SHM_PAIR,
IMAGE_REL_SHM_NOMODE,
};
enum ppc_coff_reloc_type {
IMAGE_REL_PPC_ABSOLUTE,
IMAGE_REL_PPC_ADDR64,
IMAGE_REL_PPC_ADDR32,
IMAGE_REL_PPC_ADDR24,
IMAGE_REL_PPC_ADDR16,
IMAGE_REL_PPC_ADDR14,
IMAGE_REL_PPC_REL24,
IMAGE_REL_PPC_REL14,
IMAGE_REL_PPC_ADDR32N,
IMAGE_REL_PPC_SECREL,
IMAGE_REL_PPC_SECTION,
IMAGE_REL_PPC_SECREL16,
IMAGE_REL_PPC_REFHI,
IMAGE_REL_PPC_REFLO,
IMAGE_REL_PPC_PAIR,
IMAGE_REL_PPC_SECRELLO,
IMAGE_REL_PPC_GPREL,
IMAGE_REL_PPC_TOKEN,
};
enum x86_coff_reloc_type {
IMAGE_REL_I386_ABSOLUTE,
IMAGE_REL_I386_DIR16,
IMAGE_REL_I386_REL16,
IMAGE_REL_I386_DIR32,
IMAGE_REL_I386_DIR32NB,
IMAGE_REL_I386_SEG12,
IMAGE_REL_I386_SECTION,
IMAGE_REL_I386_SECREL,
IMAGE_REL_I386_TOKEN,
IMAGE_REL_I386_SECREL7,
IMAGE_REL_I386_REL32,
};
enum ia64_coff_reloc_type {
IMAGE_REL_IA64_ABSOLUTE,
IMAGE_REL_IA64_IMM14,
IMAGE_REL_IA64_IMM22,
IMAGE_REL_IA64_IMM64,
IMAGE_REL_IA64_DIR32,
IMAGE_REL_IA64_DIR64,
IMAGE_REL_IA64_PCREL21B,
IMAGE_REL_IA64_PCREL21M,
IMAGE_REL_IA64_PCREL21F,
IMAGE_REL_IA64_GPREL22,
IMAGE_REL_IA64_LTOFF22,
IMAGE_REL_IA64_SECTION,
IMAGE_REL_IA64_SECREL22,
IMAGE_REL_IA64_SECREL64I,
IMAGE_REL_IA64_SECREL32,
IMAGE_REL_IA64_DIR32NB,
IMAGE_REL_IA64_SREL14,
IMAGE_REL_IA64_SREL22,
IMAGE_REL_IA64_SREL32,
IMAGE_REL_IA64_UREL32,
IMAGE_REL_IA64_PCREL60X,
IMAGE_REL_IA64_PCREL60B,
IMAGE_REL_IA64_PCREL60F,
IMAGE_REL_IA64_PCREL60I,
IMAGE_REL_IA64_PCREL60M,
IMAGE_REL_IA64_IMMGPREL6,
IMAGE_REL_IA64_TOKEN,
IMAGE_REL_IA64_GPREL32,
IMAGE_REL_IA64_ADDEND,
};
struct coff_reloc {
uint32_t virtual_address;
uint32_t symbol_table_index;
union {
enum x64_coff_reloc_type x64_type;
enum arm_coff_reloc_type arm_type;
enum sh_coff_reloc_type sh_type;
enum ppc_coff_reloc_type ppc_type;
enum x86_coff_reloc_type x86_type;
enum ia64_coff_reloc_type ia64_type;
uint16_t data;
};
};
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA …
#define WIN_CERT_TYPE_EFI_OKCS115 …
#define WIN_CERT_TYPE_EFI_GUID …
#define WIN_CERT_REVISION_1_0 …
#define WIN_CERT_REVISION_2_0 …
struct win_certificate {
uint32_t length;
uint16_t revision;
uint16_t cert_type;
};
#endif
#endif