From 393c7fb508b465b0cb096d46eaaefc08030e9fed Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 4 Nov 2024 01:39:55 -0500 Subject: WARP: Fix analysis updates not being correctly marked We are running at the end of analysis now so we must invoke reanalysis --- plugins/warp/src/matcher.rs | 5 +---- plugins/warp/src/plugin.rs | 8 +++++--- plugins/warp/src/plugin/workflow.rs | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs index 59a26fcf..823ac2aa 100644 --- a/plugins/warp/src/matcher.rs +++ b/plugins/warp/src/matcher.rs @@ -1,7 +1,7 @@ use binaryninja::architecture::Architecture as BNArchitecture; use binaryninja::backgroundtask::BackgroundTask; use binaryninja::binaryview::{BinaryView, BinaryViewExt}; -use binaryninja::function::{Function as BNFunction, FunctionUpdateType}; +use binaryninja::function::Function as BNFunction; use binaryninja::platform::Platform; use binaryninja::rc::Guard; use binaryninja::rc::Ref as BNRef; @@ -239,9 +239,6 @@ impl Matcher { self.add_type_to_view(&view, &arch, &in_member.ty); } } - // Also mark this for updates. - // TODO: Does this do anything? - function.mark_updates_required(FunctionUpdateType::UserFunctionUpdate); }; if let Some(matched_function) = cached_function_match(function, || { diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs index b6e21578..ee9c633b 100644 --- a/plugins/warp/src/plugin.rs +++ b/plugins/warp/src/plugin.rs @@ -8,7 +8,7 @@ use crate::convert::{to_bn_symbol_at_address, to_bn_type}; use crate::matcher::{invalidate_function_matcher_cache, Matcher, PlatformID, PLAT_MATCHER_CACHE}; use binaryninja::binaryview::{BinaryView, BinaryViewExt}; use binaryninja::command::{Command, FunctionCommand}; -use binaryninja::function::Function; +use binaryninja::function::{Function, FunctionUpdateType}; use binaryninja::rc::Ref; use binaryninja::tags::TagType; use warp::signature::function::Function as WarpFunction; @@ -35,12 +35,12 @@ fn get_warp_tag_type(view: &BinaryView) -> Ref { // TODO: Rename to markup_function or something. pub fn on_matched_function(function: &Function, matched: &WarpFunction) { let view = function.view(); - view.define_auto_symbol(&to_bn_symbol_at_address( + view.define_user_symbol(&to_bn_symbol_at_address( &view, &matched.symbol, function.symbol().address(), )); - function.set_auto_type(&to_bn_type(&function.arch(), &matched.ty)); + function.set_user_type(&to_bn_type(&function.arch(), &matched.ty)); // TODO: Add metadata. (both binja metadata and warp metadata) function.add_tag( &get_warp_tag_type(&view), @@ -49,6 +49,8 @@ pub fn on_matched_function(function: &Function, matched: &WarpFunction) { true, None, ); + // Seems to be the only way to get the analysis update to work correctly. + function.mark_updates_required(FunctionUpdateType::FullAutoFunctionUpdate); } struct DebugFunction; diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs index bea5326e..d3c75876 100644 --- a/plugins/warp/src/plugin/workflow.rs +++ b/plugins/warp/src/plugin/workflow.rs @@ -63,6 +63,8 @@ pub fn insert_workflow() { .for_each(|function| cached_function_matcher(&function)); log::info!("Function matching took {:?}", start.elapsed()); background_task.finish(); + // Now we want to trigger re-analysis. + view.update_analysis(); }; let guid_activity = |ctx: &AnalysisContext| { -- cgit v1.3.1