forked from cseagle/sk3wldbg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XSyscall_handle.h
72 lines (60 loc) · 1.33 KB
/
XSyscall_handle.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
#pragma once
#include <unicorn/unicorn.h>
#include <string>
#include <functional>
#include <map>
class interrupt_handle
{
public:
void process_interrupt(uc_engine *uc, uint32_t intno);
void set_handle(uint32_t intno, std::function<int(uc_engine*)>handler);
protected:
std::map<uint32_t, std::function<int(uc_engine*)>> _handles;
};
extern interrupt_handle g_interrupt_handle;
//================================================================
struct syscall_args
{
uint64_t arg[7];
void zero()
{
memset(arg, 0, sizeof(arg));
}
};
class syscall_handle
{
public:
int idx;
std::string name;
int arg_count;
std::function<void*(uc_engine*, syscall_args&)> callback;
syscall_handle()
{
}
syscall_handle(int idx, std::string name, int arg_count, std::function<void*(uc_engine*, syscall_args&)> cb)
{
this->idx = idx;
this->name = name;
this->arg_count = arg_count;
this->callback = cb;
}
syscall_handle& operator=(syscall_handle& right)
{
this->idx = right.idx;
this->name = right.name;
this->arg_count = right.arg_count;
this->callback = right.callback;
return *this;
}
};
class XSyscall_handle
{
public:
XSyscall_handle();
~XSyscall_handle();
void set_handle(uint32_t intno, syscall_handle handler);
int handle_syscall(uc_engine*);
syscall_args _args;
protected:
std::map<uint32_t, syscall_handle> _handles;
};