-
Notifications
You must be signed in to change notification settings - Fork 9
/
codelib.h
75 lines (61 loc) · 1.8 KB
/
codelib.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
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#define SYMBOL_TYPE_CODE 0x01
#define SYMBOL_TYPE_INITIALIZED_DATA 0x02
#define SYMBOL_TYPE_UNINITIALIZED_DATA 0x04
#define SYMBOL_TYPE_WRITE 0x08
#define FUNCTION_TYPE_CREATE_POINTER 0x01
enum FunctionType
{
ft_cdecl, // Pushes parameters on the stack, in reverse order (right to left)
ft_stdcall, // Pushes parameters on the stack, in reverse order (right to left)
ft_fastcall // Stored in registers, then pushed on stack
//ft_thiscall // Pushed on stack; this pointer stored in ECX
};
struct cfunction
{
char *name;
void *address;
int type;
};
class CResFile;
class CCodeLib
{
struct reloc
{
void **VirtualAddress;
int imp_num;
};
struct symbol
{
char *name;
char *undec_name;
void *address;
int size, type;
};
int alloctype, image_ready, image_size, bbs_size, code_size, data_size, rdata_size;
BYTE *pimage;
BYTE *bss_seg;
public:
CCodeLib();
int exports_num;
symbol *exports;
int imports_num, resolved_imports_num;
symbol *imports;
int relocs_num;
reloc *relocs;
int LoadObjCode(CResFile *f);
//int LoadDll(char *dllname,char **funcs);
int LoadProcs(cfunction *funcs);
int Link(CCodeLib *lib);
int LinkMany(CCodeLib **lib, int libs);
void Unload();
void *FindSymAddr(char *fname);
void *FindSymAddrUndec(char *und_fname);
symbol *FindSym(char *sym_name);
symbol *FindSymUndec(char *und_sym_name);
int operator ()(char *fn_name);
int GetBSS_Size() { return bbs_size; }
int GetCode_Size() { return code_size; }
int GetData_Size() { return data_size; }
int GetRData_Size() { return rdata_size; }
};