forked from actboy168/lua-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterceptor.cpp
More file actions
41 lines (33 loc) · 928 Bytes
/
interceptor.cpp
File metadata and controls
41 lines (33 loc) · 928 Bytes
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
#include <gumpp.hpp>
#include <stdio.h>
#include <string.h>
#define LOG(fmt, ...) printf("[test_native] " fmt "\n", ##__VA_ARGS__)
extern "C" {
void test_add(int a, int b) {
printf("%d,%d,%d", a, b, a + b);
a = a + 1;
b = b + 1;
printf("%d,%d,%d", a,b,a+b);
}
}
static int on_enter = 1;
static int on_leave = 2;
struct MyInvocationListener : Gum::InvocationListener{
virtual ~MyInvocationListener () {}
virtual void on_enter (Gum::InvocationContext * context){
LOG("on_enter");
::on_enter = 0;
};
virtual void on_leave (Gum::InvocationContext * context){
LOG("on_leave");
::on_leave = 0;
};
};
int main(int argc, char *argv[]) {
LOG("test execve");
Gum::RefPtr<Gum::Interceptor> interceptor (Gum::Interceptor_obtain ());
MyInvocationListener listener;
interceptor->attach((void*)&test_add, &listener, 0);
test_add(1, 2);
return on_enter + on_leave;
}