Skip to content

Commit

Permalink
Make Expression cloneable
Browse files Browse the repository at this point in the history
  • Loading branch information
emesare committed Jun 19, 2024
1 parent 7518e76 commit c1b9992
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions rust/src/llil/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ where
}
}

impl<'func, A, V, R> Clone for Expression<'func, A, Mutable, NonSSA<V>, R>
where
A: 'func + Architecture,
V: NonSSAVariant,
R: ExpressionResultType,
{
fn clone(&self) -> Self {
use binaryninjacore_sys::BNLowLevelILAddExpr;

let expr = unsafe {
BNGetLowLevelILByIndex(self.function.handle, self.expr_idx)
};

let cloned_expr_idx = unsafe {
BNLowLevelILAddExpr(
self.function.handle,
expr.operation,
expr.size,
expr.flags,
expr.operands[0],
expr.operands[1],
expr.operands[2],
expr.operands[3],
)
};

Expression::new(self.function, cloned_expr_idx)
}
}

fn common_info<'func, A, M, F>(
function: &'func Function<A, M, F>,
op: BNLowLevelILInstruction,
Expand Down

0 comments on commit c1b9992

Please sign in to comment.