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

Class Function

python/function.py:414–3393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412
413
414class Function:
415 _associated_data = {}
416 """
417 The examples in the following code will use the following variables
418
419 >>> from binaryninja import *
420 >>> bv = load("/bin/ls")
421 >>> current_function = bv.functions[0]
422 >>> here = current_function.start
423 """
424 def __init__(self, view: Optional['binaryview.BinaryView'] = None, handle: Optional[core.BNFunctionHandle] = None):
425 self._advanced_analysis_requests = 0
426 assert handle is not None, "creation of standalone 'Function' objects is not implemented"
427 FunctionHandle = ctypes.POINTER(core.BNFunction)
428 self.handle = ctypes.cast(handle, FunctionHandle)
429 if view is None:
430 self._view = binaryview.BinaryView(handle=core.BNGetFunctionData(self.handle))
431 else:
432 self._view = view
433 self._arch = None
434 self._platform = None
435
436 def __del__(self):
437 if core is not None and self.handle is not None:
438 if self._advanced_analysis_requests > 0:
439 core.BNReleaseAdvancedFunctionAnalysisDataMultiple(self.handle, self._advanced_analysis_requests)
440 core.BNFreeFunction(self.handle)
441
442 def __repr__(self):
443 arch = self.arch
444 if arch:
445 return f"<func: {arch.name}@{self.start:#x}>"
446 else:
447 return f"<func: {self.start:#x}>"
448
449 def __eq__(self, other: 'Function') -> bool:
450 if not isinstance(other, self.__class__):
451 return NotImplemented
452 return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents)
453
454 def __ne__(self, other: 'Function') -> bool:
455 if not isinstance(other, self.__class__):
456 return NotImplemented
457 return not (self == other)
458
459 def __lt__(self, other: 'Function') -> bool:
460 if not isinstance(other, self.__class__):
461 return NotImplemented
462 return self.start < other.start
463
464 def __gt__(self, other: 'Function') -> bool:
465 if not isinstance(other, self.__class__):
466 return NotImplemented
467 return self.start > other.start
468
469 def __le__(self, other: 'Function') -> bool:
470 if not isinstance(other, self.__class__):
471 return NotImplemented

Callers 11

call_sitesMethod · 0.70
get_mlil_var_refsMethod · 0.70
get_hlil_var_refsMethod · 0.70
functionMethod · 0.70
_primary_functionMethod · 0.70
_secondary_functionMethod · 0.70
_functionMethod · 0.70
translate_functionMethod · 0.50
from_bn_type_internalFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected