FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
binaryninja-api/basicblock.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
/
basicblock.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
779 lines (591 loc) · 18 KB
Breadcrumbs
binaryninja-api
/
basicblock.cpp
Copy path
File metadata and controls
779 lines (591 loc) · 18 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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
//
Copyright (c) 2015-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
"
#
include
"
ffi.h
"
using
namespace
BinaryNinja
;
using
namespace
std
;
DisassemblySettings::DisassemblySettings
()
{
m_object =
BNCreateDisassemblySettings
();
}
DisassemblySettings::DisassemblySettings
(BNDisassemblySettings* settings)
{
m_object = settings;
}
Ref<DisassemblySettings>
DisassemblySettings::GetDefaultSettings
()
{
return
new
DisassemblySettings
(
BNDefaultDisassemblySettings
());
}
Ref<DisassemblySettings>
DisassemblySettings::GetDefaultGraphSettings
()
{
return
new
DisassemblySettings
(
BNDefaultGraphDisassemblySettings
());
}
Ref<DisassemblySettings>
DisassemblySettings::GetDefaultLinearSettings
()
{
return
new
DisassemblySettings
(
BNDefaultLinearDisassemblySettings
());
}
DisassemblySettings*
DisassemblySettings::Duplicate
()
{
return
new
DisassemblySettings
(
BNDuplicateDisassemblySettings
(m_object));
}
bool
DisassemblySettings::IsOptionSet
(BNDisassemblyOption option)
const
{
return
BNIsDisassemblySettingsOptionSet
(m_object, option);
}
void
DisassemblySettings::SetOption
(BNDisassemblyOption option,
bool
state)
{
BNSetDisassemblySettingsOption
(m_object, option, state);
}
size_t
DisassemblySettings::GetWidth
()
const
{
return
BNGetDisassemblyWidth
(m_object);
}
void
DisassemblySettings::SetWidth
(
size_t
width)
{
BNSetDisassemblyWidth
(m_object, width);
}
size_t
DisassemblySettings::GetMaximumSymbolWidth
()
const
{
return
BNGetDisassemblyMaximumSymbolWidth
(m_object);
}
void
DisassemblySettings::SetMaximumSymbolWidth
(
size_t
width)
{
BNSetDisassemblyMaximumSymbolWidth
(m_object, width);
}
size_t
DisassemblySettings::GetGutterWidth
()
const
{
return
BNGetDisassemblyGutterWidth
(m_object);
}
void
DisassemblySettings::SetGutterWidth
(
size_t
width)
{
BNSetDisassemblyGutterWidth
(m_object, width);
}
BNDisassemblyAddressMode
DisassemblySettings::GetAddressMode
()
const
{
return
BNGetDisassemblyAddressMode
(m_object);
}
void
DisassemblySettings::SetAddressMode
(BNDisassemblyAddressMode mode)
{
BNSetDisassemblyAddressMode
(m_object, mode);
}
uint64_t
DisassemblySettings::GetAddressBaseOffset
()
const
{
return
BNGetDisassemblyAddressBaseOffset
(m_object);
}
void
DisassemblySettings::SetAddressBaseOffset
(
uint64_t
addressBaseOffset)
{
BNSetDisassemblyAddressBaseOffset
(m_object, addressBaseOffset);
}
BNDisassemblyCallParameterHints
DisassemblySettings::GetCallParameterHints
()
const
{
return
BNGetDisassemblyCallParameterHints
(m_object);
}
void
DisassemblySettings::SetCallParameterHints
(BNDisassemblyCallParameterHints hints)
{
BNSetDisassemblyCallParameterHints
(m_object, hints);
}
BNDisassemblyBlockLabels
DisassemblySettings::GetBlockLabels
()
const
{
return
BNGetDisassemblyBlockLabels
(m_object);
}
void
DisassemblySettings::SetBlockLabels
(BNDisassemblyBlockLabels labels)
{
BNSetDisassemblyBlockLabels
(m_object, labels);
}
BNDisassemblyTextLineTypeInfo
DisassemblyTextLineTypeInfo::GetAPIObject
()
const
{
BNDisassemblyTextLineTypeInfo result;
result.
hasTypeInfo
=
this
->
hasTypeInfo
;
result.
parentType
=
this
->
parentType
?
BNNewTypeReference
(
this
->
parentType
->
GetObject
()) :
nullptr
;
result.
fieldIndex
=
this
->
fieldIndex
;
result.
offset
=
this
->
offset
;
return
result;
}
void
DisassemblyTextLineTypeInfo::FreeAPIObject
(BNDisassemblyTextLineTypeInfo *value)
{
BNFreeType
(value->
parentType
);
}
DisassemblyTextLineTypeInfo
DisassemblyTextLineTypeInfo::FromAPIObject
(
const
BNDisassemblyTextLineTypeInfo *value)
{
DisassemblyTextLineTypeInfo result;
result.
hasTypeInfo
= value->
hasTypeInfo
;
result.
fieldIndex
= value->
fieldIndex
;
result.
parentType
= value->
parentType
?
new
Type
(
BNNewTypeReference
(value->
parentType
)) :
nullptr
;
result.
offset
= value->
offset
;
return
result;
}
DisassemblyTextLine::DisassemblyTextLine
()
{
addr =
0
;
instrIndex =
BN_INVALID_EXPR
;
highlight.
style
= StandardHighlightColor;
highlight.
color
= NoHighlightColor;
highlight.
mixColor
= NoHighlightColor;
highlight.
mix
=
0
;
highlight.
r
=
0
;
highlight.
g
=
0
;
highlight.
b
=
0
;
highlight.
alpha
=
255
;
typeInfo.
hasTypeInfo
=
false
;
typeInfo.
fieldIndex
= -
1
;
typeInfo.
parentType
=
nullptr
;
typeInfo.
offset
=
0
;
}
BNDisassemblyTextLine
DisassemblyTextLine::GetAPIObject
()
const
{
BNDisassemblyTextLine result;
result.
addr
=
this
->
addr
;
result.
instrIndex
=
this
->
instrIndex
;
result.
highlight
=
this
->
highlight
;
result.
tokens
=
InstructionTextToken::CreateInstructionTextTokenList
(
this
->
tokens
);
result.
count
=
this
->
tokens
.
size
();
result.
tags
=
Tag::CreateTagList
(
this
->
tags
, &(result.
tagCount
));
result.
typeInfo
=
this
->
typeInfo
.
GetAPIObject
();
return
result;
}
void
DisassemblyTextLine::FreeAPIObject
(BNDisassemblyTextLine *value)
{
InstructionTextToken::FreeInstructionTextTokenList
(value->
tokens
, value->
count
);
Tag::FreeTagList
(value->
tags
, value->
tagCount
);
DisassemblyTextLineTypeInfo::FreeAPIObject
(&value->
typeInfo
);
}
DisassemblyTextLine
DisassemblyTextLine::FromAPIObject
(
const
BNDisassemblyTextLine *value)
{
DisassemblyTextLine result;
result.
addr
= value->
addr
;
result.
instrIndex
= value->
instrIndex
;
result.
highlight
= value->
highlight
;
result.
tokens
=
InstructionTextToken::ConvertInstructionTextTokenList
(value->
tokens
, value->
count
);
result.
tags
=
Tag::ConvertTagList
(value->
tags
, value->
tagCount
);
result.
typeInfo
=
DisassemblyTextLineTypeInfo::FromAPIObject
(&value->
typeInfo
);
return
result;
}
size_t
DisassemblyTextLine::GetTotalWidth
()
const
{
size_t
result =
0
;
for
(
auto
& i : tokens)
result += i.
width
;
return
result;
}
static
void
FindAddressAndIndentationTokens
(
const
vector<InstructionTextToken>& tokens,
const
std::function<
void
(
const
InstructionTextToken&)>& callback)
{
size_t
startToken =
0
;
for
(
size_t
i =
0
; i < tokens.
size
(); i++)
{
if
(tokens[i].
type
== AddressSeparatorToken)
{
startToken = i +
1
;
break
;
}
}
for
(
size_t
i =
0
; i < startToken; i++)
callback
(tokens[i]);
for
(
size_t
i = startToken; i < tokens.
size
(); i++)
{
if
(tokens[i].
type
== AddressDisplayToken || tokens[i].
type
== AddressSeparatorToken
|| tokens[i].
type
== CollapseStateIndicatorToken)
{
callback
(tokens[i]);
continue
;
}
bool
whitespace =
true
;
for
(
auto
ch : tokens[i].
text
)
{
if
(!
isspace
(ch))
{
whitespace =
false
;
break
;
}
}
if
(!whitespace)
break
;
callback
(tokens[i]);
}
}
size_t
DisassemblyTextLine::GetAddressAndIndentationWidth
()
const
{
size_t
result =
0
;
FindAddressAndIndentationTokens
(tokens, [&](
const
InstructionTextToken& token) { result += token.
width
; });
return
result;
}
vector<InstructionTextToken>
DisassemblyTextLine::GetAddressAndIndentationTokens
()
const
{
vector<InstructionTextToken> result;
FindAddressAndIndentationTokens
(tokens, [&](
const
InstructionTextToken& token) { result.
push_back
(token); });
return
result;
}
BasicBlock::BasicBlock
(BNBasicBlock* block)
{
m_object = block;
}
Ref<Function>
BasicBlock::GetFunction
()
const
{
return
new
Function
(
BNGetBasicBlockFunction
(m_object));
}
Ref<Architecture>
BasicBlock::GetArchitecture
()
const
{
return
new
CoreArchitecture
(
BNGetBasicBlockArchitecture
(m_object));
}
uint64_t
BasicBlock::GetStart
()
const
{
return
BNGetBasicBlockStart
(m_object);
}
void
BasicBlock::SetEnd
(
uint64_t
end)
{
BNSetBasicBlockEnd
(m_object, end);
}
uint64_t
BasicBlock::GetEnd
()
const
{
return
BNGetBasicBlockEnd
(m_object);
}
uint64_t
BasicBlock::GetLength
()
const
{
return
BNGetBasicBlockLength
(m_object);
}
size_t
BasicBlock::GetIndex
()
const
{
return
BNGetBasicBlockIndex
(m_object);
}
vector<BasicBlockEdge>
BasicBlock::GetOutgoingEdges
()
const
{
size_t
count;
BNBasicBlockEdge* array =
BNGetBasicBlockOutgoingEdges
(m_object, &count);
vector<BasicBlockEdge> result;
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
BasicBlockEdge edge;
edge.
type
= array[i].
type
;
edge.
target
= array[i].
target
?
new
BasicBlock
(
BNNewBasicBlockReference
(array[i].
target
)) :
nullptr
;
edge.
backEdge
= array[i].
backEdge
;
edge.
fallThrough
= array[i].
fallThrough
;
result.
push_back
(edge);
}
BNFreeBasicBlockEdgeList
(array, count);
return
result;
}
vector<BasicBlockEdge>
BasicBlock::GetIncomingEdges
()
const
{
size_t
count;
BNBasicBlockEdge* array =
BNGetBasicBlockIncomingEdges
(m_object, &count);
vector<BasicBlockEdge> result;
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
BasicBlockEdge edge;
edge.
type
= array[i].
type
;
edge.
target
= array[i].
target
?
new
BasicBlock
(
BNNewBasicBlockReference
(array[i].
target
)) :
nullptr
;
edge.
backEdge
= array[i].
backEdge
;
edge.
fallThrough
= array[i].
fallThrough
;
result.
push_back
(edge);
}
BNFreeBasicBlockEdgeList
(array, count);
return
result;
}
bool
BasicBlock::HasUndeterminedOutgoingEdges
()
const
{
return
BNBasicBlockHasUndeterminedOutgoingEdges
(m_object);
}
bool
BasicBlock::HasInvalidInstructions
()
const
{
return
BNBasicBlockHasInvalidInstructions
(m_object);
}
void
BasicBlock::SetHasInvalidInstructions
(
bool
value)
{
BNBasicBlockSetHasInvalidInstructions
(m_object, value);
}
void
BasicBlock::AddPendingOutgoingEdge
(BNBranchType type,
uint64_t
addr, Ref<Architecture> arch,
bool
fallThrough)
{
BNBasicBlockAddPendingOutgoingEdge
(m_object, type, addr, arch ? arch->
GetObject
() :
nullptr
, fallThrough);
}
vector<PendingBasicBlockEdge>
BasicBlock::GetPendingOutgoingEdges
()
const
{
size_t
count;
BNPendingBasicBlockEdge* edges =
BNGetBasicBlockPendingOutgoingEdges
(m_object, &count);
vector<PendingBasicBlockEdge> result;
result.
reserve
(count);
for
(
size_t
i =
0
; i < count; i++)
{
PendingBasicBlockEdge edge;
edge.
type
= edges[i].
type
;
edge.
arch
= edges[i].
arch
?
new
CoreArchitecture
(edges[i].
arch
) :
nullptr
;
edge.
target
= edges[i].
target
;
edge.
fallThrough
= edges[i].
fallThrough
;
result.
push_back
(edge);
}
BNFreePendingBasicBlockEdgeList
(edges);
return
result;
}
void
BasicBlock::ClearPendingOutgoingEdges
()
{
BNClearBasicBlockPendingOutgoingEdges
(m_object);
}
void
BasicBlock::SetUndeterminedOutgoingEdges
(
bool
value)
{
BNBasicBlockSetUndeterminedOutgoingEdges
(m_object, value);
}
void
BasicBlock::SetFallThroughToFunction
(
bool
value)
{
BNBasicBlockSetFallThroughToFunction
(m_object, value);
}
bool
BasicBlock::IsFallThroughToFunction
()
const
{
return
BNBasicBlockIsFallThroughToFunction
(m_object);
}
bool
BasicBlock::CanExit
()
const
{
return
BNBasicBlockCanExit
(m_object);
}
void
BasicBlock::SetCanExit
(
bool
value)
{
BNBasicBlockSetCanExit
(m_object, value);
}
set<Ref<BasicBlock>>
BasicBlock::GetDominators
(
bool
post
)
const
{
size_t
count;
BNBasicBlock** blocks =
BNGetBasicBlockDominators
(m_object, &count,
post
);
set<Ref<BasicBlock>> result;
for
(
size_t
i =
0
; i < count; i++)
result.
insert
(
new
BasicBlock
(
BNNewBasicBlockReference
(blocks[i])));
BNFreeBasicBlockList
(blocks, count);
return
result;
}
set<Ref<BasicBlock>>
BasicBlock::GetStrictDominators
(
bool
post
)
const
{
size_t
count;
BNBasicBlock** blocks =
BNGetBasicBlockStrictDominators
(m_object, &count,
post
);
set<Ref<BasicBlock>> result;
for
(
size_t
i =
0
; i < count; i++)
result.
insert
(
new
BasicBlock
(
BNNewBasicBlockReference
(blocks[i])));
BNFreeBasicBlockList
(blocks, count);
return
result;
}
Ref<BasicBlock>
BasicBlock::GetImmediateDominator
(
bool
post
)
const
{
BNBasicBlock* result =
BNGetBasicBlockImmediateDominator
(m_object,
post
);
if
(!result)
return
nullptr
;
return
new
BasicBlock
(result);
}
set<Ref<BasicBlock>>
BasicBlock::GetDominatorTreeChildren
(
bool
post
)
const
{
size_t
count;
BNBasicBlock** blocks =
BNGetBasicBlockDominatorTreeChildren
(m_object, &count,
post
);
set<Ref<BasicBlock>> result;
for
(
size_t
i =
0
; i < count; i++)
result.
insert
(
new
BasicBlock
(
BNNewBasicBlockReference
(blocks[i])));
BNFreeBasicBlockList
(blocks, count);
return
result;
}
set<Ref<BasicBlock>>
BasicBlock::GetDominanceFrontier
(
bool
post
)
const
{
size_t
count;
BNBasicBlock** blocks =
BNGetBasicBlockDominanceFrontier
(m_object, &count,
post
);
set<Ref<BasicBlock>> result;
for
(
size_t
i =
0
; i < count; i++)
result.
insert
(
new
BasicBlock
(
BNNewBasicBlockReference
(blocks[i])));
BNFreeBasicBlockList
(blocks, count);
return
result;
}
set<Ref<BasicBlock>>
BasicBlock::GetIteratedDominanceFrontier
(
const
set<Ref<BasicBlock>>& blocks)
{
BNBasicBlock** blockSet =
new
BNBasicBlock*[blocks.
size
()];
size_t
i =
0
;
for
(
auto
& j : blocks)
blockSet[i++] = j->
GetObject
();
size_t
count;
BNBasicBlock** resultBlocks =
BNGetBasicBlockIteratedDominanceFrontier
(blockSet, blocks.
size
(), &count);
delete[]
blockSet;
set<Ref<BasicBlock>> result;
for
(
size_t
k =
0
; k < count; k++)
result.
insert
(
new
BasicBlock
(
BNNewBasicBlockReference
(resultBlocks[k])));
BNFreeBasicBlockList
(resultBlocks, count);
return
result;
}
void
BasicBlock::MarkRecentUse
()
{
BNMarkBasicBlockAsRecentlyUsed
(m_object);
}
vector<vector<InstructionTextToken>>
BasicBlock::GetAnnotations
()
{
return
GetFunction
()->
GetBlockAnnotations
(
GetArchitecture
(),
GetStart
());
}
std::optional<
int64_t
>
BasicBlock::GetSortHint
()
{
return
GetFunction
()->
GetBlockSortHint
(
GetArchitecture
(),
GetStart
());
}
vector<DisassemblyTextLine>
BasicBlock::GetDisassemblyText
(DisassemblySettings* settings)
{
size_t
count;
BNDisassemblyTextLine* lines =
BNGetBasicBlockDisassemblyText
(m_object, settings->
GetObject
(), &count);
vector<DisassemblyTextLine> result = ParseAPIObjectList<DisassemblyTextLine>(lines, count);;
BNFreeDisassemblyTextLines
(lines, count);
return
result;
}
BNHighlightColor
BasicBlock::GetBasicBlockHighlight
()
{
return
BNGetBasicBlockHighlight
(m_object);
}
void
BasicBlock::SetAutoBasicBlockHighlight
(BNHighlightColor color)
{
BNSetAutoBasicBlockHighlight
(m_object, color);
}
void
BasicBlock::SetAutoBasicBlockHighlight
(BNHighlightStandardColor color,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= StandardHighlightColor;
hc.
color
= color;
hc.
mixColor
= NoHighlightColor;
hc.
mix
=
0
;
hc.
r
=
0
;
hc.
g
=
0
;
hc.
b
=
0
;
hc.
alpha
= alpha;
SetAutoBasicBlockHighlight
(hc);
}
void
BasicBlock::SetAutoBasicBlockHighlight
(
BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
uint8_t
mix,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= MixedHighlightColor;
hc.
color
= color;
hc.
mixColor
= mixColor;
hc.
mix
= mix;
hc.
r
=
0
;
hc.
g
=
0
;
hc.
b
=
0
;
hc.
alpha
= alpha;
SetAutoBasicBlockHighlight
(hc);
}
void
BasicBlock::SetAutoBasicBlockHighlight
(
uint8_t
r,
uint8_t
g,
uint8_t
b,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= CustomHighlightColor;
hc.
color
= NoHighlightColor;
hc.
mixColor
= NoHighlightColor;
hc.
mix
=
0
;
hc.
r
= r;
hc.
g
= g;
hc.
b
= b;
hc.
alpha
= alpha;
SetAutoBasicBlockHighlight
(hc);
}
void
BasicBlock::SetUserBasicBlockHighlight
(BNHighlightColor color)
{
BNSetUserBasicBlockHighlight
(m_object, color);
}
void
BasicBlock::SetUserBasicBlockHighlight
(BNHighlightStandardColor color,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= StandardHighlightColor;
hc.
color
= color;
hc.
mixColor
= NoHighlightColor;
hc.
mix
=
0
;
hc.
r
=
0
;
hc.
g
=
0
;
hc.
b
=
0
;
hc.
alpha
= alpha;
SetUserBasicBlockHighlight
(hc);
}
void
BasicBlock::SetUserBasicBlockHighlight
(
BNHighlightStandardColor color, BNHighlightStandardColor mixColor,
uint8_t
mix,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= MixedHighlightColor;
hc.
color
= color;
hc.
mixColor
= mixColor;
hc.
mix
= mix;
hc.
r
=
0
;
hc.
g
=
0
;
hc.
b
=
0
;
hc.
alpha
= alpha;
SetUserBasicBlockHighlight
(hc);
}
void
BasicBlock::SetUserBasicBlockHighlight
(
uint8_t
r,
uint8_t
g,
uint8_t
b,
uint8_t
alpha)
{
BNHighlightColor hc;
hc.
style
= CustomHighlightColor;
hc.
color
= NoHighlightColor;
hc.
mixColor
= NoHighlightColor;
hc.
mix
=
0
;
hc.
r
= r;
hc.
g
= g;
hc.
b
= b;
hc.
alpha
= alpha;
SetUserBasicBlockHighlight
(hc);
}
bool
BasicBlock::IsBackEdge
(BasicBlock* source, BasicBlock* target)
{
for
(
auto
& i : source->
GetOutgoingEdges
())
{
if
(i.
target
->
GetObject
() == target->
GetObject
())
return
i.
backEdge
;
}
return
false
;
}
bool
BasicBlock::IsILBlock
()
const
{
return
BNIsILBasicBlock
(m_object);
}
bool
BasicBlock::IsLowLevelILBlock
()
const
{
return
BNIsLowLevelILBasicBlock
(m_object);
}
bool
BasicBlock::IsMediumLevelILBlock
()
const
{
return
BNIsMediumLevelILBasicBlock
(m_object);
}
bool
BasicBlock::IsHighLevelILBlock
()
const
{
return
BNIsHighLevelILBasicBlock
(m_object);
}
Ref<LowLevelILFunction>
BasicBlock::GetLowLevelILFunction
()
const
{
BNLowLevelILFunction* func =
BNGetBasicBlockLowLevelILFunction
(m_object);
if
(!func)
return
nullptr
;
return
new
LowLevelILFunction
(func);
}
Ref<MediumLevelILFunction>
BasicBlock::GetMediumLevelILFunction
()
const
{
BNMediumLevelILFunction* func =
BNGetBasicBlockMediumLevelILFunction
(m_object);
if
(!func)
return
nullptr
;
return
new
MediumLevelILFunction
(func);
}
Ref<HighLevelILFunction>
BasicBlock::GetHighLevelILFunction
()
const
{
BNHighLevelILFunction* func =
BNGetBasicBlockHighLevelILFunction
(m_object);
if
(!func)
return
nullptr
;
return
new
HighLevelILFunction
(func);
}
bool
BasicBlock::GetInstructionContainingAddress
(
uint64_t
addr,
uint64_t
* start)
{
return
BNGetBasicBlockInstructionContainingAddress
(m_object, addr, start);
}
Ref<BasicBlock>
BasicBlock::GetSourceBlock
()
const
{
BNBasicBlock* block =
BNGetBasicBlockSourceBlock
(m_object);
if
(!block)
return
nullptr
;
return
new
BasicBlock
(block);
}
Back
|
FazBrowse Home
|
New Git URL