From 203717232e816d42973f05f1c9fbc950914d71dc Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 23 Jul 2019 22:40:39 -0400 Subject: Early HLIL testing --- python/flowgraph.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'python/flowgraph.py') diff --git a/python/flowgraph.py b/python/flowgraph.py index 32303c93..6c3f41f7 100644 --- a/python/flowgraph.py +++ b/python/flowgraph.py @@ -30,6 +30,7 @@ from binaryninja import function from binaryninja import binaryview from binaryninja import lowlevelil from binaryninja import mediumlevelil +from binaryninja import highlevelil from binaryninja import basicblock from binaryninja import log from binaryninja import highlight @@ -531,6 +532,10 @@ class FlowGraph(object): def is_medium_level_il(self): return core.BNIsMediumLevelILFlowGraph(self.handle) + @property + def is_high_level_il(self): + return core.BNIsHighLevelILFlowGraph(self.handle) + @property def il_function(self): if self.is_low_level_il: @@ -549,6 +554,14 @@ class FlowGraph(object): if function is None: return None return mediumlevelil.MediumLevelILFunction(function.arch, il_func, function) + if self.is_high_level_il: + il_func = core.BNGetFlowGraphHighLevelILFunction(self.handle) + if not il_func: + return None + function = self.function + if function is None: + return None + return highlevelil.HighLevelILFunction(function.arch, il_func, function) return None @il_function.setter @@ -556,12 +569,19 @@ class FlowGraph(object): if isinstance(func, lowlevelil.LowLevelILFunction): core.BNSetFlowGraphLowLevelILFunction(self.handle, func.handle) core.BNSetFlowGraphMediumLevelILFunction(self.handle, None) + core.BNSetFlowGraphHighLevelILFunction(self.handle, None) elif isinstance(func, mediumlevelil.MediumLevelILFunction): core.BNSetFlowGraphLowLevelILFunction(self.handle, None) core.BNSetFlowGraphMediumLevelILFunction(self.handle, func.handle) + core.BNSetFlowGraphHighLevelILFunction(self.handle, None) + elif isinstance(func, highlevelil.HighLevelILFunction): + core.BNSetFlowGraphLowLevelILFunction(self.handle, None) + core.BNSetFlowGraphMediumLevelILFunction(self.handle, None) + core.BNSetFlowGraphHighLevelILFunction(self.handle, func.handle) elif func is None: core.BNSetFlowGraphLowLevelILFunction(self.handle, None) core.BNSetFlowGraphMediumLevelILFunction(self.handle, None) + core.BNSetFlowGraphHighLevelILFunction(self.handle, None) else: raise TypeError("expected IL function for setting il_function property") -- cgit v1.3.1