Stefan Reinauer | cc5b344 | 2013-01-15 17:02:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the TianoCoreBoot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Stefan Reinauer | cc5b344 | 2013-01-15 17:02:58 -0800 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | typedef struct { |
| 21 | uint8_t signature[2]; |
| 22 | uint16_t lastsize; |
| 23 | uint16_t nblocks; |
| 24 | uint16_t nreloc; |
| 25 | uint16_t hdrsize; |
| 26 | uint16_t minalloc; |
| 27 | uint16_t maxalloc; |
| 28 | uint16_t ss; |
| 29 | uint16_t sp; |
| 30 | uint16_t checksum; |
| 31 | uint16_t ip; |
| 32 | uint16_t cs; |
| 33 | uint16_t relocpos; |
| 34 | uint16_t noverlay; |
| 35 | uint16_t reserved1[4]; |
| 36 | uint16_t oem_id; |
| 37 | uint16_t oem_info; |
| 38 | uint16_t reserved2[10]; |
| 39 | uint32_t e_lfanew; |
| 40 | } dos_header_t; |
| 41 | |
| 42 | typedef struct { |
| 43 | uint8_t signature[4]; |
| 44 | uint16_t Machine; |
| 45 | uint16_t NumberOfSections; |
| 46 | uint32_t TimeDateStamp; |
| 47 | uint32_t PointerToSymbolTable; |
| 48 | uint32_t NumberOfSymbols; |
| 49 | uint16_t SizeOfOptionalHeader; |
| 50 | uint16_t Characteristics; |
| 51 | } coff_header_t; |
| 52 | |
| 53 | typedef struct { |
| 54 | uint32_t VirtualAddress; |
| 55 | uint32_t Size; |
| 56 | } data_directory; |
| 57 | |
| 58 | typedef struct { |
| 59 | uint16_t signature; |
| 60 | uint8_t MajorLinkerVersion; |
| 61 | uint8_t MinorLinkerVersion; |
| 62 | uint32_t SizeOfCode; |
| 63 | uint32_t SizeOfInitializedData; |
| 64 | uint32_t SizeOfUninitializedData; |
| 65 | uint32_t AddressOfEntryPoint; |
| 66 | uint32_t BaseOfCode; |
| 67 | uint32_t BaseOfData; |
| 68 | uint32_t ImageBase; |
| 69 | uint32_t SectionAlignment; |
| 70 | uint32_t FileAlignment; |
| 71 | uint16_t MajorOSVersion; |
| 72 | uint16_t MinorOSVersion; |
| 73 | uint16_t MajorImageVersion; |
| 74 | uint16_t MinorImageVersion; |
| 75 | uint16_t MajorSubsystemVersion; |
| 76 | uint16_t MinorSubsystemVersion; |
| 77 | uint32_t Reserved; |
| 78 | uint32_t SizeOfImage; |
| 79 | uint32_t SizeOfHeaders; |
| 80 | uint32_t Checksum; |
| 81 | uint16_t Subsystem; |
| 82 | uint16_t DLLCharacteristics; |
| 83 | uint32_t SizeOfStackReserve; |
| 84 | uint32_t SizeOfStackCommit; |
| 85 | uint32_t SizeOfHeapReserve; |
| 86 | uint32_t SizeOfHeapCommit; |
| 87 | uint32_t LoaderFlags; |
| 88 | uint32_t NumberOfRvaAndSizes; |
| 89 | data_directory DataDirectory[16]; |
| 90 | } pe_opt_header_t; |
| 91 | |
| 92 | typedef struct { |
| 93 | uint8_t SectionName[8]; |
| 94 | uint32_t Size; |
| 95 | uint32_t RVA; |
| 96 | uint32_t PhysicalSizeOnDisk; |
| 97 | uint32_t PhysicalLocationOnDisk; |
| 98 | uint8_t Reserved[12]; |
| 99 | uint32_t SectionFlags; |
| 100 | } pe_section_t; |
| 101 | |
| 102 | typedef struct { |
| 103 | uint32_t VirtualAddress; |
| 104 | uint32_t SizeOfBlock; |
| 105 | } relocation_t; |
| 106 | |