-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinject.h
More file actions
113 lines (93 loc) · 2.13 KB
/
inject.h
File metadata and controls
113 lines (93 loc) · 2.13 KB
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
#pragma once
template<typename OUTSTUFF, typename INSTUFF>
OUTSTUFF ForceCast(INSTUFF in)
{
union
{
INSTUFF in;
OUTSTUFF out;
}
u = { in };
return u.out;
};
enum BioVersion
{
BV_NEWEUR, // European 1.00c
BV_MEDIAKITE, // Japanese 1.01
BV_ASIA, // UK/US for Asia
BV_UKUSA, // UK/US
BV_UKUSA1, // almost the same as UK/US
BV_GERMAN, // Germany
BV_FRENCH, // France
BV_UKVR, // PowerVR UK/US
BV_JPVR, // PowerVR Japanese
BVV_UKUSADEMO, //
BV_UNSUPPORTED // unknown version
};
typedef struct tagBioVersion
{
size_t size; // executable size
char *pName; // internal name of version
UINT crc; // crc32 of the first 512 bytes of .text
int supported; // 1 = supported, 0 = unsupported
} BIO_VERSION;
BioVersion DetectVersion(UCHAR *pExe);
#pragma pack(push, 1)
typedef struct {
BYTE opCode; // must be 0xE9;
DWORD offset; // jump offset
} JMP;
typedef struct
{
BYTE opCode0; // must be 0xE8
DWORD offset0; // call offset
BYTE opCode1; // must be 0xE9
DWORD offset1; // reroute offset
} CALLX;
#pragma pack(pop)
#define INJECT(from,to) { \
((JMP*)(from))->opCode = 0xE9; \
((JMP*)(from))->offset = (DWORD)(to) - ((DWORD)(from) + sizeof(JMP)); \
}
#define INJECT_EXT(from,to) (*(DWORD*)(from)) = (DWORD)(to)
#define INJECT_CALL(from,to,size) {\
memset((from), 0x90, size); \
((JMP*)(from))->opCode = 0xE8; \
((JMP*)(from))->offset = (DWORD)(to) - ((DWORD)(from) + sizeof(JMP)); \
}
#define INJECT_CALLX(from,fnc,skp) {\
((CALLX*)(from))->opCode0 = 0xE8; \
((CALLX*)(from))->offset0 = (DWORD)(fnc) - ((DWORD)(from) + sizeof(JMP)); \
((CALLX*)(from))->opCode1 = 0xE9; \
((CALLX*)(from))->offset1 = (DWORD)(skp) - ((DWORD)(from) + sizeof(CALLX)); \
}\
void Inject(HMODULE exe);
void Inject_winmm(UCHAR*exe);
void Inject_winmmJP(UCHAR*exe);
void MessageBoxV(UINT icon, char *caption, char *message, ...);
enum InjectType
{
IT_JUMP,
IT_CALL,
IT_EXTERN,
IT_NOP
};
class CInjectCmd
{
public:
CInjectCmd() {}
void Execute(UCHAR*pProcess) {}
InjectType type;
};
class CInjectExtern : public CInjectCmd
{
CInjectExtern() { type = IT_EXTERN; }
void Execute(UCHAR*pProcess)
{
}
};
class CInjector
{
public:
CInjector() {}
};