FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
binaryninja-api/component.cpp at dev · Vector35/binaryninja-api · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Vector35
/
binaryninja-api
Public
Notifications
You must be signed in to change notification settings
Fork
294
Star
1.3k
Code
Issues
1.9k
Pull requests
37
Discussions
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
binaryninja-api
/
component.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
205 lines (144 loc) · 4.13 KB
Breadcrumbs
binaryninja-api
/
component.cpp
Copy path
File metadata and controls
205 lines (144 loc) · 4.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#
include
"
binaryninjaapi.h
"
using
namespace
BinaryNinja
;
using
namespace
std
;
bool
Component::
operator
==(
const
Component& other)
const
{
return
BNComponentsEqual
(m_object, other.
m_object
);
}
bool
Component::
operator
!=(
const
Component& other)
const
{
return
BNComponentsNotEqual
(m_object, other.
m_object
);
}
Component::Component
(BNComponent* component)
{
m_object = component;
}
std::string
Component::GetDisplayName
()
{
char
* result =
BNComponentGetDisplayName
(m_object);
string stringResult = result;
BNFreeString
(result);
return
stringResult;
}
std::string
Component::GetName
()
{
char
* result =
BNComponentGetOriginalName
(m_object);
string stringResult = result;
BNFreeString
(result);
return
stringResult;
}
Ref<BinaryView>
Component::GetView
()
{
return
new
BinaryView
(
BNComponentGetView
(m_object));
}
void
Component::SetName
(
const
std::string &name)
{
BNComponentSetName
(m_object, name.
c_str
());
}
Ref<Component>
Component::GetParent
()
{
return
new
Component
(
BNComponentGetParent
(m_object));
}
std::string
Component::GetGuid
()
{
char
* result =
BNComponentGetGuid
(m_object);
string stringResult = result;
BNFreeString
(result);
return
stringResult;
}
bool
Component::AddFunction
(Ref<Function> func)
{
return
BNComponentAddFunctionReference
(m_object, func->
GetObject
());
}
bool
Component::AddComponent
(Ref<Component> component)
{
return
BNComponentAddComponent
(m_object, component->
m_object
);
}
bool
Component::AddDataVariable
(DataVariable dataVariable)
{
return
BNComponentAddDataVariable
(m_object, dataVariable.
address
);
}
bool
Component::RemoveComponent
(Ref<Component> component)
{
return
BNComponentRemoveComponent
(component->
m_object
);
}
bool
Component::RemoveFunction
(Ref<Function> func)
{
return
BNComponentRemoveFunctionReference
(m_object, func->
GetObject
());
}
bool
Component::RemoveDataVariable
(DataVariable dataVariable)
{
return
BNComponentRemoveDataVariable
(m_object, dataVariable.
address
);
}
std::vector<Ref<Component>>
Component::GetContainedComponents
()
{
std::vector<Ref<Component>> components;
size_t
count;
BNComponent** list =
BNComponentGetContainedComponents
(m_object, &count);
components.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
Ref<Component> component =
new
Component
(
BNNewComponentReference
(list[i]));
components.
push_back
(component);
}
BNFreeComponents
(list, count);
return
components;
}
std::vector<Ref<Function>>
Component::GetContainedFunctions
()
{
std::vector<Ref<Function>> functions;
size_t
count;
BNFunction** list =
BNComponentGetContainedFunctions
(m_object, &count);
functions.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
Ref<Function> function =
new
Function
(
BNNewFunctionReference
(list[i]));
functions.
push_back
(function);
}
BNFreeFunctionList
(list, count);
return
functions;
}
std::vector<DataVariable>
Component::GetContainedDataVariables
()
{
vector<DataVariable> result;
size_t
count;
BNDataVariable* variables =
BNComponentGetContainedDataVariables
(m_object, &count);
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; ++i)
{
result.
emplace_back
(variables[i].
address
,
Confidence<Ref<Type>>(
new
Type
(
BNNewTypeReference
(variables[i].
type
)), variables[i].
typeConfidence
),
variables[i].
autoDiscovered
);
}
BNFreeDataVariables
(variables, count);
return
result;
}
std::vector<Ref<Type>>
Component::GetReferencedTypes
()
{
std::vector<Ref<Type>> types;
size_t
count;
BNType** list =
BNComponentGetReferencedTypes
(m_object, &count);
types.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
Ref<Type> type =
new
Type
(
BNNewTypeReference
(list[i]));
types.
push_back
(type);
}
BNComponentFreeReferencedTypes
(list, count);
return
types;
}
std::vector<DataVariable>
Component::GetReferencedDataVariables
()
{
vector<DataVariable> result;
size_t
count;
BNDataVariable* variables =
BNComponentGetReferencedDataVariables
(m_object, &count);
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; ++i)
{
result.
emplace_back
(variables[i].
address
,
Confidence<Ref<Type>>(
new
Type
(
BNNewTypeReference
(variables[i].
type
)), variables[i].
typeConfidence
),
variables[i].
autoDiscovered
);
}
BNFreeDataVariables
(variables, count);
return
result;
}
Back
|
FazBrowse Home
|
New Git URL