summaryrefslogtreecommitdiff
path: root/plugins/warp/src/plugin/load.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-15 06:12:37 -0400
committerMason Reed <mason@vector35.com>2025-07-15 12:34:43 -0400
commita3773b6922543075750a5b4ed47e79f34e60d800 (patch)
tree542d88518fd3b381e1ddf06c0c4be959678ffa20 /plugins/warp/src/plugin/load.rs
parentd6c098813fde016e225c4ee072f38cd69d9783f0 (diff)
[WARP] Misc improvements
- Fix project file filter not blacklisting warp files - Fix project name not being used for default file save name - Prevent adding the same file to the available sources
Diffstat (limited to 'plugins/warp/src/plugin/load.rs')
-rw-r--r--plugins/warp/src/plugin/load.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/warp/src/plugin/load.rs b/plugins/warp/src/plugin/load.rs
index c0319ea5..cef6ea11 100644
--- a/plugins/warp/src/plugin/load.rs
+++ b/plugins/warp/src/plugin/load.rs
@@ -1,4 +1,4 @@
-use crate::cache::container::add_cached_container;
+use crate::cache::container::{add_cached_container, for_cached_containers};
use crate::container::disk::{DiskContainer, DiskContainerSource};
use crate::container::{ContainerError, SourcePath};
use crate::convert::platform_to_target;
@@ -12,6 +12,7 @@ use binaryninja::interaction::{
use binaryninja::rc::Ref;
use std::collections::HashMap;
use std::path::PathBuf;
+use std::sync::atomic::AtomicBool;
use std::thread;
use warp::WarpFile;
@@ -125,6 +126,7 @@ impl LoadSignatureFile {
let rerun_matcher = RunMatcherField::from_form(&form).unwrap_or(false);
let source_file_path = SourcePath::new(file_path.clone());
+ let source_file_id = source_file_path.to_source_id();
let file = match LoadSignatureFile::read_file(&view, source_file_path.clone()) {
Ok(file) => file,
@@ -134,6 +136,26 @@ impl LoadSignatureFile {
}
};
+ // Verify we have not already loaded the file.
+ let already_exists = AtomicBool::new(false);
+ for_cached_containers(|c| {
+ if let Ok(_) = c.source_path(&source_file_id) {
+ // TODO: What happens if path differs? Warn?
+ already_exists.store(true, std::sync::atomic::Ordering::SeqCst);
+ }
+ });
+ if already_exists.load(std::sync::atomic::Ordering::SeqCst) {
+ let res = show_message_box(
+ "Load again?",
+ "File already loaded, would you like to load it again?",
+ MessageBoxButtonSet::YesNoButtonSet,
+ MessageBoxIcon::WarningIcon,
+ );
+ if res != MessageBoxButtonResult::YesButton {
+ return;
+ }
+ }
+
let container_source = DiskContainerSource::new(source_file_path.clone(), file);
log::info!("Loading container source: '{}'", container_source.path);
let mut map = HashMap::new();