summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-12-14 12:52:42 -0500
committerMason Reed <mason@vector35.com>2024-12-14 12:52:42 -0500
commit82cd67b9313f249e12ee4fd248a40db9dc6b4a07 (patch)
treecd55ff882cdb89b5766eaee571e21cfb2d40711f /plugins
parent5239ad6e8345e691fde31fd9f513fcf200e942aa (diff)
WARP: Run `cargo fmt`
Diffstat (limited to 'plugins')
-rw-r--r--plugins/warp/src/cache.rs4
-rw-r--r--plugins/warp/src/lib.rs7
-rw-r--r--plugins/warp/src/matcher.rs4
-rw-r--r--plugins/warp/src/plugin/add.rs7
-rw-r--r--plugins/warp/src/plugin/create.rs7
5 files changed, 15 insertions, 14 deletions
diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs
index f39bceb2..8111ca51 100644
--- a/plugins/warp/src/cache.rs
+++ b/plugins/warp/src/cache.rs
@@ -28,7 +28,9 @@ pub fn register_cache_destructor() {
pub static mut CACHE_DESTRUCTOR: CacheDestructor = CacheDestructor;
#[allow(static_mut_refs)]
// SAFETY: This can be done as the backing data is an opaque ZST.
- unsafe { CACHE_DESTRUCTOR.register() };
+ unsafe {
+ CACHE_DESTRUCTOR.register()
+ };
}
pub fn cached_function_match<F>(function: &BNFunction, f: F) -> Option<Function>
diff --git a/plugins/warp/src/lib.rs b/plugins/warp/src/lib.rs
index dee5d26b..add8b822 100644
--- a/plugins/warp/src/lib.rs
+++ b/plugins/warp/src/lib.rs
@@ -1,4 +1,3 @@
-use std::path::PathBuf;
use binaryninja::architecture::{
Architecture, ImplicitRegisterExtend, Register as BNRegister, RegisterInfo,
};
@@ -11,6 +10,7 @@ use binaryninja::llil::{
VisitorAction,
};
use binaryninja::rc::Ref as BNRef;
+use std::path::PathBuf;
use warp::signature::basic_block::BasicBlockGUID;
use warp::signature::function::constraints::FunctionConstraints;
use warp::signature::function::{Function, FunctionGUID};
@@ -31,10 +31,7 @@ pub fn core_signature_dir() -> PathBuf {
let install_dir = binaryninja::install_directory().unwrap();
// macOS core dir is separate from the install dir.
#[cfg(target_os = "macos")]
- let core_dir = install_dir
- .parent()
- .unwrap()
- .join("Resources");
+ let core_dir = install_dir.parent().unwrap().join("Resources");
#[cfg(not(target_os = "macos"))]
let core_dir = install_dir;
core_dir.join("signatures")
diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs
index 86985cc2..8df72a20 100644
--- a/plugins/warp/src/matcher.rs
+++ b/plugins/warp/src/matcher.rs
@@ -23,8 +23,8 @@ use crate::cache::{
try_cached_function_guid,
};
use crate::convert::to_bn_type;
-use crate::{core_signature_dir, user_signature_dir};
use crate::plugin::on_matched_function;
+use crate::{core_signature_dir, user_signature_dir};
pub static PLAT_MATCHER_CACHE: OnceLock<DashMap<PlatformID, Matcher>> = OnceLock::new();
@@ -62,7 +62,7 @@ impl Matcher {
/// Create a matcher from the platforms signature subdirectory.
pub fn from_platform(platform: BNRef<Platform>) -> Self {
let platform_name = platform.name().to_string();
-
+
// Get core and user signatures.
// TODO: Separate each file into own bucket for filtering?
let plat_core_sig_dir = core_signature_dir().join(&platform_name);
diff --git a/plugins/warp/src/plugin/add.rs b/plugins/warp/src/plugin/add.rs
index 8b50425b..a81ad614 100644
--- a/plugins/warp/src/plugin/add.rs
+++ b/plugins/warp/src/plugin/add.rs
@@ -1,11 +1,11 @@
use crate::cache::{cached_function, cached_type_references};
use crate::matcher::invalidate_function_matcher_cache;
+use crate::user_signature_dir;
use binaryninja::binaryview::BinaryView;
use binaryninja::command::FunctionCommand;
use binaryninja::function::Function;
use std::io::Write;
use std::thread;
-use crate::user_signature_dir;
pub struct AddFunctionSignature;
@@ -20,14 +20,15 @@ impl FunctionCommand for AddFunctionSignature {
log::error!("Could not get low level IL for function.");
return;
};
-
+
// NOTE: Because we only can consume signatures from a specific directory, we don't need to use the interaction API.
// If we did need to save signature files to a project than this would need to change.
let Some(save_file) = rfd::FileDialog::new()
.add_filter("Signature Files", &["sbin"])
.set_file_name("user.sbin")
.set_directory(signature_dir)
- .save_file() else {
+ .save_file()
+ else {
return;
};
diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs
index beb866d8..a608a31d 100644
--- a/plugins/warp/src/plugin/create.rs
+++ b/plugins/warp/src/plugin/create.rs
@@ -1,5 +1,6 @@
use crate::cache::{cached_function, cached_type_references};
use crate::matcher::invalidate_function_matcher_cache;
+use crate::user_signature_dir;
use binaryninja::binaryview::{BinaryView, BinaryViewExt};
use binaryninja::command::Command;
use binaryninja::function::Function;
@@ -9,7 +10,6 @@ use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::thread;
use std::time::Instant;
-use crate::user_signature_dir;
pub struct CreateSignatureFile;
@@ -77,10 +77,11 @@ impl Command for CreateSignatureFile {
.add_filter("Signature Files", &["sbin"])
.set_file_name(format!("{}.sbin", view.file().filename().to_string()))
.set_directory(signature_dir)
- .save_file() else {
+ .save_file()
+ else {
return;
};
-
+
match std::fs::write(&save_file, data.to_bytes()) {
Ok(_) => {
log::info!("Signature file saved successfully.");