FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
binaryninja-api/linearviewobject.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
35
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
/
linearviewobject.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
389 lines (293 loc) · 12.7 KB
Breadcrumbs
binaryninja-api
/
linearviewobject.cpp
Copy path
File metadata and controls
389 lines (293 loc) · 12.7 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
//
Copyright (c) 2020-2026 Vector 35 Inc
//
//
Permission is hereby granted, free of charge, to any person obtaining a copy
//
of this software and associated documentation files (the "Software"), to
//
deal in the Software without restriction, including without limitation the
//
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//
sell copies of the Software, and to permit persons to whom the Software is
//
furnished to do so, subject to the following conditions:
//
//
The above copyright notice and this permission notice shall be included in
//
all copies or substantial portions of the Software.
//
//
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//
IN THE SOFTWARE.
#
include
"
binaryninjaapi.h
"
using
namespace
std
;
using
namespace
BinaryNinja
;
BNLinearDisassemblyLine
LinearDisassemblyLine::GetAPIObject
()
const
{
BNLinearDisassemblyLine result;
result.
type
=
this
->
type
;
Ref<BinaryView> binaryView =
this
->
view
;
if
(!binaryView &&
this
->
function
)
binaryView =
this
->
function
->
GetView
();
result.
view
= binaryView ?
BNNewViewReference
(binaryView->
GetObject
()) :
nullptr
;
result.
function
=
this
->
function
?
BNNewFunctionReference
(
this
->
function
->
GetObject
()) :
nullptr
;
result.
block
=
this
->
block
?
BNNewBasicBlockReference
(
this
->
block
->
GetObject
()) :
nullptr
;
result.
contents
=
this
->
contents
.
GetAPIObject
();
return
result;
}
LinearDisassemblyLine
LinearDisassemblyLine::FromAPIObject
(
const
BNLinearDisassemblyLine* line)
{
LinearDisassemblyLine result;
result.
type
= line->
type
;
result.
view
= line->
view
?
new
BinaryView
(
BNNewViewReference
(line->
view
)) :
nullptr
;
result.
function
= line->
function
?
new
Function
(
BNNewFunctionReference
(line->
function
)) :
nullptr
;
result.
block
= line->
block
?
new
BasicBlock
(
BNNewBasicBlockReference
(line->
block
)) :
nullptr
;
result.
contents
=
DisassemblyTextLine::FromAPIObject
(&line->
contents
);
return
result;
}
void
LinearDisassemblyLine::FreeAPIObject
(BNLinearDisassemblyLine* line)
{
if
(line->
view
)
BNFreeBinaryView
(line->
view
);
if
(line->
function
)
BNFreeFunction
(line->
function
);
if
(line->
block
)
BNFreeBasicBlock
(line->
block
);
DisassemblyTextLine::FreeAPIObject
(&line->
contents
);
}
LinearViewObjectIdentifier::LinearViewObjectIdentifier
() : type(SingleLinearViewObject), start(
0
), end(
0
) {}
LinearViewObjectIdentifier::LinearViewObjectIdentifier
(
const
string& _name) :
name(_name), type(SingleLinearViewObject), start(
0
), end(
0
)
{}
LinearViewObjectIdentifier::LinearViewObjectIdentifier
(
const
string& _name,
uint64_t
addr) :
name(_name), type(AddressLinearViewObject), start(addr), end(addr)
{}
LinearViewObjectIdentifier::LinearViewObjectIdentifier
(
const
string& _name,
uint64_t
_start,
uint64_t
_end) :
name(_name), type(AddressRangeLinearViewObject), start(_start), end(_end)
{}
LinearViewObjectIdentifier::LinearViewObjectIdentifier
(
const
LinearViewObjectIdentifier& other) :
name(other.name), type(other.type), start(other.start), end(other.end)
{}
LinearViewObject::LinearViewObject
(BNLinearViewObject* obj)
{
m_object = obj;
}
Ref<LinearViewObject>
LinearViewObject::GetFirstChild
()
{
BNLinearViewObject* result =
BNGetFirstLinearViewObjectChild
(m_object);
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::GetLastChild
()
{
BNLinearViewObject* result =
BNGetLastLinearViewObjectChild
(m_object);
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::GetPreviousChild
(LinearViewObject* obj)
{
BNLinearViewObject* result =
BNGetPreviousLinearViewObjectChild
(m_object, obj->
GetObject
());
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::GetNextChild
(LinearViewObject* obj)
{
BNLinearViewObject* result =
BNGetNextLinearViewObjectChild
(m_object, obj->
GetObject
());
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::GetChildForAddress
(
uint64_t
addr)
{
BNLinearViewObject* result =
BNGetLinearViewObjectChildForAddress
(m_object, addr);
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::GetChildForIdentifier
(
const
LinearViewObjectIdentifier& id)
{
BNLinearViewObjectIdentifier lvid;
lvid.
name
=
BNAllocString
(id.
name
.
c_str
());
lvid.
type
= id.
type
;
lvid.
start
= id.
start
;
lvid.
end
= id.
end
;
BNLinearViewObject* result =
BNGetLinearViewObjectChildForIdentifier
(m_object, &lvid);
BNFreeString
(lvid.
name
);
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
int
LinearViewObject::CompareChildren
(LinearViewObject* a, LinearViewObject* b)
{
return
BNCompareLinearViewObjectChildren
(m_object, a->
GetObject
(), b->
GetObject
());
}
vector<LinearDisassemblyLine>
LinearViewObject::GetLines
(LinearViewObject* prev, LinearViewObject* next)
{
size_t
count;
BNLinearDisassemblyLine* lines =
BNGetLinearViewObjectLines
(
m_object, prev ? prev->
GetObject
() :
nullptr
, next ? next->
GetObject
() :
nullptr
, &count);
vector<LinearDisassemblyLine> result;
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
result.
push_back
(
LinearDisassemblyLine::FromAPIObject
(&lines[i]));
BNFreeLinearDisassemblyLines
(lines, count);
return
result;
}
uint64_t
LinearViewObject::GetStart
()
const
{
return
BNGetLinearViewObjectStart
(m_object);
}
uint64_t
LinearViewObject::GetEnd
()
const
{
return
BNGetLinearViewObjectEnd
(m_object);
}
LinearViewObjectIdentifier
LinearViewObject::GetIdentifier
()
const
{
BNLinearViewObjectIdentifier id =
BNGetLinearViewObjectIdentifier
(m_object);
LinearViewObjectIdentifier result;
result.
name
= id.
name
;
result.
type
= id.
type
;
result.
start
= id.
start
;
result.
end
= id.
end
;
BNFreeLinearViewObjectIdentifier
(&id);
return
result;
}
uint64_t
LinearViewObject::GetOrderingIndexTotal
()
const
{
return
BNGetLinearViewObjectOrderingIndexTotal
(m_object);
}
uint64_t
LinearViewObject::GetOrderingIndexForChild
(LinearViewObject* obj)
const
{
return
BNGetLinearViewObjectOrderingIndexForChild
(m_object, obj->
GetObject
());
}
Ref<LinearViewObject>
LinearViewObject::GetChildForOrderingIndex
(
uint64_t
idx)
{
BNLinearViewObject* result =
BNGetLinearViewObjectChildForOrderingIndex
(m_object, idx);
if
(result)
return
new
LinearViewObject
(result);
return
nullptr
;
}
Ref<LinearViewObject>
LinearViewObject::CreateDisassembly
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewDisassembly
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateLiftedIL
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewLiftedIL
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateLowLevelIL
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewLowLevelIL
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateLowLevelILSSAForm
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewLowLevelILSSAForm
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateMediumLevelIL
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewMediumLevelIL
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateMediumLevelILSSAForm
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewMediumLevelILSSAForm
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateMappedMediumLevelIL
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewMappedMediumLevelIL
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateMappedMediumLevelILSSAForm
(
BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewMappedMediumLevelILSSAForm
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateHighLevelIL
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewHighLevelIL
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateHighLevelILSSAForm
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewHighLevelILSSAForm
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateLanguageRepresentation
(BinaryView* view, DisassemblySettings* settings,
const
string& language)
{
return
new
LinearViewObject
(
BNCreateLinearViewLanguageRepresentation
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
, language.
c_str
()));
}
Ref<LinearViewObject>
LinearViewObject::CreateDataOnly
(BinaryView* view, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewDataOnly
(view->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionDisassembly
(Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionDisassembly
(func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionLiftedIL
(Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionLiftedIL
(func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionLowLevelIL
(Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionLowLevelIL
(func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionLowLevelILSSAForm
(
Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionLowLevelILSSAForm
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionMediumLevelIL
(Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionMediumLevelIL
(func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionMediumLevelILSSAForm
(
Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionMediumLevelILSSAForm
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionMappedMediumLevelIL
(
Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionMappedMediumLevelIL
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionMappedMediumLevelILSSAForm
(
Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionMappedMediumLevelILSSAForm
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionHighLevelIL
(Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionHighLevelIL
(func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionHighLevelILSSAForm
(
Function* func, DisassemblySettings* settings)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionHighLevelILSSAForm
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
));
}
Ref<LinearViewObject>
LinearViewObject::CreateSingleFunctionLanguageRepresentation
(
Function* func, DisassemblySettings* settings,
const
string& language)
{
return
new
LinearViewObject
(
BNCreateLinearViewSingleFunctionLanguageRepresentation
(
func->
GetObject
(), settings ? settings->
GetObject
() :
nullptr
, language.
c_str
()));
}
Back
|
FazBrowse Home
|
New Git URL