blob: 45b29752729b101660f22991c0c0dd1722976ae3 (
plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#include "binaryninjaapi.h"
using namespace BinaryNinja;
using namespace std;
Function::Function(BNFunction* func): m_func(func)
{
}
Function::~Function()
{
BNFreeFunction(m_func);
}
Ref<Architecture> Function::GetArchitecture() const
{
return new CoreArchitecture(BNGetFunctionArchitecture(m_func));
}
uint64_t Function::GetStart() const
{
return BNGetFunctionStart(m_func);
}
Ref<Symbol> Function::GetSymbol() const
{
return new Symbol(BNGetFunctionSymbol(m_func));
}
vector<Ref<BasicBlock>> Function::GetBasicBlocks() const
{
size_t count;
BNBasicBlock** blocks = BNGetFunctionBasicBlockList(m_func, &count);
vector<Ref<BasicBlock>> result;
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
BNFreeBasicBlockList(blocks, count);
return result;
}
void Function::MarkRecentUse()
{
BNMarkFunctionAsRecentlyUsed(m_func);
}
string Function::GetCommentForAddress(uint64_t addr) const
{
char* comment = BNGetCommentForAddress(m_func, addr);
string result = comment;
BNFreeString(comment);
return result;
}
vector<uint64_t> Function::GetCommentedAddresses() const
{
size_t count;
uint64_t* addrs = BNGetCommentedAddresses(m_func, &count);
vector<uint64_t> result;
result.insert(result.end(), addrs, &addrs[count]);
BNFreeAddressList(addrs);
return result;
}
void Function::SetCommentForAddress(uint64_t addr, const string& comment)
{
BNSetCommentForAddress(m_func, addr, comment.c_str());
}
Ref<LowLevelILFunction> Function::GetLowLevelIL() const
{
return new LowLevelILFunction(BNGetFunctionLowLevelIL(m_func));
}
vector<Ref<BasicBlock>> Function::GetLowLevelILBasicBlocks() const
{
size_t count;
BNBasicBlock** blocks = BNGetFunctionLowLevelILBasicBlockList(m_func, &count);
vector<Ref<BasicBlock>> result;
for (size_t i = 0; i < count; i++)
result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i])));
BNFreeBasicBlockList(blocks, count);
return result;
}
Ref<FunctionGraph> Function::CreateFunctionGraph()
{
BNFunctionGraph* graph = BNCreateFunctionGraph(m_func);
return new FunctionGraph(graph);
}
|