MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ReferenceSource

Class ReferenceSource

python/binaryview.py:97–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96@dataclass(frozen=True)
97class ReferenceSource:
98 function: Optional['_function.Function']
99 arch: Optional['architecture.Architecture']
100 address: int
101
102 def __repr__(self):
103 if self.arch:
104 return f"<ref: {self.arch.name}@{self.address:#x}>"
105 else:
106 return f"<ref: {self.address:#x}>"
107
108 @classmethod
109 def _from_core_struct(cls, view: 'BinaryView', ref: core.BNReferenceSource) -> 'ReferenceSource':
110 if ref.func:
111 func = _function.Function(view, core.BNNewFunctionReference(ref.func))
112 else:
113 func = None
114 if ref.arch:
115 arch = architecture.CoreArchitecture._from_cache(ref.arch)
116 else:
117 arch = None
118
119 return ReferenceSource(func, arch, ref.addr)
120
121 @property
122 def llil(self) -> Optional[lowlevelil.LowLevelILInstruction]:
123 """Returns the low level il instruction at the current location if one exists"""
124 if self.function is None or self.arch is None:
125 return None
126 return self.function.get_low_level_il_at(self.address, self.arch)
127
128 @property
129 def mlil(self) -> Optional[mediumlevelil.MediumLevelILInstruction]:
130 """Returns the medium level il instruction at the current location if one exists"""
131 llil = self.llil
132 return llil.mlil if llil is not None else None
133
134 @property
135 def hlil(self) -> Optional[highlevelil.HighLevelILInstruction]:
136 """Returns the high level il instruction at the current location if one exists"""
137 mlil = self.mlil
138 return mlil.hlil if mlil is not None else None
139
140
141class NotificationType(IntFlag):

Callers 1

_from_core_structMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected