summaryrefslogtreecommitdiff
path: root/plugins/warp/src/plugin/workflow.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-10-28 21:20:03 -0400
committerMason Reed <mason@vector35.com>2024-10-28 21:21:55 -0400
commita38d13f32326b72e59503a8280f610c52e018366 (patch)
tree44ea154e651489cc3d3e5a5fb5d17f894ace784d /plugins/warp/src/plugin/workflow.rs
parent08f1c49f0cb7f74d0f50dcf60289e974ae9d5c3a (diff)
Refactor WARP to use a module workflow for matching
Also flush caches on view destruction and improve performance
Diffstat (limited to 'plugins/warp/src/plugin/workflow.rs')
-rw-r--r--plugins/warp/src/plugin/workflow.rs66
1 files changed, 47 insertions, 19 deletions
diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs
index da8473f0..bd47c117 100644
--- a/plugins/warp/src/plugin/workflow.rs
+++ b/plugins/warp/src/plugin/workflow.rs
@@ -1,38 +1,66 @@
-use crate::matcher::cached_function_match;
+use crate::cache::cached_function_guid;
+use crate::matcher::cached_function_matcher;
+use binaryninja::backgroundtask::BackgroundTask;
+use binaryninja::binaryview::BinaryViewExt;
use binaryninja::llil;
use binaryninja::workflow::{Activity, AnalysisContext, Workflow};
+use std::time::Instant;
-const MATCHER_ACTIVITY_NAME: &str = "analysis.plugins.WARPMatcher";
+const MATCHER_ACTIVITY_NAME: &str = "analysis.plugins.warp.matcher";
// NOTE: runOnce is off because previously matched functions need info applied.
const MATCHER_ACTIVITY_CONFIG: &str = r#"{
- "name": "analysis.plugins.WARPMatcher",
+ "name": "analysis.plugins.warp.matcher",
"title" : "WARP Matcher",
"description": "This analysis step applies WARP info to matched functions...",
"eligibility": {
- "auto": { "default": true },
+ "auto": {},
"runOnce": false
}
}"#;
-pub fn insert_matcher_workflow() {
+const GUID_ACTIVITY_NAME: &str = "analysis.plugins.warp.guid";
+const GUID_ACTIVITY_CONFIG: &str = r#"{
+ "name": "analysis.plugins.warp.guid",
+ "title" : "WARP GUID Generator",
+ "description": "This analysis step generates the GUID for all analyzed functions...",
+ "eligibility": {
+ "auto": {},
+ "runOnce": true
+ }
+}"#;
+
+pub fn insert_workflow() {
let matcher_activity = |ctx: &AnalysisContext| {
- let function = ctx.function();
- if function.has_user_annotations() {
- // User has touched the function, stop trying to match on it!
- return;
- }
+ let view = ctx.view();
+ let background_task = BackgroundTask::new("Matching on functions...", false).unwrap();
+ let start = Instant::now();
+ view.functions()
+ .iter()
+ .for_each(|function| cached_function_matcher(&function));
+ log::info!("Function matching took {:?}", start.elapsed());
+ background_task.finish();
+ };
+ let guid_activity = |ctx: &AnalysisContext| {
+ let function = ctx.function();
if let Some(llil) = unsafe { ctx.llil_function::<llil::NonSSA<llil::RegularNonSSA>>() } {
- cached_function_match(&function, &llil);
+ cached_function_guid(&function, &llil);
}
};
- let meta_workflow = Workflow::new_from_copy("core.function.metaAnalysis");
- let activity = Activity::new_with_action(MATCHER_ACTIVITY_CONFIG, matcher_activity);
- meta_workflow.register_activity(&activity).unwrap();
- meta_workflow.insert(
- "core.function.runFunctionRecognizers",
- [MATCHER_ACTIVITY_NAME],
- );
- meta_workflow.register().unwrap();
+ let function_meta_workflow = Workflow::new_from_copy("core.function.metaAnalysis");
+ let guid_activity = Activity::new_with_action(GUID_ACTIVITY_CONFIG, guid_activity);
+ function_meta_workflow
+ .register_activity(&guid_activity)
+ .unwrap();
+ function_meta_workflow.insert("core.function.runFunctionRecognizers", [GUID_ACTIVITY_NAME]);
+ function_meta_workflow.register().unwrap();
+
+ let module_meta_workflow = Workflow::new_from_copy("core.module.metaAnalysis");
+ let matcher_activity = Activity::new_with_action(MATCHER_ACTIVITY_CONFIG, matcher_activity);
+ module_meta_workflow
+ .register_activity(&matcher_activity)
+ .unwrap();
+ module_meta_workflow.insert("core.module.notifyCompletion", [MATCHER_ACTIVITY_NAME]);
+ module_meta_workflow.register().unwrap();
}