diff options
| author | Mason Reed <mason@vector35.com> | 2024-12-01 18:20:12 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2024-12-01 18:21:31 -0500 |
| commit | 04120125575f3ee82010ed1760ad7c99fdd6a394 (patch) | |
| tree | 88ebffc719ef2cc96eb04b8953d072fbc1fc5c45 /plugins/warp/src/plugin | |
| parent | 0237e4d47493e60d256fd7332866b1a7f881abd9 (diff) | |
WARP: Prune useless functions and display progress in background task
Also bumps WARP so that loading of extremely large signature files can occur
Diffstat (limited to 'plugins/warp/src/plugin')
| -rw-r--r-- | plugins/warp/src/plugin/create.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs index dd21bd8f..20f6d65e 100644 --- a/plugins/warp/src/plugin/create.rs +++ b/plugins/warp/src/plugin/create.rs @@ -2,8 +2,12 @@ use crate::cache::{cached_function, cached_type_references}; use crate::matcher::invalidate_function_matcher_cache; use binaryninja::binaryview::{BinaryView, BinaryViewExt}; use binaryninja::command::Command; +use binaryninja::function::Function; +use binaryninja::rc::Guard; use rayon::prelude::*; use std::io::Write; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering::Relaxed; use std::thread; use std::time::Instant; @@ -13,6 +17,10 @@ pub struct CreateSignatureFile; impl Command for CreateSignatureFile { fn action(&self, view: &BinaryView) { + let is_function_named = |f: &Guard<Function>| { + !f.symbol().short_name().as_str().contains("sub_") || f.has_user_annotations() + }; + let mut signature_dir = binaryninja::user_directory().unwrap().join("signatures/"); if let Some(default_plat) = view.default_platform() { // If there is a default platform, put the signature in there. @@ -20,8 +28,10 @@ impl Command for CreateSignatureFile { } let view = view.to_owned(); thread::spawn(move || { + let total_functions = view.functions().len(); + let done_functions = AtomicUsize::default(); let background_task = binaryninja::backgroundtask::BackgroundTask::new( - format!("Generating {} signatures... ", view.functions().len()), + format!("Generating signatures... ({}/{})", 0, total_functions), true, ) .unwrap(); @@ -29,11 +39,20 @@ impl Command for CreateSignatureFile { let start = Instant::now(); let mut data = warp::signature::Data::default(); - data.functions - .par_extend(view.functions().par_iter().filter_map(|func| { - let llil = func.low_level_il().ok()?; - Some(cached_function(&func, &llil)) - })); + data.functions.par_extend( + view.functions() + .par_iter() + .inspect(|_| { + done_functions.fetch_add(1, Relaxed); + background_task.set_progress_text(format!("Generating signatures... ({}/{})", done_functions.load(Relaxed), total_functions)) + }) + .filter(is_function_named) + .filter(|f| !f.analysis_skipped()) + .filter_map(|func| { + let llil = func.low_level_il().ok()?; + Some(cached_function(&func, &llil)) + }), + ); if let Some(ref_ty_cache) = cached_type_references(&view) { let referenced_types = ref_ty_cache |
