From bd34931330858810a881b110f6b03ef198cb3664 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Thu, 20 Jun 2024 08:27:36 -0400 Subject: Create ExpressionBuilder from Expression --- rust/src/llil/lifting.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'rust/src') diff --git a/rust/src/llil/lifting.rs b/rust/src/llil/lifting.rs index e6226070..f8b8257e 100644 --- a/rust/src/llil/lifting.rs +++ b/rust/src/llil/lifting.rs @@ -607,6 +607,26 @@ where A: 'a + Architecture, R: ExpressionResultType, { + pub fn from_expr(expr: Expression<'a, A, Mutable, NonSSA, R>) -> Self { + use binaryninjacore_sys::BNGetLowLevelILByIndex; + + let instr = unsafe { + BNGetLowLevelILByIndex(expr.function.handle, expr.expr_idx) + }; + + ExpressionBuilder { + function: expr.function, + op: instr.operation, + size: instr.size, + flags: instr.flags, + op1: instr.operands[0], + op2: instr.operands[1], + op3: instr.operands[2], + op4: instr.operands[3], + _ty: PhantomData + } + } + pub fn with_flag_write(mut self, flag_write: A::FlagWrite) -> Self { // TODO verify valid id self.flags = flag_write.id(); -- cgit v1.3.1