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

Method get_mlil_var_refs_from

python/function.py:3184–3227  ·  view source on GitHub ↗

``get_mlil_var_refs_from`` returns a list of variables referenced by code in the function ``func``, of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from all functions and containing the address will be returned. If no architecture is specifie

(self, addr: int, length: Optional[int] = None,
	                           arch: Optional['architecture.Architecture'] = None)

Source from the content-addressed store, hash-verified

3182 return result
3183
3184 def get_mlil_var_refs_from(self, addr: int, length: Optional[int] = None,
3185 arch: Optional['architecture.Architecture'] = None) -> List[VariableReferenceSource]:
3186 """
3187 ``get_mlil_var_refs_from`` returns a list of variables referenced by code in the function ``func``,
3188 of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
3189 all functions and containing the address will be returned. If no architecture is specified, the
3190 architecture of the function will be used.
3191 This function is related to get_hlil_var_refs_from(), which returns variable references collected
3192 from HLIL. The two can be different in several cases, e.g., multiple variables in MLIL can be merged
3193 into a single variable in HLIL.
3194
3195 :param int addr: virtual address to query for variable references
3196 :param int length: optional length of query
3197 :param Architecture arch: optional architecture of query
3198 :return: list of variable reference sources
3199 :rtype: list(VariableReferenceSource)
3200 """
3201 result = []
3202 count = ctypes.c_ulonglong(0)
3203
3204 if arch is None:
3205 arch = self.arch
3206
3207 if length is None:
3208 refs = core.BNGetMediumLevelILVariableReferencesFrom(self.handle, arch.handle, addr, count)
3209 assert refs is not None, "core.BNGetMediumLevelILVariableReferencesFrom returned None"
3210 else:
3211 refs = core.BNGetMediumLevelILVariableReferencesInRange(self.handle, arch.handle, addr, length, count)
3212 assert refs is not None, "core.BNGetMediumLevelILVariableReferencesInRange returned None"
3213 for i in range(0, count.value):
3214 var = variable.Variable.from_BNVariable(self, refs[i].var)
3215 if refs[i].source.func:
3216 func = Function(self.view, core.BNNewFunctionReference(refs[i].source.func))
3217 else:
3218 func = None
3219 if refs[i].source.arch:
3220 _arch = architecture.CoreArchitecture._from_cache(refs[i].source.arch)
3221 else:
3222 _arch = arch
3223
3224 src = ILReferenceSource(func, _arch, refs[i].source.addr, refs[i].source.type, refs[i].source.exprId)
3225 result.append(VariableReferenceSource(var, src))
3226 core.BNFreeVariableReferenceSourceList(refs, count.value)
3227 return result
3228
3229 def get_hlil_var_refs(self, var: 'variable.Variable') -> List[ILReferenceSource]:
3230 """

Callers

nothing calls this directly

Calls 6

FunctionClass · 0.70
ILReferenceSourceClass · 0.70
from_BNVariableMethod · 0.45
_from_cacheMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected