diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-30 16:39:32 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-05-30 19:17:10 -0400 |
| commit | 68b00cdf45551ba64c4f7217963055fc5a1a0cc4 (patch) | |
| tree | f6bdef06bc02d16596bdf62870c8a1cfafe49859 /rust/src/medium_level_il/operation.rs | |
| parent | 77ab5e812af200b8e3bca0aac31d5fe0f638fba3 (diff) | |
[Rust] Express expression vs instruction index for MLIL and HLIL APIs
This was done to fix unintended behavior using an instruction or expression index in place of the other.
Fixes https://github.com/Vector35/binaryninja-api/issues/6897
Diffstat (limited to 'rust/src/medium_level_il/operation.rs')
| -rw-r--r-- | rust/src/medium_level_il/operation.rs | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/rust/src/medium_level_il/operation.rs b/rust/src/medium_level_il/operation.rs index e8b70cc6..578087d0 100644 --- a/rust/src/medium_level_il/operation.rs +++ b/rust/src/medium_level_il/operation.rs @@ -1,4 +1,6 @@ -use super::{MediumLevelILLiftedInstruction, MediumLevelInstructionIndex}; +use super::{ + MediumLevelExpressionIndex, MediumLevelILLiftedInstruction, MediumLevelInstructionIndex, +}; use crate::architecture::CoreIntrinsic; use crate::variable::{ConstantData, SSAVariable, Variable}; use std::collections::BTreeMap; @@ -6,7 +8,7 @@ use std::collections::BTreeMap; // IF #[derive(Debug, Copy, Clone)] pub struct MediumLevelILOperationIf { - pub condition: usize, + pub condition: MediumLevelExpressionIndex, pub dest_true: MediumLevelInstructionIndex, pub dest_false: MediumLevelInstructionIndex, } @@ -51,7 +53,7 @@ pub struct LiftedConstData { // JUMP, RET_HINT #[derive(Debug, Copy, Clone)] pub struct Jump { - pub dest: usize, + pub dest: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedJump { @@ -61,10 +63,10 @@ pub struct LiftedJump { // STORE_SSA #[derive(Debug, Copy, Clone)] pub struct StoreSsa { - pub dest: usize, + pub dest: MediumLevelExpressionIndex, pub dest_memory: u64, pub src_memory: u64, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedStoreSsa { @@ -77,11 +79,11 @@ pub struct LiftedStoreSsa { // STORE_STRUCT_SSA #[derive(Debug, Copy, Clone)] pub struct StoreStructSsa { - pub dest: usize, + pub dest: MediumLevelExpressionIndex, pub offset: u64, pub dest_memory: u64, pub src_memory: u64, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedStoreStructSsa { @@ -95,9 +97,9 @@ pub struct LiftedStoreStructSsa { // STORE_STRUCT #[derive(Debug, Copy, Clone)] pub struct StoreStruct { - pub dest: usize, + pub dest: MediumLevelExpressionIndex, pub offset: u64, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedStoreStruct { @@ -109,8 +111,8 @@ pub struct LiftedStoreStruct { // STORE #[derive(Debug, Copy, Clone)] pub struct Store { - pub dest: usize, - pub src: usize, + pub dest: MediumLevelExpressionIndex, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedStore { @@ -121,7 +123,7 @@ pub struct LiftedStore { // JUMP_TO #[derive(Debug, Copy, Clone)] pub struct JumpTo { - pub dest: usize, + pub dest: MediumLevelExpressionIndex, pub first_operand: usize, pub num_operands: usize, } @@ -148,7 +150,7 @@ pub struct FreeVarSlot { pub struct SetVarField { pub dest: Variable, pub offset: u64, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarField { @@ -161,8 +163,7 @@ pub struct LiftedSetVarField { #[derive(Debug, Copy, Clone)] pub struct SetVar { pub dest: Variable, - // TODO: Expression? - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVar { @@ -183,7 +184,7 @@ pub struct SetVarSsaField { pub dest: SSAVariable, pub prev: SSAVariable, pub offset: u64, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarSsaField { @@ -198,7 +199,7 @@ pub struct LiftedSetVarSsaField { pub struct SetVarAliased { pub dest: SSAVariable, pub prev: SSAVariable, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarAliased { @@ -211,7 +212,7 @@ pub struct LiftedSetVarAliased { #[derive(Debug, Copy, Clone)] pub struct SetVarSsa { pub dest: SSAVariable, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarSsa { @@ -257,7 +258,7 @@ pub struct VarSplit { pub struct SetVarSplit { pub high: Variable, pub low: Variable, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarSplit { @@ -278,7 +279,7 @@ pub struct VarSplitSsa { pub struct SetVarSplitSsa { pub high: SSAVariable, pub low: SSAVariable, - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSetVarSplitSsa { @@ -290,8 +291,8 @@ pub struct LiftedSetVarSplitSsa { // ADD, SUB, AND, OR, XOR, LSL, LSR, ASR, ROL, ROR, MUL, MULU_DP, MULS_DP, DIVU, DIVU_DP, DIVS, DIVS_DP, MODU, MODU_DP, MODS, MODS_DP, CMP_E, CMP_NE, CMP_SLT, CMP_ULT, CMP_SLE, CMP_ULE, CMP_SGE, CMP_UGE, CMP_SGT, CMP_UGT, TEST_BIT, ADD_OVERFLOW, FCMP_E, FCMP_NE, FCMP_LT, FCMP_LE, FCMP_GE, FCMP_GT, FCMP_O, FCMP_UO, FADD, FSUB, FMUL, FDIV #[derive(Debug, Copy, Clone)] pub struct BinaryOp { - pub left: usize, - pub right: usize, + pub left: MediumLevelExpressionIndex, + pub right: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedBinaryOp { @@ -302,9 +303,9 @@ pub struct LiftedBinaryOp { // ADC, SBB, RLC, RRC #[derive(Debug, Copy, Clone)] pub struct BinaryOpCarry { - pub left: usize, - pub right: usize, - pub carry: usize, + pub left: MediumLevelExpressionIndex, + pub right: MediumLevelExpressionIndex, + pub carry: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedBinaryOpCarry { @@ -318,7 +319,7 @@ pub struct LiftedBinaryOpCarry { pub struct Call { pub first_output: usize, pub num_outputs: usize, - pub dest: usize, + pub dest: MediumLevelExpressionIndex, pub first_param: usize, pub num_params: usize, } @@ -426,7 +427,7 @@ pub struct LiftedIntrinsicSsa { // MEMORY_INTRINSIC_SSA #[derive(Debug, Copy, Clone)] pub struct MemoryIntrinsicSsa { - pub output: usize, + pub output: MediumLevelExpressionIndex, pub intrinsic: u32, pub first_param: usize, pub num_params: usize, @@ -456,8 +457,8 @@ pub struct LiftedMemoryIntrinsicOutputSsa { // CALL_SSA, TAILCALL_SSA #[derive(Debug, Copy, Clone)] pub struct CallSsa { - pub output: usize, - pub dest: usize, + pub output: MediumLevelExpressionIndex, + pub dest: MediumLevelExpressionIndex, pub first_param: usize, pub num_params: usize, pub src_memory: u64, @@ -473,10 +474,10 @@ pub struct LiftedCallSsa { // CALL_UNTYPED_SSA, TAILCALL_UNTYPED_SSA #[derive(Debug, Copy, Clone)] pub struct CallUntypedSsa { - pub output: usize, - pub dest: usize, - pub params: usize, - pub stack: usize, + pub output: MediumLevelExpressionIndex, + pub dest: MediumLevelExpressionIndex, + pub params: MediumLevelExpressionIndex, + pub stack: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedCallUntypedSsa { @@ -489,7 +490,7 @@ pub struct LiftedCallUntypedSsa { // SYSCALL_SSA #[derive(Debug, Copy, Clone)] pub struct SyscallSsa { - pub output: usize, + pub output: MediumLevelExpressionIndex, pub first_param: usize, pub num_params: usize, pub src_memory: u64, @@ -504,9 +505,9 @@ pub struct LiftedSyscallSsa { // SYSCALL_UNTYPED_SSA #[derive(Debug, Copy, Clone)] pub struct SyscallUntypedSsa { - pub output: usize, - pub params: usize, - pub stack: usize, + pub output: MediumLevelExpressionIndex, + pub params: MediumLevelExpressionIndex, + pub stack: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSyscallUntypedSsa { @@ -518,10 +519,10 @@ pub struct LiftedSyscallUntypedSsa { // CALL_UNTYPED, TAILCALL_UNTYPED #[derive(Debug, Copy, Clone)] pub struct CallUntyped { - pub output: usize, - pub dest: usize, - pub params: usize, - pub stack: usize, + pub output: MediumLevelExpressionIndex, + pub dest: MediumLevelExpressionIndex, + pub params: MediumLevelExpressionIndex, + pub stack: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedCallUntyped { @@ -534,9 +535,9 @@ pub struct LiftedCallUntyped { // SYSCALL_UNTYPED #[derive(Debug, Copy, Clone)] pub struct SyscallUntyped { - pub output: usize, - pub params: usize, - pub stack: usize, + pub output: MediumLevelExpressionIndex, + pub params: MediumLevelExpressionIndex, + pub stack: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedSyscallUntyped { @@ -548,7 +549,7 @@ pub struct LiftedSyscallUntyped { // NEG, NOT, SX, ZX, LOW_PART, BOOL_TO_INT, UNIMPL_MEM, FSQRT, FNEG, FABS, FLOAT_TO_INT, INT_TO_FLOAT, FLOAT_CONV, ROUND_TO_INT, FLOOR, CEIL, FTRUNC, LOAD #[derive(Debug, Copy, Clone)] pub struct UnaryOp { - pub src: usize, + pub src: MediumLevelExpressionIndex, } #[derive(Clone, Debug, PartialEq)] pub struct LiftedUnaryOp { @@ -558,7 +559,7 @@ pub struct LiftedUnaryOp { // LOAD_STRUCT #[derive(Debug, Copy, Clone)] pub struct LoadStruct { - pub src: usize, + pub src: MediumLevelExpressionIndex, pub offset: u64, } #[derive(Clone, Debug, PartialEq)] @@ -570,7 +571,7 @@ pub struct LiftedLoadStruct { // LOAD_STRUCT_SSA #[derive(Debug, Copy, Clone)] pub struct LoadStructSsa { - pub src: usize, + pub src: MediumLevelExpressionIndex, pub offset: u64, pub src_memory: u64, } @@ -584,7 +585,7 @@ pub struct LiftedLoadStructSsa { // LOAD_SSA #[derive(Debug, Copy, Clone)] pub struct LoadSsa { - pub src: usize, + pub src: MediumLevelExpressionIndex, pub src_memory: u64, } #[derive(Clone, Debug, PartialEq)] |
