diff options
| author | Mason Reed <mason@vector35.com> | 2024-10-23 20:47:31 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2024-10-24 17:03:11 -0400 |
| commit | e151425087b6c0ee8c4d099bfc2d6d1268201db0 (patch) | |
| tree | 25160cf81aa6d650cf1497a078acc50f0062757c /plugins/warp/src/plugin/find.rs | |
| parent | 0f53c21d6a7abbfd48fd59ec7c15586f02777b7e (diff) | |
Add WARP integration
https://github.com/Vector35/warp/
Diffstat (limited to 'plugins/warp/src/plugin/find.rs')
| -rw-r--r-- | plugins/warp/src/plugin/find.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/warp/src/plugin/find.rs b/plugins/warp/src/plugin/find.rs new file mode 100644 index 00000000..7f089c2f --- /dev/null +++ b/plugins/warp/src/plugin/find.rs @@ -0,0 +1,57 @@ +use binaryninja::binaryview::{BinaryView, BinaryViewExt}; +use binaryninja::command::Command; +use rayon::prelude::*; +use std::thread; +use warp::signature::function::FunctionGUID; + +use crate::cache::cached_function_guid; + +pub struct FindFunctionFromGUID; + +impl Command for FindFunctionFromGUID { + fn action(&self, view: &BinaryView) { + let Some(guid_str) = binaryninja::interaction::get_text_line_input( + "Function GUID", + "Find Function from GUID", + ) else { + return; + }; + + let Ok(searched_guid) = guid_str.parse::<FunctionGUID>() else { + log::error!("Failed to parse function guid... {}", guid_str); + return; + }; + + log::info!("Searching functions for GUID... {}", searched_guid); + let funcs = view.functions(); + thread::spawn(move || { + let background_task = binaryninja::backgroundtask::BackgroundTask::new( + format!("Searching functions for GUID... {}", searched_guid), + true, + ) + .unwrap(); + + // TODO: While background_task has not finished. + let matched = funcs + .par_iter() + .filter_map(|func| { + Some(( + func.clone(), + cached_function_guid(&func, func.low_level_il_if_available()?.as_ref())?, + )) + }) + .filter(|(_func, guid)| guid.eq(&searched_guid)) + .collect::<Vec<_>>(); + + for (func, _) in matched { + log::info!("Match found at function... 0x{:0x}", func.start()); + } + + background_task.finish(); + }); + } + + fn valid(&self, _view: &BinaryView) -> bool { + true + } +} |
