From 2d731fed5b1942143fd3991fd3b60667707a47a5 Mon Sep 17 00:00:00 2001 From: Josh Watson Date: Wed, 24 Apr 2019 14:10:39 -0700 Subject: Add LowLevelILFunction.replace_expr method Expose the BNReplaceLowLevelILExpr core API via a new method on LowLevelILFunction, replace_expr --- python/lowlevelil.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index efa92a7a..9435fd5c 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -939,6 +939,19 @@ class LowLevelILFunction(object): flags = 0 return LowLevelILExpr(core.BNLowLevelILAddExpr(self.handle, operation, size, flags, a, b, c, d)) + def replace_expr(self, original, new): + if isinstance(original, LowLevelILInstruction): + original = original.expr_index + elif isinstance(original, LowLevelILExpr): + original = original.index + + if isinstance(new, LowLevelILInstruction): + new = new.expr_index + elif isinstance(new, LowLevelILExpr): + new = new.index + + core.BNReplaceLowLevelILExpr(self.handle, original, new) + def append(self, expr): """ ``append`` adds the LowLevelILExpr ``expr`` to the current LowLevelILFunction. -- cgit v1.3.1