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

Method get_code_refs_from

python/binaryview.py:5282–5319  ·  view source on GitHub ↗

``get_code_refs_from`` returns a list of virtual addresses 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 spec

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

Source from the content-addressed store, hash-verified

5280 core.BNFreeCodeReferences(refs, count.value)
5281
5282 def get_code_refs_from(
5283 self, addr: int, func: Optional['_function.Function'] = None,
5284 arch: Optional['architecture.Architecture'] = None, length: Optional[int] = None
5285 ) -> List[int]:
5286 """
5287 ``get_code_refs_from`` returns a list of virtual addresses referenced by code in the function ``func``,
5288 of the architecture ``arch``, and at the address ``addr``. If no function is specified, references from
5289 all functions and containing the address will be returned. If no architecture is specified, the
5290 architecture of the function will be used.
5291 This function returns both autoanalysis ("auto") and user-specified ("user") xrefs.
5292 To add a user-specified reference, see :py:func:`~binaryninja.function.Function.add_user_code_ref`.
5293
5294 :param int addr: virtual address to query for references
5295 :param int length: optional length of query
5296 :param Architecture arch: optional architecture of query
5297 :return: list of integers
5298 :rtype: list(integer)
5299 """
5300
5301 result = []
5302 funcs = self.get_functions_containing(addr) if func is None else [func]
5303 if not funcs:
5304 return []
5305 for src_func in funcs:
5306 src_arch = src_func.arch if arch is None else arch
5307 assert src_arch is not None
5308 ref_src = core.BNReferenceSource(src_func.handle, src_arch.handle, addr)
5309 count = ctypes.c_ulonglong(0)
5310 if length is None:
5311 refs = core.BNGetCodeReferencesFrom(self.handle, ref_src, count)
5312 assert refs is not None, "core.BNGetCodeReferencesFrom returned None"
5313 else:
5314 refs = core.BNGetCodeReferencesFromInRange(self.handle, ref_src, length, count)
5315 assert refs is not None, "core.BNGetCodeReferencesFromInRange returned None"
5316 for i in range(0, count.value):
5317 result.append(refs[i])
5318 core.BNFreeAddressList(refs)
5319 return result
5320
5321 def get_data_refs(self, addr: int, length: Optional[int] = None) -> Generator[int, None, None]:
5322 """

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45

Tested by

no test coverage detected