Kernel/armv7 - Fixed lack of in*/out* functions
[tpg/acess2.git] / Kernel / bin / pe.h
1 /*\r
2 AcessOS/AcessBasic v1\r
3 PE Loader\r
4 HEADER\r
5 */\r
6 #ifndef _EXE_PE_H\r
7 #define _EXE_PE_H\r
8 \r
9 enum ePE_MACHINES {\r
10         PE_MACHINE_I386 = 0x14c,        // Intel 386+\r
11         PE_MACHINE_IA64 = 0x200         // Intel-64\r
12 };\r
13 \r
14 enum ePE_DIR_INDX {\r
15         PE_DIR_EXPORT,          // 0\r
16         PE_DIR_IMPORT,          // 1\r
17         PE_DIR_RESOURCE,        // 2\r
18         PE_DIR_EXCEPTION,       // 3\r
19         PE_DIR_SECRURITY,       // 4\r
20         PE_DIR_RELOC,           // 5\r
21         PE_DIR_DEBUG,           // 6\r
22         PE_DIR_COPYRIGHT,       // 7\r
23         PE_DIR_ARCHITECTURE,// 8\r
24         PE_DIR_GLOBALPTR,       // 9\r
25         PE_DIR_TLS,                     // 10\r
26         PE_DIR_LOAD_CFG,        // 11\r
27         PE_DIR_BOUND_IMPORT,// 12\r
28         PE_DIR_IAT,                     // 13\r
29         PE_DIR_DELAY_IMPORT,// 14\r
30         PE_DIR_COM_DESCRIPTOR,  //15\r
31         PE_DIR_LAST\r
32 };\r
33 \r
34 typedef struct {\r
35         Uint32  RVA;\r
36         Uint32  Size;\r
37 } tPE_DATA_DIR;\r
38 \r
39 typedef struct {\r
40         Uint32  *ImportLookupTable;     //0x80000000 is Ordninal Flag\r
41         Uint32  TimeStamp;\r
42         Uint32  FowarderChain;\r
43         char    *DLLName;\r
44         Uint32  *ImportAddressTable;    // Array of Addresses - To be edited by loader\r
45 } tPE_IMPORT_DIR;\r
46 \r
47 typedef struct {\r
48         Uint16  Hint;\r
49         char    Name[]; // Zero Term String\r
50 } tPE_HINT_NAME;\r
51 \r
52 typedef struct {\r
53         char    Name[8];\r
54         Uint32  VirtualSize;\r
55         Uint32  RVA;\r
56         Uint32  RawSize;\r
57         Uint32  RawOffs;\r
58         Uint32  RelocationsPtr; //Set to 0 in executables\r
59         Uint32  LineNumberPtr;  //Pointer to Line Numbers\r
60         Uint16  RelocationCount;        // Set to 0 in executables\r
61         Uint16  LineNumberCount;\r
62         Uint32  Flags;\r
63 } tPE_SECTION_HEADER;\r
64 \r
65 #define PE_SECTION_FLAG_CODE    0x00000020      // Section contains executable code.\r
66 #define PE_SECTION_FLAG_IDATA   0x00000040      // Section contains initialized data.\r
67 #define PE_SECTION_FLAG_UDATA   0x00000080      // Section contains uninitialized data.\r
68 #define PE_SECTION_FLAG_DISCARDABLE     0x02000000      // Section can be discarded as needed.\r
69 #define PE_SECTION_FLAG_MEM_NOT_CACHED  0x04000000      // Section cannot be cached.\r
70 #define PE_SECTION_FLAG_MEM_NOT_PAGED   0x08000000      // Section is not pageable.\r
71 #define PE_SECTION_FLAG_MEM_SHARED      0x10000000      // Section can be shared in memory.\r
72 #define PE_SECTION_FLAG_MEM_EXECUTE     0x20000000      // Section can be executed as code.\r
73 #define PE_SECTION_FLAG_MEM_READ        0x40000000      // Section can be read.\r
74 #define PE_SECTION_FLAG_MEM_WRITE       0x80000000      // Section can be written to.\r
75 \r
76 typedef struct {\r
77         Uint32  page;\r
78         Uint32  size;\r
79         Uint16  ents[];\r
80 } tPE_FIXUP_BLOCK;\r
81 \r
82 //File Header\r
83 typedef struct {\r
84         Uint16  Machine;\r
85         Uint16  SectionCount;\r
86         Uint32  CreationTimestamp;\r
87         Uint32  SymbolTableOffs;\r
88         Uint32  SymbolCount;\r
89         Uint16  OptHeaderSize;\r
90         Uint16  Flags;\r
91 } tPE_FILE_HEADER;\r
92 \r
93 typedef struct {\r
94         Uint16  Magic;  //0x10b: 32Bit, 0x20b: 64Bit\r
95         Uint16  LinkerVersion;\r
96         Uint32  CodeSize;       //Sum of all Code Segment Sizes\r
97         Uint32  DataSize;       //Sum of all Intialised Data Segments\r
98         Uint32  BssSize;        //Sum of all Unintialised Data Segments\r
99         Uint32  EntryPoint;\r
100         Uint32  CodeRVA;\r
101         Uint32  DataRVA;\r
102         Uint32  ImageBase;      //Prefered Base Address\r
103         Uint32  SectionAlignment;\r
104         Uint32  FileAlignment;\r
105         Uint32  WindowsVersion; //Unused/Irrelevent\r
106         Uint32  ImageVersion;   //Unused/Irrelevent\r
107         Uint32  SubsystemVersion;       //Unused, Set to 4\r
108         Uint32  Win32Version;   //Unused\r
109         Uint32  ImageSize;\r
110         Uint32  HeaderSize;\r
111         Uint32  Checksum;       //Unknown Method, Can be set to 0\r
112         Uint16  Subsystem;      //Required Windows Subsystem (None, GUI, Console)\r
113         Uint16  DllFlags;\r
114         Uint32  MaxStackSize;           //Reserved Stack Size\r
115         Uint32  InitialStackSize;       //Commited Stack Size\r
116         Uint32  InitialReservedHeap;    // Reserved Heap Size\r
117         Uint32  InitialCommitedHeap;    // Commited Heap Size\r
118         Uint32  LoaderFlags;    // Obselete\r
119         Uint32  NumberOfDirEntries;\r
120         tPE_DATA_DIR    Directory[16];\r
121 } tPE_OPT_HEADER;\r
122 \r
123 // Root Header\r
124 typedef struct {\r
125         Uint32  Signature;\r
126         tPE_FILE_HEADER FileHeader;\r
127         tPE_OPT_HEADER  OptHeader;\r
128 } tPE_IMAGE_HEADERS;\r
129 \r
130 typedef struct {\r
131         Uint16  Ident;\r
132         Uint16  Resvd[29];\r
133         Uint32  PeHdrOffs;              // File address of new exe header\r
134 } tPE_DOS_HEADER;\r
135 \r
136 #endif\r

UCC git Repository :: git.ucc.asn.au