summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2017-03-13 23:03:41 -0400
committerRusty Wagner <rusty@vector35.com>2017-03-13 23:03:54 -0400
commit42cb99079d4ff0a5aa49e7730bb73500d13f35dd (patch)
tree03c6a4899fc6d8c5eab5dd09742c608c7e3a104c /python/mediumlevelil.py
parent29be664b3c91d135b54ed34976357bb7d3413e94 (diff)
Branch dependence APIs for path sensitive analysis
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 00d7215f..8830e738 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -22,7 +22,7 @@ import ctypes
# Binary Ninja components
import _binaryninjacore as core
-from .enums import MediumLevelILOperation, InstructionTextTokenType, ILVariableSourceType
+from .enums import MediumLevelILOperation, InstructionTextTokenType, ILVariableSourceType, ILBranchDependence
import function
import basicblock
import lowlevelil
@@ -260,6 +260,11 @@ class MediumLevelILInstruction(object):
return result
@property
+ def branch_dependence(self):
+ """Set of branching instructions that must take the true or false path to reach this instruction"""
+ return self.function.get_all_branch_dependence_at_instruction(self.instr_index)
+
+ @property
def low_level_il(self):
"""Low level IL form of this expression"""
expr = self.function.get_low_level_il_expr_index(self.expr_index)
@@ -567,6 +572,18 @@ class MediumLevelILFunction(object):
def get_ssa_memory_index_at_instruction(self, instr):
return core.BNGetMediumLevelILSSAMemoryIndexAtILInstruction(self.handle, instr)
+ def get_branch_dependence_at_instruction(self, cur_instr, branch_instr):
+ return ILBranchDependence(core.BNGetMediumLevelILBranchDependence(self.handle, cur_instr, branch_instr))
+
+ def get_all_branch_dependence_at_instruction(self, instr):
+ count = ctypes.c_ulonglong()
+ deps = core.BNGetAllMediumLevelILBranchDependence(self.handle, instr, count)
+ result = {}
+ for i in xrange(0, count.value):
+ result[deps[i].branch] = ILBranchDependence(deps[i].dependence)
+ core.BNFreeILBranchDependenceList(deps)
+ return result
+
def get_low_level_il_instruction_index(self, instr):
low_il = self.low_level_il
if low_il is None: