-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathhot_patch.h
84 lines (76 loc) · 1.99 KB
/
hot_patch.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
76
77
78
79
80
81
82
83
84
/*
* hot_patch.h
*
* Created on: Jan 10, 2011
* Author: Guyl
*/
#ifndef HOT_PATCH_H_
#define HOT_PATCH_H_
#include "mysql_inc.h"
#define DATATYPE_ADDRESS unsigned long
/*
#define JMP_OPCODE 0xE9
#define OPCODE_LENGTH 1
#define ADDRESS_LENGTH (sizeof(DATATYPE_ADDRESS))
#define MIN_REQUIRED_FOR_DETOUR (OPCODE_LENGTH + ADDRESS_LENGTH)
//the lenght of code we copy from target function to trampoline function (must be larger from MIN_REQUIRED_FOR_DETOUR=5).
//Using 6 as this is what is used in other sample code I've seen
#define TRAMPOLINE_COPY_LENGTH 6
*/
#define TRAMPOLINE_NOP_DEF {asm("nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t"\
"nop\n\t");\
}
int hot_patch_function(void* targetFunction, void* newFunction, void * trampolineFunction, unsigned int *trampolinesize, bool log_info, const char * log_prefix);
void remove_hot_patch_function (void* targetFunction, void * trampolineFunction, unsigned int trampolinesize, bool log_info, const char * log_prefix);
#endif /* HOT_PATCH_H_ */