summaryrefslogtreecommitdiff
path: root/rust/src/mlil/function.rs
diff options
context:
space:
mode:
authorMichael Krasnitski <michael.krasnitski@gmail.com>2024-02-08 19:50:49 -0500
committerKyle Martin <krm504@nyu.edu>2024-03-18 17:46:37 -0400
commit970fe84875e2d6eed918f5bdc9ff689ef37b05ce (patch)
tree31fe9d82a623693c92c5c1fc7d05daf69fad3da3 /rust/src/mlil/function.rs
parentf535df40f978d221547b45650b75aa1089e197ce (diff)
Make `OperandIter` generic over its function IL
Diffstat (limited to 'rust/src/mlil/function.rs')
-rw-r--r--rust/src/mlil/function.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/rust/src/mlil/function.rs b/rust/src/mlil/function.rs
index 16cc5102..3f96d8bb 100644
--- a/rust/src/mlil/function.rs
+++ b/rust/src/mlil/function.rs
@@ -2,16 +2,19 @@ use core::hash::{Hash, Hasher};
use binaryninjacore_sys::BNFreeMediumLevelILFunction;
use binaryninjacore_sys::BNGetMediumLevelILBasicBlockList;
+use binaryninjacore_sys::BNGetMediumLevelILByIndex;
use binaryninjacore_sys::BNGetMediumLevelILInstructionCount;
use binaryninjacore_sys::BNGetMediumLevelILOwnerFunction;
use binaryninjacore_sys::BNGetMediumLevelILSSAForm;
use binaryninjacore_sys::BNMediumLevelILFunction;
use binaryninjacore_sys::BNMediumLevelILGetInstructionStart;
+use binaryninjacore_sys::BNMediumLevelILInstruction;
+use binaryninjacore_sys::BNMediumLevelILOperation;
use binaryninjacore_sys::BNNewMediumLevelILFunctionReference;
use crate::basicblock::BasicBlock;
-use crate::function::Function;
use crate::function::Location;
+use crate::function::{Function, ILFunction};
use crate::rc::{Array, Ref, RefCountable};
use super::{MediumLevelILBlock, MediumLevelILInstruction, MediumLevelILLiftedInstruction};
@@ -93,6 +96,21 @@ impl MediumLevelILFunction {
}
}
+impl ILFunction for MediumLevelILFunction {
+ type BNInstruction = BNMediumLevelILInstruction;
+ type Instruction = MediumLevelILInstruction;
+
+ fn il_instruction_from_idx(&self, expr_idx: usize) -> Self::Instruction {
+ self.instruction_from_idx(expr_idx)
+ }
+
+ fn operands_from_idx(&self, expr_idx: usize) -> [u64; 5] {
+ let node = unsafe { BNGetMediumLevelILByIndex(self.handle, expr_idx) };
+ assert_eq!(node.operation, BNMediumLevelILOperation::MLIL_UNDEF);
+ node.operands
+ }
+}
+
impl ToOwned for MediumLevelILFunction {
type Owned = Ref<Self>;