summaryrefslogtreecommitdiff
path: root/plugins/idb_import/src/settings.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-01-20 14:30:34 -0800
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-23 21:50:02 -0700
commit1e85844d6407db817db25fd43f1dd9756ef0c3ae (patch)
treed6d2df2c3ed9403604fecff294be88d70fce5cf7 /plugins/idb_import/src/settings.rs
parent1f98e7ca7cce35ae4c2b4741f33e9892dd695534 (diff)
IDB Import refactor
Diffstat (limited to 'plugins/idb_import/src/settings.rs')
-rw-r--r--plugins/idb_import/src/settings.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/idb_import/src/settings.rs b/plugins/idb_import/src/settings.rs
new file mode 100644
index 00000000..1dca8bf2
--- /dev/null
+++ b/plugins/idb_import/src/settings.rs
@@ -0,0 +1,50 @@
+use binaryninja::binary_view::BinaryView;
+use binaryninja::settings::{QueryOptions, Settings};
+use serde_json::json;
+use std::path::PathBuf;
+
+#[derive(Debug, Clone)]
+pub struct LoadSettings {
+ pub auto_load_file: Option<PathBuf>,
+}
+
+impl LoadSettings {
+ pub const AUTO_LOAD_FILE_DEFAULT: &'static str = "";
+ pub const AUTO_LOAD_FILE_SETTING: &'static str = "analysis.idb.autoLoadFile";
+
+ pub fn register() {
+ let bn_settings = Settings::new();
+
+ let file_props = json!({
+ "title" : "IDB File",
+ "type" : "string",
+ "default" : Self::AUTO_LOAD_FILE_DEFAULT,
+ "description" : "The IDB File to automatically load when opening the view.",
+ "uiSelectionAction" : "file"
+ });
+ bn_settings.register_setting_json(Self::AUTO_LOAD_FILE_SETTING, &file_props.to_string());
+ }
+
+ pub fn from_view_settings(view: &BinaryView) -> Self {
+ let mut load_settings = LoadSettings::default();
+ let settings = Settings::new();
+ let mut query_opts = QueryOptions::new_with_view(view);
+ if settings.contains(Self::AUTO_LOAD_FILE_SETTING) {
+ let path_str =
+ settings.get_string_with_opts(Self::AUTO_LOAD_FILE_SETTING, &mut query_opts);
+ if !path_str.is_empty() {
+ let path = PathBuf::from(path_str.to_string());
+ load_settings.auto_load_file = Some(path);
+ }
+ }
+ load_settings
+ }
+}
+
+impl Default for LoadSettings {
+ fn default() -> Self {
+ Self {
+ auto_load_file: None,
+ }
+ }
+}