Usermode/libposix - Fixed bug in getpass (didn't trim \n)
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / 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         Uint32  Flags;\r
49         Uint32  Timestamp;\r
50         Uint16  MajorVer;\r
51         Uint16  MinorVer;\r
52         Uint32  NameRVA;        // DLL Name\r
53         Uint32  OrdinalBase;\r
54         Uint32  NumAddresses;\r
55         Uint32  NumNamePointers;\r
56         Uint32  AddressRVA;\r
57         Uint32  NamePointerRVA;\r
58         Uint32  OrdinalTableRVA;\r
59 } tPE_EXPORT_DIR;\r
60 \r
61 typedef struct {\r
62         Uint16  Hint;\r
63         char    Name[]; // Zero Terminated String\r
64 } tPE_HINT_NAME;\r
65 \r
66 typedef struct {\r
67         char    Name[8];\r
68         Uint32  VirtualSize;\r
69         Uint32  RVA;\r
70         Uint32  RawSize;\r
71         Uint32  RawOffs;\r
72         Uint32  RelocationsPtr; //Set to 0 in executables\r
73         Uint32  LineNumberPtr;  //Pointer to Line Numbers\r
74         Uint16  RelocationCount;        // Set to 0 in executables\r
75         Uint16  LineNumberCount;\r
76         Uint32  Flags;\r
77 } tPE_SECTION_HEADER;\r
78 \r
79 #define PE_SECTION_FLAG_CODE    0x00000020      // Section contains executable code.\r
80 #define PE_SECTION_FLAG_IDATA   0x00000040      // Section contains initialized data.\r
81 #define PE_SECTION_FLAG_UDATA   0x00000080      // Section contains uninitialized data.\r
82 #define PE_SECTION_FLAG_DISCARDABLE     0x02000000      // Section can be discarded as needed.\r
83 #define PE_SECTION_FLAG_MEM_NOT_CACHED  0x04000000      // Section cannot be cached.\r
84 #define PE_SECTION_FLAG_MEM_NOT_PAGED   0x08000000      // Section is not pageable.\r
85 #define PE_SECTION_FLAG_MEM_SHARED      0x10000000      // Section can be shared in memory.\r
86 #define PE_SECTION_FLAG_MEM_EXECUTE     0x20000000      // Section can be executed as code.\r
87 #define PE_SECTION_FLAG_MEM_READ        0x40000000      // Section can be read.\r
88 #define PE_SECTION_FLAG_MEM_WRITE       0x80000000      // Section can be written to.\r
89 \r
90 typedef struct {\r
91         Uint32  page;\r
92         Uint32  size;\r
93         Uint16  ents[];\r
94 } tPE_FIXUP_BLOCK;\r
95 \r
96 //File Header\r
97 typedef struct {\r
98         Uint16  Machine;\r
99         Uint16  SectionCount;\r
100         Uint32  CreationTimestamp;\r
101         Uint32  SymbolTableOffs;\r
102         Uint32  SymbolCount;\r
103         Uint16  OptHeaderSize;\r
104         Uint16  Flags;\r
105 } tPE_FILE_HEADER;\r
106 \r
107 typedef struct {\r
108         Uint16  Magic;  //0x10b: 32Bit, 0x20b: 64Bit\r
109         Uint16  LinkerVersion;\r
110         Uint32  CodeSize;       //Sum of all Code Segment Sizes\r
111         Uint32  DataSize;       //Sum of all Intialised Data Segments\r
112         Uint32  BssSize;        //Sum of all Unintialised Data Segments\r
113         Uint32  EntryPoint;\r
114         Uint32  CodeRVA;\r
115         Uint32  DataRVA;\r
116         Uint32  ImageBase;      //Prefered Base Address\r
117         Uint32  SectionAlignment;\r
118         Uint32  FileAlignment;\r
119         Uint32  WindowsVersion; //Unused/Irrelevent\r
120         Uint32  ImageVersion;   //Unused/Irrelevent\r
121         Uint32  SubsystemVersion;       //Unused, Set to 4\r
122         Uint32  Win32Version;   //Unused\r
123         Uint32  ImageSize;\r
124         Uint32  HeaderSize;\r
125         Uint32  Checksum;       //Unknown Method, Can be set to 0\r
126         Uint16  Subsystem;      //Required Windows Subsystem (None, GUI, Console)\r
127         Uint16  DllFlags;\r
128         Uint32  MaxStackSize;           //Reserved Stack Size\r
129         Uint32  InitialStackSize;       //Commited Stack Size\r
130         Uint32  InitialReservedHeap;    // Reserved Heap Size\r
131         Uint32  InitialCommitedHeap;    // Commited Heap Size\r
132         Uint32  LoaderFlags;    // Obselete\r
133         Uint32  NumberOfDirEntries;\r
134         tPE_DATA_DIR    Directory[16];\r
135 } tPE_OPT_HEADER;\r
136 \r
137 // Root Header\r
138 typedef struct {\r
139         Uint32  Signature;\r
140         tPE_FILE_HEADER FileHeader;\r
141         tPE_OPT_HEADER  OptHeader;\r
142 } tPE_IMAGE_HEADERS;\r
143 \r
144 typedef struct {\r
145         Uint16  Ident;\r
146         Uint16  Resvd[29];\r
147         Uint32  PeHdrOffs;              // File address of new exe header\r
148 } tPE_DOS_HEADER;\r
149 \r
150 #endif\r

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