-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfridacpp.h
57 lines (41 loc) · 1.41 KB
/
fridacpp.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
#include "frida-gum.h"
struct GumInvocationListenerProxy;
class InvocationListener {
public:
InvocationListener();
~InvocationListener() = default;
virtual void on_enter(GumInvocationContext* ic) = 0;
virtual void on_leave(GumInvocationContext* ic) = 0;
GumInvocationListenerProxy* get_handle() { return cproxy; }
private:
GumInvocationListenerProxy* cproxy;
};
class Intercepter {
inline static bool init = false;
public:
Intercepter()
{
if (!init) {
gum_init_embedded();
init = true;
}
_intercepter = gum_interceptor_obtain();
}
~Intercepter() { g_object_unref(_intercepter); }
bool attach(gpointer function, InvocationListener* listener, gpointer data)
{
return gum_interceptor_attach(_intercepter, function, (GumInvocationListener*)listener->get_handle(), data) == GUM_ATTACH_OK;
}
bool replace(gpointer oldfun, gpointer newfun, gpointer data)
{
return gum_interceptor_replace(_intercepter, oldfun, newfun, data) == GUM_REPLACE_OK;
}
void detach(InvocationListener* listener)
{
gum_interceptor_detach(_intercepter, (GumInvocationListener*)listener->get_handle());
}
void begin_transaction() { gum_interceptor_begin_transaction(_intercepter); }
void end_transaction() { gum_interceptor_end_transaction(_intercepter); }
private:
GumInterceptor* _intercepter;
};