blob: 5d8ac9f8c7350740e4c30f8d0b79096eea9dadb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* -------------------------------------------
Copyright Mahrouss Logic
File: PE.hpp
Purpose: Portable Executable for HCore.
Revision History:
30/01/24: Added file (amlel)
------------------------------------------- */
#ifndef __PE__
#define __PE__
#include <NewKit/Defines.hpp>
typedef HCore::UInt32 U32;
typedef HCore::UInt16 U16;
typedef HCore::UInt8 U8;
typedef char CHAR;
#define kPeMagic 0x00004550
struct ExecHeader final {
U32 mMagic; // PE\0\0 or 0x00004550
U16 mMachine;
U16 mNumberOfSections;
U32 mTimeDateStamp;
U32 mPointerToSymbolTable;
U32 mNumberOfSymbols;
U16 mSizeOfOptionalHeader;
U16 mCharacteristics;
};
#define kMagPE32 0x010b
#define kMagPE64 0x020b
typedef struct ExecOptionalHeader final {
U16 mMagic; // 0x010b - PE32, 0x020b - PE32+ (64 bit)
U8 mMajorLinkerVersion;
U8 mMinorLinkerVersion;
U32 mSizeOfCode;
U32 mSizeOfInitializedData;
U32 mSizeOfUninitializedData;
U32 mAddressOfEntryPoint;
U32 mBaseOfCode;
U32 mBaseOfData;
U32 mImageBase;
U32 mSectionAlignment;
U32 mFileAlignment;
U16 mMajorOperatingSystemVersion;
U16 mMinorOperatingSystemVersion;
U16 mMajorImageVersion;
U16 mMinorImageVersion;
U16 mMajorSubsystemVersion;
U16 mMinorSubsystemVersion;
U32 mWin32VersionValue;
U32 mSizeOfImage;
U32 mSizeOfHeaders;
U32 mCheckSum;
U16 mSubsystem;
U16 mDllCharacteristics;
U32 mSizeOfStackReserve;
U32 mSizeOfStackCommit;
U32 mSizeOfHeapReserve;
U32 mSizeOfHeapCommit;
U32 mLoaderFlags;
U32 mNumberOfRvaAndSizes;
} ExecOptionalHeader, *ExecOptionalHeaderPtr;
typedef struct ExecSectionHeader final {
CHAR mName[8];
U32 mVirtualSize;
U32 mVirtualAddress;
U32 mSizeOfRawData;
U32 mPointerToRawData;
U32 mPointerToRelocations;
U32 mPointerToLinenumbers;
U16 mNumberOfRelocations;
U16 mNumberOfLinenumbers;
U32 mCharacteristics;
} ExecSectionHeader, *ExecSectionHeaderPtr;
enum kExecDataDirParams {
kExecExport,
kExecImport,
kExecCnt,
};
typedef struct ExecExportDirectory {
U32 mCharacteristics;
U32 mTimeDateStamp;
U16 mMajorVersion;
U16 mMinorVersion;
U32 mName;
U32 mBase;
U32 mNumberOfFunctions;
U32 mNumberOfNames;
U32 mAddressOfFunctions; // export table rva
U32 mAddressOfNames;
U32 mAddressOfNameOrdinal; // ordinal table rva
} ExecExportDirectory, *ExecExportDirectoryPtr;
typedef struct ExecImportDirectory {
union {
U32 mCharacteristics;
U32 mOriginalFirstThunk;
};
U32 mTimeDateStamp;
U32 mForwarderChain;
U32 mNameRva;
U32 mThunkTableRva;
} ExecImportDirectory, *ExecImportDirectoryPtr;
#endif /* ifndef __PE__ */
|