Module llil

Source
Expand description

More ergonomic matching over Binary Ninja’s low_level_il types

match_instr!{
    instr,
    // Basic patterns
    CallSsa(ConstPtr(address), _) => println!("Direct call to {:#x}", address),
     
    // Variable bindings and guards
    instr @ SetRegSsa(dest, add @ Add(RegSsa(src), Const(value))) if value > 10 => {
        println!(
            "Increment of {src:?} by {value} > 10 at {:#x} (dest={dest:?}, add={add:?})",
            instr.address(),
        );
    },
     
    // OR patterns
    CallSsa(_, _) | TailCallSsa(_, _) => println!("Function call"),
     
    _ => {}
};

NOTE: This currently only supports the operations I’ve had a need to match against. It will need to be expanded as it is used for more things.

Macros§

match_instr
match style pattern matching and destructuring of instructions and their expressions.
try_let_instr
let / else style pattern matching and destructuring of instructions and their expressions.

Structs§

BinaryExpression
Expression
Instruction

Enums§

ExpressionKind
InstructionKind

Functions§

is_full_register
Checks whether a given LowLevelILSSARegisterKind is a full register.
is_same_register
Checks if two LowLevelILSSARegisterKind instances represent the same register, irrespective of their version.
require_full_register
Extract the underlying LowLevelILRegisterKind from a LowLevelILSSARegisterKind if it is a full register. If not, logs a warning and returns None.

Derive Macros§

InstrMatch
Derive macro for mapping instruction pattern matching to structs.