FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
binaryninja-api/python/types.py at dev · Vector35/binaryninja-api · GitHub
binaryninja-api/python/types.py at dev · Vector35/binaryninja-api · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
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
36
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
/
python
/
types.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
3972 lines (3376 loc) · 148 KB
Breadcrumbs
binaryninja-api
/
python
/
types.py
Copy path
File metadata and controls
3972 lines (3376 loc) · 148 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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# 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.
import
ctypes
import
typing
from
typing
import
Generator
,
List
,
Union
,
Tuple
,
Optional
,
Iterable
,
Dict
,
Generic
,
TypeVar
,
Callable
,
overload
from
dataclasses
import
dataclass
import
uuid
# Binary Ninja components
from
.
import
_binaryninjacore
as
core
from
.
enums
import
(
InlineDuringAnalysis
,
StructureVariant
,
SymbolType
,
SymbolBinding
,
TypeClass
,
NamedTypeReferenceClass
,
ReferenceType
,
VariableSourceType
,
ValueLocationSource
,
TypeReferenceType
,
MemberAccess
,
MemberScope
,
TypeDefinitionLineType
,
TokenEscapingType
,
NameType
,
PointerSuffix
,
PointerBaseType
,
Endianness
,
IntegerDisplayType
)
from
.
import
callingconvention
from
.
import
function
as
_function
from
.
import
variable
from
.
import
architecture
from
.
import
binaryview
from
.
import
function
from
.
import
platform
as
_platform
from
.
import
typecontainer
from
.
import
typelibrary
from
.
import
typeparser
QualifiedNameType
=
Union
[
Iterable
[
Union
[
str
,
bytes
]],
str
,
'QualifiedName'
]
BoolWithConfidenceType
=
Union
[
bool
,
'BoolWithConfidence'
]
OffsetWithConfidenceType
=
Union
[
int
,
'OffsetWithConfidence'
]
ParamsType
=
Union
[
List
[
'Type'
],
List
[
'FunctionParameter'
],
List
[
Tuple
[
str
,
'Type'
]]]
MembersType
=
Union
[
List
[
'StructureMember'
],
List
[
'Type'
],
List
[
Tuple
[
'Type'
,
str
]]]
EnumMembersType
=
Union
[
List
[
Tuple
[
str
,
int
]],
List
[
str
],
List
[
'EnumerationMember'
]]
SomeType
=
Union
[
'TypeBuilder'
,
'Type'
]
ReturnValueOrType
=
Union
[
'TypeBuilder'
,
'Type'
,
'ReturnValue'
]
TypeContainerType
=
Union
[
'binaryview.BinaryView'
,
'typelibrary.TypeLibrary'
]
NameSpaceType
=
Optional
[
Union
[
str
,
List
[
str
],
'NameSpace'
]]
TypeParserResult
=
typeparser
.
TypeParserResult
BasicTypeParserResult
=
typeparser
.
BasicTypeParserResult
ResolveMemberCallback
=
Callable
[[
'NamedTypeReferenceType'
,
'StructureType'
,
int
,
int
,
int
,
'StructureMember'
],
None
]
OptionalLocation
=
Optional
[
Union
[
'ValueLocation'
,
'ValueLocationWithConfidence'
,
'variable.CoreVariable'
]]
# The following are needed to prevent the type checker from getting
# confused as we have member functions in `Type` named the same thing
_int
=
int
_bool
=
bool
MemberName
=
str
MemberIndex
=
int
MemberOffset
=
int
TB
=
TypeVar
(
'TB'
,
bound
=
'TypeBuilder'
)
def
convert_integer
(
value
:
ctypes
.
c_uint64
,
signed
:
bool
,
width
:
int
)
->
int
:
if
width
not
in
[
1
,
2
,
4
,
8
]:
raise
ValueError
(
"Width must be 1, 2, 4, or 8 bytes"
)
func
=
{
True
: {
1
:
ctypes
.
c_int8
,
2
:
ctypes
.
c_int16
,
4
:
ctypes
.
c_int32
,
8
:
ctypes
.
c_int64
},
False
: {
1
:
ctypes
.
c_uint8
,
2
:
ctypes
.
c_uint16
,
4
:
ctypes
.
c_uint32
,
8
:
ctypes
.
c_uint64
}
}
return
func
[
bool
(
signed
)][
width
](
value
).
value
class
QualifiedName
:
def
__init__
(
self
,
name
:
Optional
[
QualifiedNameType
]
=
None
,
join
:
str
=
"::"
):
self
.
_name
:
List
[
str
]
=
[]
if
isinstance
(
name
,
str
):
self
.
_name
=
[
name
]
elif
isinstance
(
name
,
bytes
):
self
.
_name
=
[
name
.
decode
(
"utf-8"
)]
elif
isinstance
(
name
,
self
.
__class__
):
self
.
_name
=
name
.
_name
elif
isinstance
(
name
, (
list
,
tuple
)):
for
i
in
name
:
if
isinstance
(
i
,
bytes
):
self
.
_name
.
append
(
i
.
decode
(
"utf-8"
))
else
:
self
.
_name
.
append
(
str
(
i
))
self
.
_join
=
join
def
__str__
(
self
):
return
self
.
join
.
join
(
self
.
name
)
def
__repr__
(
self
):
return
repr
(
str
(
self
))
def
__len__
(
self
):
return
len
(
self
.
name
)
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
str
):
return
str
(
self
)
==
other
elif
isinstance
(
other
,
list
):
return
self
.
name
==
other
elif
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
==
other
.
name
and
self
.
join
==
other
.
join
return
NotImplemented
def
__ne__
(
self
,
other
):
if
isinstance
(
other
,
str
):
return
str
(
self
)
!=
other
elif
isinstance
(
other
,
list
):
return
self
.
name
!=
other
elif
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
!=
other
.
name
return
NotImplemented
def
__lt__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
<
other
.
name
return
NotImplemented
def
__le__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
<=
other
.
name
return
NotImplemented
def
__gt__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
>
other
.
name
return
NotImplemented
def
__ge__
(
self
,
other
):
if
isinstance
(
other
,
self
.
__class__
):
return
self
.
name
>=
other
.
name
return
NotImplemented
def
__hash__
(
self
):
return
hash
(
str
(
self
))
def
__getitem__
(
self
,
key
):
return
self
.
name
[
key
]
def
__iter__
(
self
):
return
iter
(
self
.
name
)
def
_to_core_struct
(
self
)
->
core
.
BNQualifiedName
:
result
=
core
.
BNQualifiedName
()
name_list
=
(
ctypes
.
c_char_p
*
len
(
self
.
name
))()
for
i
in
range
(
0
,
len
(
self
.
name
)):
name_list
[
i
]
=
self
.
name
[
i
].
encode
(
"utf-8"
)
result
.
name
=
name_list
result
.
nameCount
=
len
(
self
.
name
)
result
.
join
=
self
.
join
return
result
@
staticmethod
def
_from_core_struct
(
name
):
result
=
[]
for
i
in
range
(
0
,
name
.
nameCount
):
result
.
append
(
name
.
name
[
i
].
decode
(
"utf-8"
))
return
QualifiedName
(
result
,
name
.
join
)
@
property
def
name
(
self
)
->
List
[
str
]:
return
self
.
_name
@
name
.
setter
def
name
(
self
,
value
:
List
[
str
])
->
None
:
self
.
_name
=
value
@
property
def
join
(
self
)
->
str
:
return
self
.
_join
@
join
.
setter
def
join
(
self
,
value
:
str
)
->
None
:
self
.
_join
=
value
@
staticmethod
def
escape
(
name
:
QualifiedNameType
,
escaping
:
TokenEscapingType
)
->
str
:
return
core
.
BNEscapeTypeName
(
str
(
QualifiedName
(
name
)),
escaping
)
@
staticmethod
def
unescape
(
name
:
QualifiedNameType
,
escaping
:
TokenEscapingType
)
->
str
:
return
core
.
BNUnescapeTypeName
(
str
(
QualifiedName
(
name
)),
escaping
)
@
dataclass
(
frozen
=
True
)
class
TypeReferenceSource
:
name
:
QualifiedName
offset
:
int
ref_type
:
TypeReferenceType
def
__repr__
(
self
):
if
self
.
ref_type
==
TypeReferenceType
.
DirectTypeReferenceType
:
s
=
'direct'
elif
self
.
ref_type
==
TypeReferenceType
.
IndirectTypeReferenceType
:
s
=
'indirect'
else
:
s
=
'unknown'
return
'<type %s, offset 0x%x, %s>'
%
(
self
.
name
,
self
.
offset
,
s
)
class
NameSpace
(
QualifiedName
):
def
_to_core_struct
(
self
)
->
core
.
BNNameSpace
:
result
=
core
.
BNNameSpace
()
name_list
=
(
ctypes
.
c_char_p
*
len
(
self
.
name
))()
for
i
in
range
(
0
,
len
(
self
.
name
)):
name_list
[
i
]
=
self
.
name
[
i
].
encode
(
'utf-8'
)
result
.
name
=
name_list
result
.
nameCount
=
len
(
self
.
name
)
result
.
join
=
self
.
join
return
result
@
staticmethod
def
_from_core_struct
(
name
:
core
.
BNNameSpace
)
->
'NameSpace'
:
result
=
[]
for
i
in
range
(
0
,
name
.
nameCount
):
result
.
append
(
name
.
name
[
i
].
decode
(
"utf-8"
))
return
NameSpace
(
result
,
name
.
join
)
@
staticmethod
def
get_core_struct
(
name
:
Optional
[
Union
[
str
,
List
[
str
],
'NameSpace'
]])
->
Optional
[
core
.
BNNameSpace
]:
if
name
is
None
:
return
None
if
isinstance
(
name
,
NameSpace
):
return
name
.
_to_core_struct
()
else
:
return
NameSpace
(
name
).
_to_core_struct
()
@
dataclass
(
frozen
=
True
)
class
TypeDefinitionLine
:
line_type
:
TypeDefinitionLineType
tokens
:
List
[
'_function.InstructionTextToken'
]
type
:
'Type'
parent_type
:
'Type'
root_type
:
'Type'
root_type_name
:
str
base_type
:
Optional
[
'NamedTypeReferenceType'
]
base_offset
:
int
offset
:
int
field_index
:
int
def
__str__
(
self
):
return
""
.
join
(
map
(
str
,
self
.
tokens
))
def
__repr__
(
self
):
return
f"<typeDefinitionLine
{
self
.
type
}
:
{
self
}
>"
@
staticmethod
def
_from_core_struct
(
struct
:
core
.
BNTypeDefinitionLine
,
platform
:
Optional
[
_platform
.
Platform
]
=
None
):
tokens
=
_function
.
InstructionTextToken
.
_from_core_struct
(
struct
.
tokens
,
struct
.
count
)
type_
=
Type
.
create
(
handle
=
core
.
BNNewTypeReference
(
struct
.
type
),
platform
=
platform
)
parent_type
=
Type
.
create
(
handle
=
core
.
BNNewTypeReference
(
struct
.
parentType
),
platform
=
platform
)
root_type
=
Type
.
create
(
handle
=
core
.
BNNewTypeReference
(
struct
.
rootType
),
platform
=
platform
)
root_type_name
=
core
.
pyNativeStr
(
struct
.
rootTypeName
)
if
struct
.
baseType
:
const_conf
=
BoolWithConfidence
.
get_core_struct
(
False
,
0
)
volatile_conf
=
BoolWithConfidence
.
get_core_struct
(
False
,
0
)
handle
=
core
.
BNCreateNamedTypeReference
(
struct
.
baseType
,
0
,
1
,
const_conf
,
volatile_conf
)
base_type
=
NamedTypeReferenceType
(
handle
,
platform
)
else
:
base_type
=
None
return
TypeDefinitionLine
(
struct
.
lineType
,
tokens
,
type_
,
parent_type
,
root_type
,
root_type_name
,
base_type
,
struct
.
baseOffset
,
struct
.
offset
,
struct
.
fieldIndex
)
def
_to_core_struct
(
self
):
struct
=
core
.
BNTypeDefinitionLine
()
struct
.
lineType
=
self
.
line_type
struct
.
tokens
=
_function
.
InstructionTextToken
.
_get_core_struct
(
self
.
tokens
)
struct
.
count
=
len
(
self
.
tokens
)
struct
.
type
=
core
.
BNNewTypeReference
(
self
.
type
.
handle
)
struct
.
parentType
=
core
.
BNNewTypeReference
(
self
.
parent_type
.
handle
)
struct
.
rootType
=
core
.
BNNewTypeReference
(
self
.
root_type
.
handle
)
struct
.
rootTypeName
=
self
.
root_type_name
if
self
.
base_type
is
None
:
struct
.
baseType
=
None
else
:
struct
.
baseType
=
core
.
BNNewNamedTypeReference
(
self
.
base_type
.
ntr_handle
)
struct
.
baseOffset
=
self
.
base_offset
struct
.
offset
=
self
.
offset
struct
.
fieldIndex
=
self
.
field_index
return
struct
class
CoreSymbol
:
def
__init__
(
self
,
handle
:
core
.
BNSymbolHandle
):
self
.
_handle
=
handle
def
__del__
(
self
):
if
core
is
not
None
:
core
.
BNFreeSymbol
(
self
.
_handle
)
def
__repr__
(
self
):
try
:
return
f"<
{
self
.
type
.
name
}
:
\"
{
self
.
full_name
}
\"
@
{
self
.
address
:#x
}
>"
except
UnicodeDecodeError
:
return
f"<
{
self
.
type
.
name
}
:
\"
{
self
.
raw_bytes
}
\"
@
{
self
.
address
:#x
}
>"
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
return
NotImplemented
return
ctypes
.
addressof
(
self
.
_handle
.
contents
)
==
ctypes
.
addressof
(
other
.
_handle
.
contents
)
def
__ne__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
return
NotImplemented
return
not
(
self
==
other
)
def
__hash__
(
self
):
return
hash
(
ctypes
.
addressof
(
self
.
_handle
.
contents
))
@
property
def
type
(
self
)
->
SymbolType
:
"""Symbol type (read-only)"""
return
SymbolType
(
core
.
BNGetSymbolType
(
self
.
_handle
))
@
property
def
binding
(
self
)
->
SymbolBinding
:
"""Symbol binding (read-only)"""
return
SymbolBinding
(
core
.
BNGetSymbolBinding
(
self
.
_handle
))
@
property
def
namespace
(
self
)
->
'NameSpace'
:
"""Symbol namespace (read-only)"""
ns
=
core
.
BNGetSymbolNameSpace
(
self
.
_handle
)
result
=
NameSpace
.
_from_core_struct
(
ns
)
core
.
BNFreeNameSpace
(
ns
)
return
result
@
property
def
name
(
self
)
->
str
:
"""Symbol name (read-only)"""
return
core
.
BNGetSymbolRawName
(
self
.
_handle
)
@
property
def
short_name
(
self
)
->
str
:
"""Symbol short name (read-only)"""
return
core
.
BNGetSymbolShortName
(
self
.
_handle
)
@
property
def
full_name
(
self
)
->
str
:
"""Symbol full name (read-only)"""
return
core
.
BNGetSymbolFullName
(
self
.
_handle
)
@
property
def
raw_name
(
self
)
->
str
:
"""Symbol raw name (read-only)"""
return
core
.
BNGetSymbolRawName
(
self
.
_handle
)
@
property
def
raw_bytes
(
self
)
->
bytes
:
"""Bytes of the raw symbol (read-only)"""
count
=
ctypes
.
c_ulonglong
()
result
=
core
.
BNGetSymbolRawBytes
(
self
.
_handle
,
count
)
assert
result
is
not
None
,
"core.BNGetSymbolRawBytes returned None"
buf
=
ctypes
.
create_string_buffer
(
count
.
value
)
ctypes
.
memmove
(
buf
,
result
,
count
.
value
)
core
.
BNFreeSymbolRawBytes
(
result
)
return
buf
.
raw
@
property
def
address
(
self
)
->
int
:
"""Symbol address (read-only)"""
return
core
.
BNGetSymbolAddress
(
self
.
_handle
)
@
property
def
ordinal
(
self
)
->
int
:
"""Symbol ordinal (read-only)"""
return
core
.
BNGetSymbolOrdinal
(
self
.
_handle
)
@
property
def
auto
(
self
)
->
bool
:
"""Whether the symbol was auto-defined"""
return
core
.
BNIsSymbolAutoDefined
(
self
.
_handle
)
@
property
def
handle
(
self
):
return
self
.
_handle
def
imported_function_from_import_address_symbol
(
self
,
addr
:
int
)
->
Optional
[
'CoreSymbol'
]:
sym
=
core
.
BNImportedFunctionFromImportAddressSymbol
(
self
.
_handle
,
addr
)
if
sym
is
None
:
return
None
return
CoreSymbol
(
sym
)
class
Symbol
(
CoreSymbol
):
"""
Symbols are defined as one of the following types:
=========================== =================================================================
SymbolType Description
=========================== =================================================================
FunctionSymbol Symbol for function that exists in the current binary
ImportAddressSymbol Symbol defined in the Import Address Table
ImportedFunctionSymbol Symbol for a function that is not defined in the current binary
DataSymbol Symbol for data in the current binary
ImportedDataSymbol Symbol for data that is not defined in the current binary
ExternalSymbol Symbols for data and code that reside outside the BinaryView
LibraryFunctionSymbol Symbols for functions identified as belonging to a shared library
SymbolicFunctionSymbol Symbols for functions without a concrete implementation or which have been abstractly represented
LocalLabelSymbol Symbol for a local label in the current binary
=========================== =================================================================
"""
def
__init__
(
self
,
sym_type
,
addr
,
short_name
,
full_name
=
None
,
raw_name
=
None
,
binding
=
None
,
namespace
=
None
,
ordinal
=
0
):
if
isinstance
(
sym_type
,
str
):
sym_type
=
SymbolType
[
sym_type
]
if
full_name
is
None
:
full_name
=
short_name
if
raw_name
is
None
:
raw_name
=
full_name
if
binding
is
None
:
binding
=
SymbolBinding
.
NoBinding
_namespace
=
NameSpace
.
get_core_struct
(
namespace
)
_handle
=
core
.
BNCreateSymbol
(
sym_type
,
short_name
,
full_name
,
raw_name
,
addr
,
binding
,
_namespace
,
ordinal
)
assert
_handle
is
not
None
,
"core.BNCreateSymbol return None"
super
().
__init__
(
_handle
)
@
dataclass
class
ValueLocationComponent
:
var
:
'variable.CoreVariable'
offset
:
int
=
0
size
:
Optional
[
int
]
=
None
@
staticmethod
def
_from_core_struct
(
struct
:
core
.
BNValueLocationComponent
,
arch
:
Optional
[
'architecture.Architecture'
]
=
None
):
if
arch
is
None
:
var
=
variable
.
CoreVariable
.
from_BNVariable
(
struct
.
variable
)
else
:
var
=
variable
.
ArchitectureVariable
.
from_BNVariable
(
arch
,
struct
.
variable
)
offset
=
struct
.
offset
size
=
None
if
struct
.
sizeValid
:
size
=
struct
.
size
return
ValueLocationComponent
(
var
,
offset
,
size
)
def
_to_core_struct
(
self
)
->
core
.
BNValueLocationComponent
:
struct
=
core
.
BNValueLocationComponent
()
struct
.
variable
=
self
.
var
.
to_BNVariable
()
struct
.
offset
=
self
.
offset
struct
.
sizeValid
=
self
.
size
is
not
None
if
self
.
size
is
not
None
:
struct
.
size
=
self
.
size
return
struct
def
to_string
(
self
,
arch
:
Optional
[
'architecture.Architecture'
]):
if
arch
is
None
:
if
isinstance
(
self
.
var
,
variable
.
ArchitectureVariable
):
arch
=
self
.
var
.
arch
elif
isinstance
(
self
.
var
,
variable
.
Variable
):
arch
=
self
.
var
.
function
.
arch
if
arch
is
None
:
return
f"
{
repr
(
self
.
var
)
}
offset
{
hex
(
self
.
offset
)
}
size
{
repr
(
self
.
size
)
}
"
struct
=
self
.
_to_core_struct
()
return
core
.
BNValueLocationComponentToString
(
struct
,
arch
.
handle
)
def
__str__
(
self
):
return
self
.
to_string
(
None
)
def
__repr__
(
self
):
return
f"<component
{
self
.
to_string
(
None
)
}
>"
@
dataclass
class
ValueLocation
:
components
:
List
[
'ValueLocationComponent'
]
indirect
:
bool
=
False
returned_pointer
:
Optional
[
'variable.CoreVariable'
]
=
None
@
staticmethod
def
_from_core_struct
(
struct
:
core
.
BNValueLocation
,
arch
:
Optional
[
'architecture.Architecture'
]
=
None
):
components
=
[]
for
i
in
range
(
struct
.
count
):
components
.
append
(
ValueLocationComponent
.
_from_core_struct
(
struct
.
components
[
i
],
arch
))
indirect
=
struct
.
indirect
returned_pointer
=
None
if
struct
.
returnedPointerValid
:
if
arch
is
None
:
returned_pointer
=
variable
.
CoreVariable
.
from_BNVariable
(
struct
.
returnedPointer
)
else
:
returned_pointer
=
variable
.
ArchitectureVariable
.
from_BNVariable
(
arch
,
struct
.
returnedPointer
)
return
ValueLocation
(
components
,
indirect
,
returned_pointer
)
def
_to_core_struct
(
self
)
->
core
.
BNValueLocation
:
struct
=
core
.
BNValueLocation
()
struct
.
count
=
len
(
self
.
components
)
components
=
(
core
.
BNValueLocationComponent
*
len
(
self
.
components
))()
for
i
in
range
(
len
(
self
.
components
)):
components
[
i
]
=
self
.
components
[
i
].
_to_core_struct
()
struct
.
components
=
components
struct
.
indirect
=
self
.
indirect
struct
.
returnedPointerValid
=
self
.
returned_pointer
is
not
None
if
self
.
returned_pointer
is
not
None
:
struct
.
returnedPointer
=
self
.
returned_pointer
.
to_BNVariable
()
return
struct
def
with_confidence
(
self
,
confidence
:
int
)
->
'ValueLocationWithConfidence'
:
return
ValueLocationWithConfidence
(
self
,
confidence
)
def
variable_for_parameter
(
self
,
idx
:
int
)
->
Optional
[
'variable.CoreVariable'
]:
struct
=
self
.
_to_core_struct
()
var
=
core
.
BNVariable
()
if
core
.
BNGetValueLocationVariableForParameter
(
struct
,
var
,
idx
):
return
variable
.
CoreVariable
.
from_BNVariable
(
var
)
return
None
@
staticmethod
def
parse
(
string
:
str
,
arch
:
'architecture.Architecture'
)
->
'ValueLocation'
:
struct
=
core
.
BNValueLocation
()
error
=
ctypes
.
c_char_p
()
if
not
core
.
BNParseValueLocation
(
string
,
arch
.
handle
,
struct
,
error
):
assert
error
.
value
is
not
None
,
"core.BNParseValueLocation returned 'error' set to None"
error_str
=
error
.
value
.
decode
(
"utf-8"
)
core
.
free_string
(
error
)
raise
SyntaxError
(
error_str
)
result
=
ValueLocation
.
_from_core_struct
(
struct
,
arch
)
core
.
BNFreeValueLocation
(
struct
)
return
result
def
to_string
(
self
,
arch
:
Optional
[
'architecture.Architecture'
]):
if
arch
is
None
:
for
component
in
self
.
components
:
if
isinstance
(
component
.
var
,
variable
.
ArchitectureVariable
):
arch
=
component
.
var
.
arch
break
if
isinstance
(
component
.
var
,
variable
.
Variable
):
arch
=
component
.
var
.
function
.
arch
break
if
arch
is
None
:
if
self
.
indirect
:
indirect
=
" indirect"
else
:
indirect
=
""
if
self
.
returned_pointer
is
None
:
ret_ptr
=
""
else
:
ret_ptr
=
f" returned ptr
{
repr
(
self
.
returned_pointer
)
}
"
return
f"
{
repr
(
self
.
components
)
}
{
indirect
}
{
ret_ptr
}
"
struct
=
self
.
_to_core_struct
()
return
core
.
BNValueLocationToString
(
struct
,
arch
.
handle
)
def
__str__
(
self
):
return
self
.
to_string
(
None
)
def
__repr__
(
self
):
return
f"<value location
{
self
.
to_string
(
None
)
}
>"
@
dataclass
class
ValueLocationWithConfidence
:
location
:
'ValueLocation'
confidence
:
int
=
core
.
max_confidence
@
staticmethod
def
from_optional_location
(
location
:
OptionalLocation
)
->
Optional
[
'ValueLocationWithConfidence'
]:
if
isinstance
(
location
,
ValueLocation
):
return
location
.
with_confidence
(
core
.
max_confidence
)
elif
isinstance
(
location
,
ValueLocationWithConfidence
):
return
location
elif
location
is
not
None
:
return
ValueLocation
([
ValueLocationComponent
(
location
)]).
with_confidence
(
core
.
max_confidence
)
return
None
def
__repr__
(
self
):
return
f"<value location
{
self
.
location
.
to_string
(
None
)
}
confidence
{
self
.
confidence
}
>"
@
dataclass
class
ReturnValue
:
type
:
SomeType
location
:
Optional
[
'ValueLocationWithConfidence'
]
def
__init__
(
self
,
ty
:
SomeType
,
location
:
OptionalLocation
=
None
):
self
.
type
=
ty
.
immutable_copy
()
self
.
location
=
ValueLocationWithConfidence
.
from_optional_location
(
location
)
@
staticmethod
def
_from_core_struct
(
struct
:
core
.
BNReturnValue
,
arch
:
Optional
[
'architecture.Architecture'
]
=
None
):
ty
=
Type
.
from_core_struct
(
struct
.
type
).
with_confidence
(
struct
.
typeConfidence
)
if
struct
.
defaultLocation
:
location
=
None
else
:
location
=
ValueLocation
.
_from_core_struct
(
struct
.
location
,
arch
).
with_confidence
(
struct
.
locationConfidence
)
return
ReturnValue
(
ty
,
location
)
def
_to_core_struct
(
self
)
->
core
.
BNReturnValue
:
struct
=
core
.
BNReturnValue
()
ic
=
self
.
type
.
immutable_copy
()
struct
.
type
=
ic
.
handle
struct
.
typeConfidence
=
ic
.
confidence
struct
.
defaultLocation
=
self
.
location
is
None
if
self
.
location
is
None
:
struct
.
location
.
count
=
0
struct
.
locationConfidence
=
0
else
:
struct
.
location
=
self
.
location
.
location
.
_to_core_struct
()
struct
.
locationConfidence
=
self
.
location
.
confidence
return
struct
@
dataclass
class
FunctionParameter
:
type
:
SomeType
name
:
str
=
""
location_source
:
ValueLocationSource
=
ValueLocationSource
.
DefaultLocationSource
location
:
Optional
[
'ValueLocation'
]
=
None
def
__init__
(
self
,
type
:
SomeType
,
name
:
str
=
""
,
location
:
OptionalLocation
=
None
,
source
:
Optional
[
'ValueLocationSource'
]
=
None
):
self
.
type
=
type
self
.
name
=
name
location
=
ValueLocationWithConfidence
.
from_optional_location
(
location
)
if
location
is
not
None
:
self
.
location
=
location
.
location
self
.
location_source
=
ValueLocationSource
.
CustomLocationSource
else
:
self
.
location
=
None
self
.
location_source
=
ValueLocationSource
.
DefaultLocationSource
if
source
is
not
None
:
self
.
location_source
=
source
def
__repr__
(
self
):
ic
=
self
.
type
.
immutable_copy
()
if
(
self
.
location
is
not
None
)
and
(
str
(
self
.
location
)
!=
self
.
name
):
return
f"
{
ic
.
get_string_before_name
()
}
{
self
.
name
}
{
ic
.
get_string_after_name
()
}
@
{
self
.
location
}
"
return
f"
{
ic
.
get_string_before_name
()
}
{
self
.
name
}
{
ic
.
get_string_after_name
()
}
"
def
immutable_copy
(
self
)
->
'FunctionParameter'
:
return
FunctionParameter
(
self
.
type
.
immutable_copy
(),
self
.
name
,
self
.
location
,
self
.
location_source
)
def
mutable_copy
(
self
)
->
'FunctionParameter'
:
return
FunctionParameter
(
self
.
type
.
mutable_copy
(),
self
.
name
,
self
.
location
,
self
.
location_source
)
@
staticmethod
def
_from_core_struct
(
struct
:
'core.BNFunctionParameter'
,
arch
:
Optional
[
'architecture.Architecture'
]
=
None
)
->
'FunctionParameter'
:
name
=
struct
.
name
ty
=
Type
.
from_core_struct
(
struct
.
type
).
with_confidence
(
struct
.
typeConfidence
)
source
=
ValueLocationSource
(
struct
.
locationSource
)
if
source
==
ValueLocationSource
.
CustomLocationSource
:
location
=
ValueLocation
.
_from_core_struct
(
struct
.
location
,
arch
)
else
:
location
=
None
return
FunctionParameter
(
ty
,
name
,
location
,
source
)
@
dataclass
(
frozen
=
True
)
class
OffsetWithConfidence
:
value
:
int
confidence
:
int
=
core
.
max_confidence
def
__int__
(
self
):
return
self
.
value
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
return
self
.
value
==
int
(
other
)
else
:
return
(
self
.
value
,
self
.
confidence
)
==
(
other
.
value
,
other
.
confidence
)
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__gt__
(
self
,
other
):
return
self
.
value
>
int
(
other
)
def
__le__
(
self
,
other
):
return
self
.
value
<=
int
(
other
)
def
__ge__
(
self
,
other
):
return
self
.
value
>=
int
(
other
)
def
__lt__
(
self
,
other
):
return
self
.
value
<
int
(
other
)
def
_to_core_struct
(
self
)
->
core
.
BNOffsetWithConfidence
:
result
=
core
.
BNOffsetWithConfidence
()
result
.
value
=
self
.
value
result
.
confidence
=
self
.
confidence
return
result
@
classmethod
def
from_core_struct
(
cls
,
core_struct
:
core
.
BNOffsetWithConfidence
)
->
'OffsetWithConfidence'
:
return
cls
(
core_struct
.
value
,
core_struct
.
confidence
)
@
staticmethod
def
get_core_struct
(
value
:
OffsetWithConfidenceType
,
confidence
:
int
=
core
.
max_confidence
)
->
core
.
BNOffsetWithConfidence
:
if
isinstance
(
value
,
OffsetWithConfidence
):
return
value
.
_to_core_struct
()
else
:
return
OffsetWithConfidence
(
value
,
confidence
).
_to_core_struct
()
@
dataclass
(
frozen
=
True
)
class
BoolWithConfidence
:
value
:
bool
confidence
:
int
=
core
.
max_confidence
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
return
self
.
value
==
bool
(
other
)
else
:
return
(
self
.
value
,
self
.
confidence
)
==
(
other
.
value
,
other
.
confidence
)
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__bool__
(
self
):
return
self
.
value
def
_to_core_struct
(
self
)
->
core
.
BNBoolWithConfidence
:
result
=
core
.
BNBoolWithConfidence
()
result
.
value
=
self
.
value
result
.
confidence
=
self
.
confidence
return
result
@
classmethod
def
from_core_struct
(
cls
,
core_struct
:
core
.
BNBoolWithConfidence
)
->
'BoolWithConfidence'
:
return
cls
(
core_struct
.
value
,
core_struct
.
confidence
)
@
staticmethod
def
get_core_struct
(
value
:
Union
[
BoolWithConfidenceType
,
bool
],
confidence
:
int
=
core
.
max_confidence
)
->
core
.
BNBoolWithConfidence
:
if
isinstance
(
value
,
BoolWithConfidence
):
return
value
.
_to_core_struct
()
else
:
return
BoolWithConfidence
(
value
,
confidence
).
_to_core_struct
()
@
dataclass
(
frozen
=
True
)
class
InlineDuringAnalysisWithConfidence
:
"""Represents an InlineDuringAnalysis value with an associated confidence level."""
value
:
InlineDuringAnalysis
confidence
:
int
=
core
.
max_confidence
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
# For backward compatibility, allow comparison with bool
if
isinstance
(
other
,
bool
):
return
bool
(
self
.
value
)
==
other
# Allow comparison with enum value directly
return
self
.
value
==
other
else
:
return
(
self
.
value
,
self
.
confidence
)
==
(
other
.
value
,
other
.
confidence
)
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__bool__
(
self
):
return
bool
(
self
.
value
)
def
_to_core_struct
(
self
)
->
core
.
BNInlineDuringAnalysisWithConfidence
:
result
=
core
.
BNInlineDuringAnalysisWithConfidence
()
result
.
value
=
self
.
value
result
.
confidence
=
self
.
confidence
return
result
@
classmethod
def
from_core_struct
(
cls
,
core_struct
:
core
.
BNInlineDuringAnalysisWithConfidence
)
->
'InlineDuringAnalysisWithConfidence'
:
return
cls
(
InlineDuringAnalysis
(
core_struct
.
value
),
core_struct
.
confidence
)
@
dataclass
class
MutableTypeBuilder
(
Generic
[
TB
]):
type
:
TB
container
:
TypeContainerType
name
:
QualifiedName
platform
:
Optional
[
'_platform.Platform'
]
confidence
:
int
user
:
bool
=
True
def
__enter__
(
self
)
->
TB
:
return
self
.
type
def
__exit__
(
self
,
type
,
value
,
traceback
):
if
isinstance
(
self
.
container
,
binaryview
.
BinaryView
):
if
self
.
user
:
self
.
container
.
define_user_type
(
self
.
name
,
self
.
type
.
immutable_copy
())
else
:
type_id
=
Type
.
generate_auto_type_id
(
str
(
uuid
.
uuid4
()),
str
(
self
.
name
))
self
.
container
.
define_type
(
type_id
,
self
.
name
,
self
.
type
.
immutable_copy
())
else
:
self
.
container
.
add_named_type
(
self
.
name
,
self
.
type
.
immutable_copy
())
class
TypeBuilderAttributes
(
dict
):
def
__init__
(
self
,
builder
:
'TypeBuilder'
,
*
args
):
super
().
__init__
(
*
args
)
self
.
_builder
=
builder
def
__setitem__
(
self
,
key
:
str
,
value
:
str
):
if
not
isinstance
(
key
,
str
):
raise
TypeError
(
"Type attribute key must be a string"
)
if
not
isinstance
(
value
,
str
):
raise
TypeError
(
"Type attribute value must be a string"
)
core
.
BNSetTypeBuilderAttribute
(
self
.
_builder
.
_handle
,
key
,
value
)
super
().
__setitem__
(
key
,
value
)
def
__delitem__
(
self
,
key
:
str
):
if
not
isinstance
(
key
,
str
):
raise
TypeError
(
"Type attribute key must be a string"
)
core
.
BNRemoveTypeBuilderAttribute
(
self
.
_builder
.
_handle
,
key
)
super
().
__delitem__
(
key
)
class
TypeBuilder
:
"""
All TypeBuilder objects should not be instantiated directly but created via ``.create`` APIs.
"""
def
__init__
(
self
,
handle
:
core
.
BNTypeBuilderHandle
,
platform
:
Optional
[
'_platform.Platform'
]
=
None
,
confidence
:
int
=
core
.
max_confidence
):
assert
isinstance
(
handle
,
core
.
BNTypeBuilderHandle
),
"handle isn't an instance of BNTypeBuilderHandle"
self
.
_handle
=
handle
self
.
platform
=
platform
self
.
confidence
=
confidence
def
__del__
(
self
):
if
core
is
not
None
:
core
.
BNFreeTypeBuilder
(
self
.
_handle
)
def
__eq__
(
self
,
other
:
'TypeBuilder'
)
->
bool
:
if
not
isinstance
(
other
,
TypeBuilder
):
raise
ValueError
(
f"Unable compare equality of TypeBuilder and
{
type
(
other
)
}
"
)
return
self
.
immutable_copy
()
==
other
.
immutable_copy
()
def
__ne__
(
self
,
other
:
'TypeBuilder'
)
->
bool
:
return
not
self
.
__eq__
(
other
)
def
__repr__
(
self
):
return
f"<type: mutable:
{
self
.
type_class
.
name
}
'
{
self
}
'>"
def
__str__
(
self
):
return
str
(
self
.
immutable_copy
())
def
__hash__
(
self
):
return
hash
(
ctypes
.
addressof
(
self
.
_handle
.
contents
))
def
immutable_copy
(
self
):
Types
=
{
TypeClass
.
VoidTypeClass
:
VoidType
,
TypeClass
.
BoolTypeClass
:
BoolType
,
TypeClass
.
IntegerTypeClass
:
IntegerType
,
TypeClass
.
FloatTypeClass
:
FloatType
,
TypeClass
.
PointerTypeClass
:
PointerType
,
TypeClass
.
ArrayTypeClass
:
ArrayType
,
TypeClass
.
FunctionTypeClass
:
FunctionType
,
TypeClass
.
WideCharTypeClass
:
WideCharType
,
TypeClass
.
StructureTypeClass
:
StructureType
,
TypeClass
.
EnumerationTypeClass
:
EnumerationType
,
TypeClass
.
NamedTypeReferenceClass
:
NamedTypeReferenceType
,
TypeClass
.
FragmentTypeClass
:
FragmentType
,
}
return
Types
[
self
.
type_class
](
self
.
_finalized
,
self
.
platform
,
self
.
confidence
)
def
mutable_copy
(
self
)
->
'TypeBuilder'
:
return
self
@
classmethod
def
create
(
cls
):
_
=
cls
return
NotImplemented
@
classmethod
def
builder
(
cls
:
typing
.
Type
[
TB
],
container
:
TypeContainerType
,
name
:
'QualifiedName'
,
user
:
bool
=
True
,
platform
:
Optional
[
'_platform.Platform'
]
=
None
,
confidence
:
int
=
core
.
max_confidence
)
->
'MutableTypeBuilder[TB]'
:
return
MutableTypeBuilder
(
cls
.
create
(),
container
,
name
,
platform
,
confidence
,
user
)
@
staticmethod
def
void
()
->
'VoidBuilder'
:
return
VoidBuilder
.
create
()
@
staticmethod
def
bool
()
->
'BoolBuilder'
:
return
BoolBuilder
.
create
()
@
staticmethod
def
char
(
alternate_name
:
str
=
""
)
->
'CharBuilder'
:
return
CharBuilder
.
create
(
alternate_name
)
@
staticmethod
def
int
(
width
:
_int
,
sign
:
BoolWithConfidenceType
=
BoolWithConfidence
(
True
),
altname
:
str
=
""
)
->
'IntegerBuilder'
:
"""
``int`` class method for creating an int Type.
:param int width: width of the integer in bytes
:param bool sign: optional variable representing signedness
:param str altname: alternate name for type
"""
return
IntegerBuilder
.
create
(
width
,
sign
,
altname
)
@
staticmethod
def
float
(
width
:
_int
,
altname
:
str
=
""
)
->
'FloatBuilder'
:
"""
``float`` class method for creating floating point Types.
:param int width: width of the floating point number in bytes
:param str altname: alternate name for type
"""
return
FloatBuilder
.
create
(
width
,
altname
)
@
staticmethod
def
wide_char
(
width
:
_int
,
altname
:
str
=
""
)
->
'WideCharBuilder'
:
"""
``wide_char`` class method for creating wide char Types.
:param int width: width of the wide character in bytes
:param str altname: alternate name for type
"""
return
WideCharBuilder
.
create
(
width
,
altname
)
@
staticmethod
def
named_type_from_type
(
name
:
QualifiedNameType
,
type_class
:
Optional
[
NamedTypeReferenceClass
]
=
None
)
->
'NamedTypeReferenceBuilder'
:
return
NamedTypeReferenceBuilder
.
named_type_from_type
(
name
,
type_class
)
@
staticmethod
def
named_type_from_type_and_id
(
type_id
:
str
,
name
:
QualifiedNameType
,
type
:
Optional
[
SomeType
]
=
None
)
->
'NamedTypeReferenceBuilder'
:
return
NamedTypeReferenceBuilder
.
named_type_from_type_and_id
(
type_id
,
name
,
type
)
@
staticmethod
def
named_type_from_registered_type
(
view
:
'binaryview.BinaryView'
,
name
:
QualifiedName
)
->
'NamedTypeReferenceBuilder'
:
return
NamedTypeReferenceBuilder
.
named_type_from_registered_type
(
view
,
name
)
@
staticmethod
def
pointer
(
arch
:
'architecture.Architecture'
,
type
:
SomeType
,
const
:
BoolWithConfidenceType
=
BoolWithConfidence
(
False
),
volatile
:
BoolWithConfidenceType
=
BoolWithConfidence
(
False
),
ref_type
:
ReferenceType
=
ReferenceType
.
PointerReferenceType
)
->
'PointerBuilder'
:
return
PointerBuilder
.
create
(
type
,
arch
.
address_size
,
arch
,
const
,
volatile
,
ref_type
)
@
staticmethod
def
pointer_of_width
(
width
:
_int
,
type
:
SomeType
,
const
:
BoolWithConfidenceType
=
BoolWithConfidence
(
False
),
volatile
:
BoolWithConfidenceType
=
BoolWithConfidence
(
False
),
ref_type
:
ReferenceType
=
ReferenceType
.
PointerReferenceType
)
->
'PointerBuilder'
:
return
PointerBuilder
.
create
(
type
,
width
,
None
,
const
,
volatile
,
ref_type
)
@
staticmethod
def
array
(
type
:
SomeType
,
count
:
_int
)
->
'ArrayBuilder'
:
return
ArrayBuilder
.
create
(
type
,
count
)
@
staticmethod
def
function
(
ret
:
Optional
[
ReturnValueOrType
]
=
None
,
params
:
Optional
[
ParamsType
]
=
None
,
calling_convention
:
Optional
[
'callingconvention.CallingConvention'
]
=
None
,
variable_arguments
:
Optional
[
BoolWithConfidenceType
]
=
None
,
stack_adjust
:
Optional
[
OffsetWithConfidenceType
]
=
None
)
->
'FunctionBuilder'
:
"""
``function`` class method for creating a function Type.
:param Type ret: return Type of the function
:param params: list of parameter Types
:type params: list(Type)
:param CallingConvention calling_convention: optional argument for the function calling convention
:param bool variable_arguments: optional boolean, true if the function has a variable number of arguments
"""
return
FunctionBuilder
.
create
(
ret
,
calling_convention
,
params
,
variable_arguments
,
stack_adjust
)
@
staticmethod
def
structure
(
members
:
Optional
[
MembersType
]
=
None
,
packed
:
_bool
=
False
,
type
:
StructureVariant
=
StructureVariant
.
StructStructureType
)
->
'StructureBuilder'
:
return
StructureBuilder
.
create
(
members
,
type
=
type
,
packed
=
packed
)
@
staticmethod
def
union
(
members
:
Optional
[
MembersType
]
=
None
,
packed
:
_bool
=
False
)
->
'StructureBuilder'
:
return
StructureBuilder
.
create
(
members
,
type
=
StructureVariant
.
UnionStructureType
,
packed
=
packed
)
@
staticmethod
def
class_type
(
members
:
Optional
[
MembersType
]
=
None
,
packed
:
_bool
=
False
)
->
'StructureBuilder'
:
View remainder of file in raw view
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
You can’t perform that action at this time.
Back
|
FazBrowse Home
|
New Git URL