summaryrefslogtreecommitdiff
path: root/plugins/warp/src/plugin.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.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.rs')
-rw-r--r--plugins/warp/src/plugin.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs
index 3373cafd..ad08e842 100644
--- a/plugins/warp/src/plugin.rs
+++ b/plugins/warp/src/plugin.rs
@@ -1,5 +1,11 @@
use log::LevelFilter;
+use crate::build_function;
+use crate::cache::{
+ register_cache_destructor, ViewID, FUNCTION_CACHE, GUID_CACHE, MATCHED_FUNCTION_CACHE,
+};
+use crate::convert::{to_bn_symbol_at_address, to_bn_type};
+use crate::matcher::{PlatformID, PLAT_MATCHER_CACHE};
use binaryninja::binaryview::{BinaryView, BinaryViewExt};
use binaryninja::command::{Command, FunctionCommand};
use binaryninja::function::Function;
@@ -7,11 +13,6 @@ use binaryninja::rc::Ref;
use binaryninja::tags::TagType;
use warp::signature::function::Function as WarpFunction;
-use crate::build_function;
-use crate::cache::{ViewID, FUNCTION_CACHE, GUID_CACHE};
-use crate::convert::{to_bn_symbol_at_address, to_bn_type};
-use crate::matcher::{PlatformID, PLAT_MATCHER_CACHE};
-
mod apply;
mod copy;
mod create;
@@ -67,12 +68,17 @@ struct DebugCache;
impl Command for DebugCache {
fn action(&self, view: &BinaryView) {
- let function_cache = FUNCTION_CACHE.get_or_init(Default::default);
let view_id = ViewID::from(view);
+ let function_cache = FUNCTION_CACHE.get_or_init(Default::default);
if let Some(cache) = function_cache.get(&view_id) {
log::info!("View functions: {}", cache.cache.len());
}
+ let matched_function_cache = MATCHED_FUNCTION_CACHE.get_or_init(Default::default);
+ if let Some(cache) = matched_function_cache.get(&view_id) {
+ log::info!("View matched functions: {}", cache.cache.len());
+ }
+
let function_guid_cache = GUID_CACHE.get_or_init(Default::default);
if let Some(cache) = function_guid_cache.get(&view_id) {
log::info!("View function guids: {}", cache.cache.len());
@@ -84,10 +90,6 @@ impl Command for DebugCache {
if let Some(cache) = plat_cache.get(&platform_id) {
log::info!("Platform functions: {}", cache.functions.len());
log::info!("Platform types: {}", cache.types.len());
- log::info!(
- "Platform matched functions: {}",
- cache.matched_functions.len()
- );
}
}
}
@@ -102,7 +104,10 @@ impl Command for DebugCache {
pub extern "C" fn CorePluginInit() -> bool {
binaryninja::logger::init(LevelFilter::Debug).unwrap();
- workflow::insert_matcher_workflow();
+ // Make sure caches are flushed when the views get destructed.
+ register_cache_destructor();
+
+ workflow::insert_workflow();
binaryninja::command::register(
"WARP\\Apply Signature File Types",