blob: 8afdef60dad73855bd6943407a2059de64277d43 (
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
|
#include "binaryninjaapi.h"
using namespace BinaryNinja;
using namespace std;
FunctionGraphBlock::FunctionGraphBlock(BNFunctionGraphBlock* block): m_block(block)
{
}
FunctionGraphBlock::~FunctionGraphBlock()
{
BNFreeFunctionGraphBlock(m_block);
}
int FunctionGraphBlock::GetX() const
{
return BNGetFunctionGraphBlockX(m_block);
}
int FunctionGraphBlock::GetY() const
{
return BNGetFunctionGraphBlockY(m_block);
}
int FunctionGraphBlock::GetWidth() const
{
return BNGetFunctionGraphBlockWidth(m_block);
}
int FunctionGraphBlock::GetHeight() const
{
return BNGetFunctionGraphBlockHeight(m_block);
}
vector<FunctionGraphTextLine> FunctionGraphBlock::GetLines() const
{
size_t count;
BNFunctionGraphTextLine* lines = BNGetFunctionGraphBlockLines(m_block, &count);
vector<FunctionGraphTextLine> result;
for (size_t i = 0; i < count; i++)
{
FunctionGraphTextLine line;
line.addr = lines[i].addr;
for (size_t j = 0; j < lines[i].count; j++)
{
InstructionTextToken token;
token.type = lines[i].tokens[j].type;
token.text = lines[i].tokens[j].text;
token.value = lines[i].tokens[j].value;
line.tokens.push_back(token);
}
result.push_back(line);
}
BNFreeFunctionGraphBlockLines(lines, count);
return result;
}
vector<BNBasicBlockEdge> FunctionGraphBlock::GetOutgoingEdges() const
{
size_t count;
BNBasicBlockEdge* edges = BNGetFunctionGraphBlockOutgoingEdges(m_block, &count);
vector<BNBasicBlockEdge> result;
result.insert(result.begin(), &edges[0], &edges[count]);
BNFreeFunctionGraphBlockOutgoingEdgeList(edges);
return result;
}
|