-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisassembler.h
52 lines (44 loc) · 1.23 KB
/
disassembler.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
#ifndef _DISASSEMBLER_H_
#define _DISASSEMBLER_H_
#include <stddef.h>
#include <inttypes.h>
#include "vec.h"
#include "set.h"
#include "dict.h"
#include "util.h"
typedef struct next {
uintptr_t address;
} next_t;
typedef struct instruction {
uintptr_t address;
size_t size;
char *mnemonic;
char *op_str;
uint8_t bytes[16];
vec_t *nexts;
uintptr_t call_target;
} ins_t;
typedef struct basicblock {
vec_t *prevs;
vec_t *instructions;
} bb_t;
typedef struct control_flow_graph {
uintptr_t address;
dict_t *basicblocks;
} cfg_t;
next_t *next_new(uintptr_t address);
dict_t *disassemble(uintptr_t address);
set_t *find_all_calls(dict_t *instructions);
set_t *find_all_functions(uintptr_t address, vec_t *seen);
ins_t *get_instruction(vec_t *instructions, uintptr_t address);
bb_t *basicblock_new(vec_t *prevs, ins_t *first_ins);
uintptr_t basicblock_address(bb_t *bb);
vec_t *basicblock_nexts(bb_t *bb);
vec_t *basicblock_prevs(bb_t *bb);
void basicblock_push_ins(bb_t *bb, ins_t *ins);
void basicblock_print(bb_t *bb);
cfg_t *make_cfg(dict_t *instructions, uintptr_t address);
void remove_single_jump_bb(cfg_t *cfg, bb_t *bb);
void cleanup_cfg(cfg_t *cfg);
vec_t *find_all_basicblocks(uintptr_t address);
#endif