summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2019-01-29 19:52:52 -0500
committerRusty Wagner <rusty@vector35.com>2019-01-30 16:09:12 -0500
commit78fc76b12da21dae9be6c57d92e08691a533836f (patch)
tree2652620541088abc6d8e50564b78f3571bc5f31b /python/mediumlevelil.py
parentcbb196c27ff14928ac17bd97dc7a537726fbffed (diff)
Prepare API for Python UI bindings
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index a6867c60..a83cfff4 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -615,19 +615,27 @@ class MediumLevelILFunction(object):
objects can be added to the MediumLevelILFunction by calling ``append`` and passing the result of the various class
methods which return MediumLevelILExpr objects.
"""
- def __init__(self, arch, handle = None, source_func = None):
+ def __init__(self, arch = None, handle = None, source_func = None):
self.arch = arch
self.source_function = source_func
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNMediumLevelILFunction)
+ if self.source_function is None:
+ self.source_function = binaryninja.function.Function(handle = core.BNGetMediumLevelILOwnerFunction(self.handle))
+ if self.arch is None:
+ self.arch = self.source_function.arch
else:
if self.source_function is None:
+ self.handle = None
raise ValueError("IL functions must be created with an associated function")
+ if self.arch is None:
+ self.arch = self.source_function.arch
func_handle = self.source_function.handle
self.handle = core.BNCreateMediumLevelILFunction(arch.handle, func_handle)
def __del__(self):
- core.BNFreeMediumLevelILFunction(self.handle)
+ if self.handle is not None:
+ core.BNFreeMediumLevelILFunction(self.handle)
def __eq__(self, value):
if not isinstance(value, MediumLevelILFunction):
@@ -966,7 +974,7 @@ class MediumLevelILFunction(object):
class MediumLevelILBasicBlock(basicblock.BasicBlock):
def __init__(self, view, handle, owner):
- super(MediumLevelILBasicBlock, self).__init__(view, handle)
+ super(MediumLevelILBasicBlock, self).__init__(handle, view)
self.il_function = owner
def __iter__(self):