-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.h
63 lines (54 loc) · 1.78 KB
/
common.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
#ifndef COMMON_H
#define COMMON_H
#include <proto/exec.h>
#define NAME_LEN 64
#define TAG_BUFFER_LEN 1024
#define MAX_CLIENTS 5
void find_process_name2(struct Node * node, char * destination);
#define GENERATE_PATCH(type,func,prefix,ctxtype) \
static void patch_##func(BOOL patching, struct ctxtype * ctx) \
{ \
IExec->Forbid(); \
if (patching) { \
ctx->old_##func = (const void *)IExec->SetMethod((struct Interface *)ctx->interface, offsetof(struct type, func), prefix##_##func); \
} else { \
if (ctx->old_##func) { \
IExec->SetMethod((struct Interface *)ctx->interface, offsetof(struct type, func), ctx->old_##func); \
ctx->old_##func = NULL; \
} \
} \
IExec->Permit(); \
\
if (patching) { \
if (ctx->old_##func) { \
logDebug("Patched " #func " %p with %p", ctx->old_##func, prefix##_##func); \
} \
} else { \
logDebug("Restored " #func); \
} \
} \
#define GENERATE_FILTERED_PATCH(type,func,prefix,ctxtype) \
static void patch_##func(BOOL patching, struct ctxtype * ctx) \
{ \
IExec->Forbid(); \
if (patching) { \
if (match(#func)) { \
ctx->old_##func = (const void *)IExec->SetMethod((struct Interface *)ctx->interface, offsetof(struct type, func), prefix##_##func); \
} \
} else { \
if (ctx->old_##func) { \
IExec->SetMethod((struct Interface *)ctx->interface, offsetof(struct type, func), ctx->old_##func); \
ctx->old_##func = NULL; \
} \
} \
IExec->Permit(); \
\
if (patching) { \
if (ctx->old_##func) { \
logDebug("Patched " #func " %p with %p", ctx->old_##func, prefix##_##func); \
} \
} else { \
logDebug("Restored " #func); \
} \
} \
#endif