From 01a9eb27ea90e62476bb368f1e418745777f24b5 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Wed, 12 Dec 2018 13:26:52 -0500 Subject: deprecate current_function.medium_level_il in favor of .mlil and move .instructions to mlil instead of main function -- likewise for llil --- python/binaryview.py | 2 +- python/function.py | 32 +++++++++++++++++++------------- python/lowlevelil.py | 7 +++++++ python/mediumlevelil.py | 7 +++++++ python/scriptingprovider.py | 4 ++-- 5 files changed, 36 insertions(+), 16 deletions(-) (limited to 'python') diff --git a/python/binaryview.py b/python/binaryview.py index fd15de76..6ecca2dc 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -874,7 +874,7 @@ class BinaryView(object): def mlil_basic_blocks(self): """A generator of all MediumLevelILBasicBlock objects in the BinaryView""" for func in self: - for il_block in func.medium_level_il.basic_blocks: + for il_block in func.mlil.basic_blocks: yield il_block @property diff --git a/python/function.py b/python/function.py index dce57975..bda06091 100644 --- a/python/function.py +++ b/python/function.py @@ -503,6 +503,11 @@ class Function(object): @property def low_level_il(self): + """Deprecated property provided for compatibility. Use llil instead.""" + return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelIL(self.handle), self) + + @property + def llil(self): """returns LowLevelILFunction used to represent Function low level IL (read-only)""" return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelIL(self.handle), self) @@ -513,6 +518,11 @@ class Function(object): @property def medium_level_il(self): + """Deprecated property provided for compatibility. Use mlil instead.""" + return binaryninja.mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) + + @property + def mlil(self): """Function medium level IL (read-only)""" return binaryninja.mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) @@ -786,13 +796,13 @@ class Function(object): @property def llil_basic_blocks(self): """A generator of all LowLevelILBasicBlock objects in the current function""" - for block in self.low_level_il: + for block in self.llil: yield block @property def mlil_basic_blocks(self): """A generator of all MediumLevelILBasicBlock objects in the current function""" - for block in self.medium_level_il: + for block in self.mlil: yield block @property @@ -806,17 +816,13 @@ class Function(object): @property def llil_instructions(self): - """A generator of llil instructions of the current function""" - for block in self.llil_basic_blocks: - for i in block: - yield i + """Deprecated method provided for compatibility. Use llil.instructions instead. Was: A generator of llil instructions of the current function""" + return self.llil.instructions @property def mlil_instructions(self): - """A generator of mlil instructions of the current function""" - for block in self.mlil_basic_blocks: - for i in block: - yield i + """Deprecated method provided for compatibility. Use mlil.instructions instead. Was: A generator of mlil instructions of the current function""" + return self.mlil.instructions @property def too_large(self): @@ -886,7 +892,7 @@ class Function(object): return core.BNGetCommentForAddress(self.handle, addr) def set_comment(self, addr, comment): - """Deprecated use set_comment_at instead""" + """Deprecated method provided for compatibility. Use set_comment_at instead.""" core.BNSetCommentForAddress(self.handle, addr, comment) def set_comment_at(self, addr, comment): @@ -921,10 +927,10 @@ class Function(object): idx = core.BNGetLowLevelILForInstruction(self.handle, arch.handle, addr) - if idx == len(self.low_level_il): + if idx == len(self.llil): return None - return self.low_level_il[idx] + return self.llil[idx] def get_low_level_il_exits_at(self, addr, arch=None): if arch is None: diff --git a/python/lowlevelil.py b/python/lowlevelil.py index c8db74b6..a98de6d3 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -791,6 +791,13 @@ class LowLevelILFunction(object): core.BNFreeBasicBlockList(blocks, count.value) return result + @property + def instructions(self): + """A generator of llil instructions of the current llil function""" + for block in self.basic_blocks: + for i in block: + yield i + @property def ssa_form(self): """Low level IL in SSA form (read-only)""" diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index e7059918..c88ab6b8 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -672,6 +672,13 @@ class MediumLevelILFunction(object): core.BNFreeBasicBlockList(blocks, count.value) return result + @property + def instructions(self): + """A generator of mlil instructions of the current function""" + for block in self.basic_blocks: + for i in block: + yield i + @property def ssa_form(self): """Medium level IL in SSA form (read-only)""" diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 52584ec7..4183f136 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -551,8 +551,8 @@ class PythonScriptingInstance(ScriptingInstance): self.locals["current_llil"] = None self.locals["current_mlil"] = None else: - self.locals["current_llil"] = self.active_func.low_level_il - self.locals["current_mlil"] = self.active_func.medium_level_il + self.locals["current_llil"] = self.active_func.llil + self.locals["current_mlil"] = self.active_func.mlil for line in code.split(b'\n'): self.interpreter.push(line.decode('charmap')) -- cgit v1.3.1