From 7e32ee8b629e3e4f8d061cbe0729ff961b3502d7 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sat, 10 May 2025 19:24:35 -0400 Subject: [Rust] Remove `NonSSAVariant` bound from `LowLevelILFunction` We don't do enough with the lifted il != non lifted il to justify the bound. This makes modifying IL much less work as the historical lifted il bound is gone. --- plugins/warp/src/cache.rs | 14 ++++++-------- plugins/warp/src/lib.rs | 16 +++++++--------- plugins/warp/src/plugin/workflow.rs | 3 +-- 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'plugins') diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs index 7219b547..cc8dfded 100644 --- a/plugins/warp/src/cache.rs +++ b/plugins/warp/src/cache.rs @@ -3,10 +3,8 @@ use crate::{build_function, function_guid}; use binaryninja::binary_view::{BinaryView, BinaryViewExt}; use binaryninja::confidence::MAX_CONFIDENCE; use binaryninja::function::Function as BNFunction; -use binaryninja::low_level_il::function::{ - FunctionMutability, LowLevelILFunction, NonSSA, RegularNonSSA, -}; -use binaryninja::low_level_il::RegularLowLevelILFunction; +use binaryninja::low_level_il::function::{FunctionMutability, LowLevelILFunction, NonSSA}; +use binaryninja::low_level_il::LowLevelILRegularFunction; use binaryninja::rc::Guard; use binaryninja::rc::Ref as BNRef; use binaryninja::symbol::Symbol as BNSymbol; @@ -67,7 +65,7 @@ pub fn try_cached_function_match(function: &BNFunction) -> Option { .to_owned() } -pub fn cached_function(function: &BNFunction, llil: &RegularLowLevelILFunction) -> Function { +pub fn cached_function(function: &BNFunction, llil: &LowLevelILRegularFunction) -> Function { let view = function.view(); let view_id = ViewID::from(view.as_ref()); let function_cache = FUNCTION_CACHE.get_or_init(Default::default); @@ -120,7 +118,7 @@ where pub fn cached_function_guid( function: &BNFunction, - llil: &LowLevelILFunction>, + llil: &LowLevelILFunction, ) -> FunctionGUID { let view = function.view(); let view_id = ViewID::from(view); @@ -198,7 +196,7 @@ pub struct FunctionCache { } impl FunctionCache { - pub fn function(&self, function: &BNFunction, llil: &RegularLowLevelILFunction) -> Function { + pub fn function(&self, function: &BNFunction, llil: &LowLevelILRegularFunction) -> Function { let function_id = FunctionID::from(function); match self.cache.get(&function_id) { Some(function) => function.value().to_owned(), @@ -325,7 +323,7 @@ impl GUIDCache { pub fn function_guid( &self, function: &BNFunction, - llil: &LowLevelILFunction>, + llil: &LowLevelILFunction, ) -> FunctionGUID { let function_id = FunctionID::from(function); match self.cache.get(&function_id) { diff --git a/plugins/warp/src/lib.rs b/plugins/warp/src/lib.rs index 3d68b402..62af0102 100644 --- a/plugins/warp/src/lib.rs +++ b/plugins/warp/src/lib.rs @@ -10,9 +10,7 @@ use binaryninja::binary_view::BinaryViewExt; use binaryninja::confidence::MAX_CONFIDENCE; use binaryninja::function::{Function as BNFunction, NativeBlock}; use binaryninja::low_level_il::expression::{ExpressionHandler, LowLevelILExpressionKind}; -use binaryninja::low_level_il::function::{ - FunctionMutability, LowLevelILFunction, NonSSA, RegularNonSSA, -}; +use binaryninja::low_level_il::function::{FunctionMutability, LowLevelILFunction, NonSSA}; use binaryninja::low_level_il::instruction::{ InstructionHandler, LowLevelILInstruction, LowLevelILInstructionKind, }; @@ -46,7 +44,7 @@ pub fn user_signature_dir() -> PathBuf { pub fn build_function( func: &BNFunction, - llil: &LowLevelILFunction>, + llil: &LowLevelILFunction, ) -> Function { let bn_fn_ty = func.function_type(); Function { @@ -78,7 +76,7 @@ pub fn sorted_basic_blocks(func: &BNFunction) -> Vec( func: &BNFunction, - llil: &LowLevelILFunction>, + llil: &LowLevelILFunction, ) -> FunctionGUID { let basic_blocks = sorted_basic_blocks(func); let basic_block_guids = basic_blocks @@ -90,7 +88,7 @@ pub fn function_guid( pub fn basic_block_guid( basic_block: &BNBasicBlock, - llil: &LowLevelILFunction>, + llil: &LowLevelILFunction, ) -> BasicBlockGUID { let func = basic_block.function(); let view = func.view(); @@ -98,7 +96,7 @@ pub fn basic_block_guid( let max_instr_len = arch.max_instr_len(); // NOPs and useless moves are blacklisted to allow for hot-patchable functions. - let is_blacklisted_instr = |instr: &LowLevelILInstruction>| { + let is_blacklisted_instr = |instr: &LowLevelILInstruction| { match instr.kind() { LowLevelILInstructionKind::Nop(_) => true, LowLevelILInstructionKind::SetReg(op) => { @@ -126,8 +124,8 @@ pub fn basic_block_guid( } }; - let is_variant_instr = |instr: &LowLevelILInstruction>| { - let is_variant_expr = |expr: &LowLevelILExpressionKind>| { + let is_variant_instr = |instr: &LowLevelILInstruction| { + let is_variant_expr = |expr: &LowLevelILExpressionKind| { // TODO: Checking the section here is slow, we should gather all section ranges outside of this. match expr { LowLevelILExpressionKind::ConstPtr(op) diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs index 9f7c4d0d..f5763116 100644 --- a/plugins/warp/src/plugin/workflow.rs +++ b/plugins/warp/src/plugin/workflow.rs @@ -3,7 +3,6 @@ use crate::matcher::cached_function_matcher; use binaryninja::background_task::BackgroundTask; use binaryninja::binary_view::{BinaryView, BinaryViewExt}; use binaryninja::command::Command; -use binaryninja::low_level_il::function::RegularNonSSA; use binaryninja::workflow::{Activity, AnalysisContext, Workflow}; use std::time::Instant; @@ -74,7 +73,7 @@ pub fn insert_workflow() { let guid_activity = |ctx: &AnalysisContext| { let function = ctx.function(); // TODO: Returning RegularNonSSA means we cant modify the il (the lifting code was written just for lifted il, that needs to be fixed) - if let Some(llil) = unsafe { ctx.llil_function::() } { + if let Some(llil) = unsafe { ctx.llil_function() } { cached_function_guid(&function, &llil); } }; -- cgit v1.3.1