diff options
| author | Peter LaFosse <peter@vector35.com> | 2019-04-05 21:53:36 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2019-04-07 18:19:49 -0400 |
| commit | 5de327770ec8c3f1aca9c774d850442edb9a3610 (patch) | |
| tree | 9b192f7921822cef5dff8a66b0d9b39f7ac38971 /python | |
| parent | 6a66d5bc6f1418c80d9ec45e821272a05f9b3ad9 (diff) | |
Add callee/caller properties to function objects
Diffstat (limited to 'python')
| -rw-r--r-- | python/function.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/python/function.py b/python/function.py index 14e140c1..c33ac97f 100644 --- a/python/function.py +++ b/python/function.py @@ -33,7 +33,7 @@ from binaryninja import types from binaryninja.enums import (AnalysisSkipReason, FunctionGraphType, BranchType, SymbolType, InstructionTextTokenType, HighlightStandardColor, HighlightColorStyle, RegisterValueType, ImplicitRegisterExtend, DisassemblyOption, IntegerDisplayType, InstructionTextTokenContext, VariableSourceType, - FunctionAnalysisSkipOverride) + FunctionAnalysisSkipOverride, MediumLevelILOperation) # 2-3 compatibility from binaryninja import range @@ -1600,6 +1600,35 @@ class Function(object): core.BNRequestFunctionDebugReport(self.handle, name) self.view.update_analysis() + @property + def callees(self): + called = [] + for bb in self.medium_level_il: + for i in bb: + if i.operation in (MediumLevelILOperation.MLIL_CALL, MediumLevelILOperation.MLIL_CALL_UNTYPED): + if i.dest.value.type == RegisterValueType.ConstantPointerValue: + func = self.view.get_function_at(i.dest.value.value, self.platform) + if func is not None: + called.append(func) + return called + + @property + def callee_addresses(self): + called = [] + for bb in self.medium_level_il: + for i in bb: + if i.operation in (MediumLevelILOperation.MLIL_CALL, MediumLevelILOperation.MLIL_CALL_UNTYPED): + if i.dest.value.type == RegisterValueType.ConstantPointerValue: + called.append(i.dest.value.value) + return called + + @property + def callers(self): + functions = [] + for ref in self.view.get_code_refs(self.start): + if ref.function is not None: + functions.append(ref.function) + return functions class AdvancedFunctionAnalysisDataRequestor(object): def __init__(self, func = None): |
