1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 3 #pragma once 4 5 #include <inttypes.h> 6 7 #include "macro.h" 8 #include "sparse-endian.h" 9 10 struct DosFileHeader { 11 uint8_t Magic[2]; 12 le16_t LastSize; 13 le16_t nBlocks; 14 le16_t nReloc; 15 le16_t HdrSize; 16 le16_t MinAlloc; 17 le16_t MaxAlloc; 18 le16_t ss; 19 le16_t sp; 20 le16_t Checksum; 21 le16_t ip; 22 le16_t cs; 23 le16_t RelocPos; 24 le16_t nOverlay; 25 le16_t reserved[4]; 26 le16_t OEMId; 27 le16_t OEMInfo; 28 le16_t reserved2[10]; 29 le32_t ExeHeader; 30 } _packed_; 31 32 struct PeFileHeader { 33 le16_t Machine; 34 le16_t NumberOfSections; 35 le32_t TimeDateStamp; 36 le32_t PointerToSymbolTable; 37 le32_t NumberOfSymbols; 38 le16_t SizeOfOptionalHeader; 39 le16_t Characteristics; 40 } _packed_; 41 42 struct PeHeader { 43 uint8_t Magic[4]; 44 struct PeFileHeader FileHeader; 45 } _packed_; 46 47 struct PeSectionHeader { 48 uint8_t Name[8]; 49 le32_t VirtualSize; 50 le32_t VirtualAddress; 51 le32_t SizeOfRawData; 52 le32_t PointerToRawData; 53 le32_t PointerToRelocations; 54 le32_t PointerToLinenumbers; 55 le16_t NumberOfRelocations; 56 le16_t NumberOfLinenumbers; 57 le32_t Characteristics; 58 } _packed_; 59