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/lib.rs | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 plugins/bntl_utils/src/lib.rs (limited to 'plugins/bntl_utils/src/lib.rs') diff --git a/plugins/bntl_utils/src/lib.rs b/plugins/bntl_utils/src/lib.rs new file mode 100644 index 00000000..aad6cdcf --- /dev/null +++ b/plugins/bntl_utils/src/lib.rs @@ -0,0 +1,63 @@ +mod command; +pub mod diff; +pub mod dump; +pub mod helper; +mod merge; +pub mod process; +pub mod schema; +pub mod tbd; +pub mod url; +pub mod validate; +mod winmd; + +#[no_mangle] +#[allow(non_snake_case)] +pub extern "C" fn CorePluginInit() -> bool { + if plugin_init().is_err() { + tracing::error!("Failed to initialize BNTL Utils plug-in"); + return false; + } + true +} + +fn plugin_init() -> Result<(), ()> { + binaryninja::tracing_init!("BNTL Utils"); + + binaryninja::command::register_command( + "BNTL\\Create\\From Current View", + "Create .bntl files from the current view", + command::create::CreateFromCurrentView {}, + ); + + binaryninja::command::register_command_for_project( + "BNTL\\Create\\From Project", + "Create .bntl files from the given project", + command::create::CreateFromProject {}, + ); + + binaryninja::command::register_command( + "BNTL\\Create\\From Directory", + "Create .bntl files from the given directory", + command::create::CreateFromDirectory {}, + ); + + binaryninja::command::register_command( + "BNTL\\Diff", + "Diff two .bntl files and output the difference to a file", + command::diff::Diff {}, + ); + + binaryninja::command::register_command( + "BNTL\\Dump To Header", + "Dump a .bntl file to a header file", + command::dump::Dump {}, + ); + + binaryninja::command::register_command( + "BNTL\\Validate", + "Validate a .bntl file and report the issues", + command::validate::Validate {}, + ); + + Ok(()) +} -- cgit v1.3.1