From 072c5cd6eee7af9671e6c4fe583e77bc3bcbdd1d Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 14 Apr 2020 21:25:41 -0400 Subject: Add IL support to linear view --- python/function.py | 15 +++++++++++++++ python/lineardisassembly.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) (limited to 'python') diff --git a/python/function.py b/python/function.py index bdd04590..7cee467c 100644 --- a/python/function.py +++ b/python/function.py @@ -1214,11 +1214,21 @@ class Function(object): """returns LowLevelILFunction used to represent Function low level IL (read-only)""" return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelIL(self.handle), self) + @property + def llil_if_available(self): + """returns LowLevelILFunction used to represent Function low level IL, or None if not loaded (read-only)""" + return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLowLevelILIfAvailable(self.handle), self) + @property def lifted_il(self): """returns LowLevelILFunction used to represent lifted IL (read-only)""" return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLiftedIL(self.handle), self) + @property + def lifted_il_if_available(self): + """returns LowLevelILFunction used to represent lifted IL, or None if not loaded (read-only)""" + return binaryninja.lowlevelil.LowLevelILFunction(self.arch, core.BNGetFunctionLiftedILIfAvailable(self.handle), self) + @property def medium_level_il(self): """Deprecated property provided for compatibility. Use mlil instead.""" @@ -1229,6 +1239,11 @@ class Function(object): """Function medium level IL (read-only)""" return binaryninja.mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelIL(self.handle), self) + @property + def mlil_if_available(self): + """Function medium level IL, or None if not loaded (read-only)""" + return binaryninja.mediumlevelil.MediumLevelILFunction(self.arch, core.BNGetFunctionMediumLevelILIfAvailable(self.handle), self) + @property def function_type(self): """Function type object, can be set with either a string representing the function prototype (`str(function)` shows examples) or a :py:class:`Type` object""" diff --git a/python/lineardisassembly.py b/python/lineardisassembly.py index a23c829f..ec213a19 100644 --- a/python/lineardisassembly.py +++ b/python/lineardisassembly.py @@ -258,6 +258,48 @@ class LinearViewObject(object): settings = settings.handle return LinearViewObject(core.BNCreateLinearViewDisassembly(view.handle, settings)) + @classmethod + def lifted_il(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewLiftedIL(view.handle, settings)) + + @classmethod + def llil(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewLowLevelIL(view.handle, settings)) + + @classmethod + def llil_ssa_form(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewLowLevelILSSAForm(view.handle, settings)) + + @classmethod + def mlil(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewMediumLevelIL(view.handle, settings)) + + @classmethod + def mlil_ssa_form(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewMediumLevelILSSAForm(view.handle, settings)) + + @classmethod + def mmlil(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewMappedMediumLevelIL(view.handle, settings)) + + @classmethod + def mmlil_ssa_form(cls, view, settings = None): + if settings is not None: + settings = settings.handle + return LinearViewObject(core.BNCreateLinearViewMappedMediumLevelILSSAForm(view.handle, settings)) + class LinearViewCursor(object): def __init__(self, root_object, handle = None): -- cgit v1.3.1