-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPE.h
63 lines (52 loc) · 1.71 KB
/
PE.h
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
#ifndef PE_INCLUDED
#define PE_INCLUDED
/*
(Partial) Parsing of PE Header information. Main use is to read/write import info; either to set hooks or to write
injectable asm code that uses imported functions (therefore i need the import-addresses from the IAT before i can write/inject the code).
-- Wim Decelle
*/
#include "BinaryTree.h"
#include "Process.h"
#include <windows.h>
typedef struct
{
unsigned int baseaddress;
unsigned int fileheader_address;
unsigned int optionalheader_address;
IMAGE_DOS_HEADER dosheader;
IMAGE_FILE_HEADER fileheader;
IMAGE_OPTIONAL_HEADER32 optionalheader;
//IMAGE_OPTIONAL_HEADER64 optionalheader64;
} PEHeaders;
typedef struct
{
PEHeaders headers;//note this contains RVAs and the like, so not all addresses can be used easily
LinkedList * ImportedLibraries;
LinkedList * ExportedSymbols;
} PEInfo;
typedef struct
{
char * name;//might be 0, though an attempt is made to read the name from the loaded libraries PE export directory if it's not in the INT
unsigned int IATAddress;//address of the IAT address entry (<- overwrite the address at this point when hooking)
unsigned int Address;//symbol address
unsigned short Ordinal;//imported symbol's ordinal
} ImportedSymbol;
typedef struct
{
char * libname;
LinkedList * ImportedSymbols;
} ImportedLibrary;
typedef struct
{
unsigned int Address;
unsigned short Ordinal;
char * Name;
//...?
} ExportedSymbol;
PEInfo * _GetPEInfo(Process * onprocess, unsigned int baseaddress, int need_imports, int need_exports);
PEInfo * GetPEInfo(Process * ofprocess);
void DeletePEInfo(PEInfo * todelete);
//ERRORS
#define PE_ERROR_BASE 0x1000
#define PE_ERROR PE_ERROR_BASE+1
#endif