From 0f0321bb94358b807fee1ba7a546f0762bf9785e Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Sun, 11 May 2025 07:04:35 -0700 Subject: [Rust] Don't panic when a Rust plug-in encounters an unhandled MLIL instruction `MediumLevelILInstruction` does not yet handle `MLIL_CALL_OUTPUT`, `MLIL_CALL_PARAM`, `MLIL_CALL_PARAM_SSA`, `MLIL_CALL_OUTPUT_SSA`, `MLIL_MEMORY_INTRINSIC_OUTPUT_SSA`, or `MLIL_MEMORY_INTRINSIC_SSA`. Map these to a `NotYetImplemented` kind rather than panicking since a panic takes down the entire app. --- rust/src/medium_level_il/instruction.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'rust/src/medium_level_il/instruction.rs') diff --git a/rust/src/medium_level_il/instruction.rs b/rust/src/medium_level_il/instruction.rs index 5e201478..ae550d91 100644 --- a/rust/src/medium_level_il/instruction.rs +++ b/rust/src/medium_level_il/instruction.rs @@ -609,9 +609,7 @@ impl MediumLevelILInstruction { | MLIL_CALL_PARAM_SSA | MLIL_CALL_OUTPUT_SSA | MLIL_MEMORY_INTRINSIC_OUTPUT_SSA - | MLIL_MEMORY_INTRINSIC_SSA => { - unimplemented!() - } + | MLIL_MEMORY_INTRINSIC_SSA => Op::NotYetImplemented, }; Self { @@ -633,6 +631,7 @@ impl MediumLevelILInstruction { Bp => Lifted::Bp, Undef => Lifted::Undef, Unimpl => Lifted::Unimpl, + NotYetImplemented => Lifted::NotYetImplemented, If(op) => Lifted::If(LiftedIf { condition: self.lift_operand(op.condition), dest_true: op.dest_true, @@ -1629,6 +1628,9 @@ pub enum MediumLevelILInstructionKind { VarSsaField(VarSsaField), VarAliasedField(VarSsaField), Trap(Trap), + // A placeholder for instructions that the Rust bindings do not yet support. + // Distinct from `Unimpl` as that is a valid instruction. + NotYetImplemented, } fn get_float(value: u64, size: usize) -> f64 { -- cgit v1.3.1