diff options
| author | Mason Reed <mason@vector35.com> | 2025-08-06 21:07:02 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-08-08 02:46:59 +0000 |
| commit | 1d25b8cb9304f53f80d1df960341d7c21d40ab13 (patch) | |
| tree | faec7e6f5d21e33ecdf39410858176da9eb4f86d /plugins/warp/src/plugin | |
| parent | 534627a04c77aa6791be25ad04deefa9b37034f5 (diff) | |
[WARP] Move symbol and comment application to when matched functions are inserted
Instead of applying symbols and comments in the applier step, we will do it when the matched function is identified.
This has the side effect that if you turn off the apply activity names and comments will still be applied, more work to be done later.
Diffstat (limited to 'plugins/warp/src/plugin')
| -rw-r--r-- | plugins/warp/src/plugin/ffi/function.rs | 4 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/workflow.rs | 17 |
2 files changed, 5 insertions, 16 deletions
diff --git a/plugins/warp/src/plugin/ffi/function.rs b/plugins/warp/src/plugin/ffi/function.rs index a7ec6593..7563bd96 100644 --- a/plugins/warp/src/plugin/ffi/function.rs +++ b/plugins/warp/src/plugin/ffi/function.rs @@ -67,7 +67,7 @@ pub unsafe extern "C" fn BNWARPFunctionApply( let analysis_function = Function::from_raw(analysis_function); match function.is_null() { false => { - // Set the matched function to `function` and return previous. + // Set the matched function to `function`. let matched_function = ManuallyDrop::new(Arc::from_raw(function)); insert_cached_function_match( &analysis_function, @@ -75,7 +75,7 @@ pub unsafe extern "C" fn BNWARPFunctionApply( ) } true => { - // We are removing the previous match and returning it. + // We are removing the previous match. insert_cached_function_match(&analysis_function, None) } }; diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs index 624fe0ef..2a8f6287 100644 --- a/plugins/warp/src/plugin/workflow.rs +++ b/plugins/warp/src/plugin/workflow.rs @@ -3,9 +3,7 @@ use crate::cache::{ cached_function_guid, insert_cached_function_match, try_cached_function_guid, try_cached_function_match, }; -use crate::convert::{ - comment_to_bn_comment, platform_to_target, to_bn_symbol_at_address, to_bn_type, -}; +use crate::convert::{platform_to_target, to_bn_type}; use crate::matcher::{Matcher, MatcherSettings}; use crate::{get_warp_tag_type, relocatable_regions}; use binaryninja::architecture::RegisterId; @@ -192,16 +190,13 @@ pub fn run_matcher(view: &BinaryView) { } pub fn insert_workflow() { + // TODO: Note: because of symbol persistence function symbol is applied in `insert_cached_function_match`. + // TODO: Comments are also applied there, they are "user" like, persisted and make undo actions. // "Hey look, it's a plier" ~ Josh 2025 let apply_activity = |ctx: &AnalysisContext| { let view = ctx.view(); let function = ctx.function(); if let Some(matched_function) = try_cached_function_match(&function) { - view.define_auto_symbol(&to_bn_symbol_at_address( - &view, - &matched_function.symbol, - function.symbol().address(), - )); // core.function.propagateAnalysis will assign user type info to auto, so we must not apply // otherwise we will wipe over user type info. if !function.has_user_type() { @@ -209,12 +204,6 @@ pub fn insert_workflow() { function.set_auto_type(&to_bn_type(&function.arch(), func_ty)); } } - // TODO: How to clear the comments? They are just persisted. - // TODO: Also they generate an undo action, i hate implicit undo actions so much. - for comment in matched_function.comments { - let bn_comment = comment_to_bn_comment(&function, comment); - function.set_comment_at(bn_comment.addr, &bn_comment.comment); - } if let Some(mlil) = ctx.mlil_function() { for variable in matched_function.variables { let decl_addr = ((function.start() as i64) + variable.offset) as u64; |
