summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2018-09-05 14:39:46 -0400
committerRusty Wagner <rusty@vector35.com>2018-09-05 14:39:46 -0400
commitf4d75c9229d2d76f36f80e97dd49c7aece242600 (patch)
tree0390fc2b624149274c5c01b847d59698055a2974 /python/mediumlevelil.py
parentc02c863367ff88c1e562a1110e069bf2842798aa (diff)
parente51031010b107089dd7b5b69039ac42b856a0769 (diff)
Merge branch 'test_stack_adjust' into dev
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index c024d287..a862adca 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -22,6 +22,7 @@ import ctypes
import struct
# Binary Ninja components
+import binaryninja
from binaryninja import _binaryninjacore as core
from binaryninja.enums import MediumLevelILOperation, InstructionTextTokenType, ILBranchDependence
from binaryninja import basicblock #required for MediumLevelILBasicBlock argument
@@ -128,6 +129,7 @@ class MediumLevelILInstruction(object):
MediumLevelILOperation.MLIL_LOW_PART: [("src", "expr")],
MediumLevelILOperation.MLIL_JUMP: [("dest", "expr")],
MediumLevelILOperation.MLIL_JUMP_TO: [("dest", "expr"), ("targets", "int_list")],
+ MediumLevelILOperation.MLIL_RET_HINT: [("dest", "expr")],
MediumLevelILOperation.MLIL_CALL: [("output", "var_list"), ("dest", "expr"), ("params", "expr_list")],
MediumLevelILOperation.MLIL_CALL_UNTYPED: [("output", "expr"), ("dest", "expr"), ("params", "expr"), ("stack", "expr")],
MediumLevelILOperation.MLIL_CALL_OUTPUT: [("dest", "var_list")],
@@ -229,6 +231,7 @@ class MediumLevelILInstruction(object):
name, operand_type = operand
if operand_type == "int":
value = instr.operands[i]
+ value = (value & ((1 << 63) - 1)) - (value & (1 << 63))
elif operand_type == "float":
if instr.size == 4:
value = struct.unpack("f", struct.pack("I", instr.operands[i] & 0xffffffff))[0]
@@ -614,9 +617,9 @@ class MediumLevelILFunction(object):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNMediumLevelILFunction)
else:
- func_handle = None
- if self.source_function is not None:
- func_handle = self.source_function.handle
+ if self.source_function is None:
+ raise ValueError("IL functions must be created with an associated function")
+ func_handle = self.source_function.handle
self.handle = core.BNCreateMediumLevelILFunction(arch.handle, func_handle)
def __del__(self):
@@ -937,6 +940,13 @@ class MediumLevelILFunction(object):
return None
return result
+ def create_graph(self, settings = None):
+ if settings is not None:
+ settings_obj = settings.handle
+ else:
+ settings_obj = None
+ return binaryninja.flowgraph.CoreFlowGraph(core.BNCreateMediumLevelILFunctionGraph(self.handle, settings_obj))
+
class MediumLevelILBasicBlock(basicblock.BasicBlock):
def __init__(self, view, handle, owner):