From 37008b7fa16837d04c1658868646cad681cbe035 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 11 Feb 2026 18:04:07 -0800 Subject: Add BNTL utility plugin Allow users to easily create, diff, dump and validate type libraries Supports the following formats: - C header files (via core type parsers) - Binary files (collects exported and imported functions) - WinMD files (via `windows-metadata` crate) - Existing type library files (for easy fixups) - Apiset files (to resolve through forwarded windows dlls) Can be invoked as a regular plugin via UI commands or via CLI. Processing of type libraries inherently requires external linking, processing will automatically merge and deduplicate colliding type libraries so prefer to use inside a project or a directory and process all information (for a given platform) at once, rather than smaller invocations. --- plugins/bntl_utils/src/command.rs | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plugins/bntl_utils/src/command.rs (limited to 'plugins/bntl_utils/src/command.rs') diff --git a/plugins/bntl_utils/src/command.rs b/plugins/bntl_utils/src/command.rs new file mode 100644 index 00000000..39f25b99 --- /dev/null +++ b/plugins/bntl_utils/src/command.rs @@ -0,0 +1,66 @@ +use binaryninja::interaction::{Form, FormInputField}; +use binaryninja::user_directory; +use std::path::PathBuf; + +pub mod create; +pub mod diff; +pub mod dump; +pub mod validate; +// TODO: Load? + +pub struct InputFileField; + +impl InputFileField { + pub fn field() -> FormInputField { + FormInputField::OpenFileName { + prompt: "File Path".to_string(), + // TODO: This is called extension but is really a filter. + extension: None, + default: None, + value: None, + } + } + + pub fn from_form(form: &Form) -> Option { + let field = form.get_field_with_name("File Path")?; + let field_value = field.try_value_string()?; + Some(PathBuf::from(field_value)) + } +} + +pub struct OutputDirectoryField; + +impl OutputDirectoryField { + pub fn field() -> FormInputField { + let type_lib_dir = user_directory().join("typelib"); + FormInputField::DirectoryName { + prompt: "Output Directory".to_string(), + default: Some(type_lib_dir.to_string_lossy().to_string()), + value: None, + } + } + + pub fn from_form(form: &Form) -> Option { + let field = form.get_field_with_name("Output Directory")?; + let field_value = field.try_value_string()?; + Some(PathBuf::from(field_value)) + } +} + +pub struct InputDirectoryField; + +impl InputDirectoryField { + pub fn field() -> FormInputField { + FormInputField::DirectoryName { + prompt: "Input Directory".to_string(), + default: None, + value: None, + } + } + + pub fn from_form(form: &Form) -> Option { + let field = form.get_field_with_name("Input Directory")?; + let field_value = field.try_value_string()?; + Some(PathBuf::from(field_value)) + } +} -- cgit v1.3.1