diff options
| author | Mason Reed <mason@vector35.com> | 2026-02-22 22:42:35 -0800 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-02-23 00:09:44 -0800 |
| commit | d0eec62d6df0edbbb76dfeac58879797e90a8594 (patch) | |
| tree | 03cf8d04eb7d33ac0785f2eede92ecbd552a48b0 /plugins | |
| parent | f3e0bf4ab35d50b11b2dbde41a699ab7497208d1 (diff) | |
Add global plugin command type
Register plugins which are available outside the context of a binary view
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/bntl_utils/src/command/create.rs | 8 | ||||
| -rw-r--r-- | plugins/bntl_utils/src/command/diff.rs | 9 | ||||
| -rw-r--r-- | plugins/bntl_utils/src/command/dump.rs | 10 | ||||
| -rw-r--r-- | plugins/bntl_utils/src/command/validate.rs | 9 | ||||
| -rw-r--r-- | plugins/bntl_utils/src/lib.rs | 8 | ||||
| -rw-r--r-- | plugins/warp/src/plugin.rs | 5 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/commit.rs | 9 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/create.rs | 15 |
8 files changed, 36 insertions, 37 deletions
diff --git a/plugins/bntl_utils/src/command/create.rs b/plugins/bntl_utils/src/command/create.rs index 5fa8c2be..96d0eb60 100644 --- a/plugins/bntl_utils/src/command/create.rs +++ b/plugins/bntl_utils/src/command/create.rs @@ -3,7 +3,7 @@ use crate::process::{new_processing_state_background_thread, TypeLibProcessor}; use crate::validate::TypeLibValidater; use binaryninja::background_task::BackgroundTask; use binaryninja::binary_view::{BinaryView, BinaryViewExt}; -use binaryninja::command::{Command, ProjectCommand}; +use binaryninja::command::{Command, GlobalCommand, ProjectCommand}; use binaryninja::interaction::{Form, FormInputField, MessageBoxButtonSet, MessageBoxIcon}; use binaryninja::platform::Platform; use binaryninja::project::Project; @@ -188,14 +188,14 @@ impl CreateFromDirectory { } } -impl Command for CreateFromDirectory { - fn action(&self, _view: &BinaryView) { +impl GlobalCommand for CreateFromDirectory { + fn action(&self) { thread::spawn(move || { CreateFromDirectory::execute(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } diff --git a/plugins/bntl_utils/src/command/diff.rs b/plugins/bntl_utils/src/command/diff.rs index 48501433..6cc0fe0a 100644 --- a/plugins/bntl_utils/src/command/diff.rs +++ b/plugins/bntl_utils/src/command/diff.rs @@ -2,8 +2,7 @@ use crate::command::OutputDirectoryField; use crate::diff::TILDiff; use crate::helper::path_to_type_libraries; use binaryninja::background_task::BackgroundTask; -use binaryninja::binary_view::BinaryView; -use binaryninja::command::Command; +use binaryninja::command::GlobalCommand; use binaryninja::interaction::{Form, FormInputField}; use std::path::PathBuf; use std::thread; @@ -95,14 +94,14 @@ impl Diff { } } -impl Command for Diff { - fn action(&self, _view: &BinaryView) { +impl GlobalCommand for Diff { + fn action(&self) { thread::spawn(move || { Diff::execute(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } diff --git a/plugins/bntl_utils/src/command/dump.rs b/plugins/bntl_utils/src/command/dump.rs index 96c3b264..7b48900d 100644 --- a/plugins/bntl_utils/src/command/dump.rs +++ b/plugins/bntl_utils/src/command/dump.rs @@ -2,8 +2,7 @@ use crate::command::{InputDirectoryField, OutputDirectoryField}; use crate::dump::TILDump; use crate::helper::path_to_type_libraries; use binaryninja::background_task::BackgroundTask; -use binaryninja::binary_view::BinaryView; -use binaryninja::command::Command; +use binaryninja::command::GlobalCommand; use binaryninja::interaction::Form; pub struct Dump; @@ -48,15 +47,14 @@ impl Dump { } } -impl Command for Dump { - // TODO: We need a command type that does not require a binary view. - fn action(&self, _view: &BinaryView) { +impl GlobalCommand for Dump { + fn action(&self) { std::thread::spawn(move || { Dump::execute(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } diff --git a/plugins/bntl_utils/src/command/validate.rs b/plugins/bntl_utils/src/command/validate.rs index b95699e0..921309fd 100644 --- a/plugins/bntl_utils/src/command/validate.rs +++ b/plugins/bntl_utils/src/command/validate.rs @@ -1,8 +1,7 @@ use crate::command::{InputDirectoryField, OutputDirectoryField}; use crate::helper::path_to_type_libraries; use crate::validate::TypeLibValidater; -use binaryninja::binary_view::BinaryView; -use binaryninja::command::Command; +use binaryninja::command::GlobalCommand; use binaryninja::interaction::Form; use binaryninja::platform::Platform; @@ -68,14 +67,14 @@ impl Validate { } } -impl Command for Validate { - fn action(&self, _view: &BinaryView) { +impl GlobalCommand for Validate { + fn action(&self) { std::thread::spawn(move || { Validate::execute(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } diff --git a/plugins/bntl_utils/src/lib.rs b/plugins/bntl_utils/src/lib.rs index aad6cdcf..fb96746a 100644 --- a/plugins/bntl_utils/src/lib.rs +++ b/plugins/bntl_utils/src/lib.rs @@ -35,25 +35,25 @@ fn plugin_init() -> Result<(), ()> { command::create::CreateFromProject {}, ); - binaryninja::command::register_command( + binaryninja::command::register_global_command( "BNTL\\Create\\From Directory", "Create .bntl files from the given directory", command::create::CreateFromDirectory {}, ); - binaryninja::command::register_command( + binaryninja::command::register_global_command( "BNTL\\Diff", "Diff two .bntl files and output the difference to a file", command::diff::Diff {}, ); - binaryninja::command::register_command( + binaryninja::command::register_global_command( "BNTL\\Dump To Header", "Dump a .bntl file to a header file", command::dump::Dump {}, ); - binaryninja::command::register_command( + binaryninja::command::register_global_command( "BNTL\\Validate", "Validate a .bntl file and report the issues", command::validate::Validate {}, diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs index cb527fff..d163205b 100644 --- a/plugins/warp/src/plugin.rs +++ b/plugins/warp/src/plugin.rs @@ -11,6 +11,7 @@ use crate::{core_signature_dir, user_signature_dir}; use binaryninja::background_task::BackgroundTask; use binaryninja::command::{ register_command, register_command_for_function, register_command_for_project, + register_global_command, }; use binaryninja::is_ui_enabled; use binaryninja::settings::{QueryOptions, Settings}; @@ -192,7 +193,7 @@ fn plugin_init() -> bool { load::LoadSignatureFile {}, ); - register_command( + register_global_command( "WARP\\Commit File", "Commit file to a source", commit::CommitFile {}, @@ -234,7 +235,7 @@ fn plugin_init() -> bool { create::CreateFromCurrentView {}, ); - register_command( + register_global_command( "WARP\\Create\\From File(s)", "Creates a signature file containing all selected functions", create::CreateFromFiles {}, diff --git a/plugins/warp/src/plugin/commit.rs b/plugins/warp/src/plugin/commit.rs index d98a356a..4e8a9fee 100644 --- a/plugins/warp/src/plugin/commit.rs +++ b/plugins/warp/src/plugin/commit.rs @@ -3,8 +3,7 @@ use crate::cache::container::cached_containers; use crate::container::{SourceId, SourcePath}; use crate::plugin::create::OpenFileField; -use binaryninja::binary_view::BinaryView; -use binaryninja::command::Command; +use binaryninja::command::GlobalCommand; use binaryninja::interaction::{Form, FormInputField}; use warp::chunk::ChunkKind; use warp::WarpFile; @@ -137,14 +136,14 @@ impl CommitFile { } } -impl Command for CommitFile { - fn action(&self, _view: &BinaryView) { +impl GlobalCommand for CommitFile { + fn action(&self) { std::thread::spawn(move || { Self::execute(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs index 2a748819..5f5527a7 100644 --- a/plugins/warp/src/plugin/create.rs +++ b/plugins/warp/src/plugin/create.rs @@ -6,7 +6,8 @@ use crate::report::{ReportGenerator, ReportKindField}; use crate::{user_signature_dir, INCLUDE_TAG_NAME}; use binaryninja::background_task::BackgroundTask; use binaryninja::binary_view::{BinaryView, BinaryViewExt}; -use binaryninja::command::Command; +use binaryninja::command::{Command, GlobalCommand}; +use binaryninja::file_metadata::FileMetadata; use binaryninja::interaction::form::{Form, FormInputField}; use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet, MessageBoxIcon}; use binaryninja::rc::Ref; @@ -248,15 +249,17 @@ impl Command for CreateFromCurrentView { pub struct CreateFromFiles; -impl Command for CreateFromFiles { - fn action(&self, view: &BinaryView) { - let view = view.to_owned(); +impl GlobalCommand for CreateFromFiles { + fn action(&self) { + let empty_file_metadata = FileMetadata::new(); + let empty_bv = BinaryView::from_data(&empty_file_metadata, &[]); thread::spawn(move || { - CreateFromCurrentView::execute(view, true); + CreateFromCurrentView::execute(empty_bv.to_owned(), true); + empty_bv.file().close(); }); } - fn valid(&self, _view: &BinaryView) -> bool { + fn valid(&self) -> bool { true } } |
