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/cli/README.md | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 plugins/bntl_utils/cli/README.md (limited to 'plugins/bntl_utils/cli/README.md') diff --git a/plugins/bntl_utils/cli/README.md b/plugins/bntl_utils/cli/README.md new file mode 100644 index 00000000..5c4ddcb7 --- /dev/null +++ b/plugins/bntl_utils/cli/README.md @@ -0,0 +1,61 @@ +# Headless BNTL Processor + +Provides headless support for generating, inspecting, and validating Binary Ninja type libraries (BNTL). + +### Building + +> Assuming you have the following: +> - A compatible Binary Ninja with headless usage (see [this documentation](https://docs.binary.ninja/dev/batch.html#batch-processing-and-other-automation-tips) for more information) +> - Clang +> - Rust (currently tested for 1.91.1) +> - Set `BINARYNINJADIR` env variable to your installation directory (see [here](https://docs.binary.ninja/guide/#binary-path) for more details) + > - If this is not set, the -sys crate will try and locate using the default installation path and last run location. + +1. Clone this repository (`git clone https://github.com/Vector35/binaryninja-api/tree/dev`) +2. Build in release (`cargo build --release`) + +If compilation fails because it could not link against binaryninjacore than you should double-check you set `BINARYNINJADIR` correctly. + +Once it finishes you now will have a `bntl_cli` binary in `target/release` for use. + +### Usage + +> Assuming you already have the `bntl_cli` binary and a valid headless compatible Binary Ninja license. + +#### Create + +Generate a new type library from local files or remote projects. + +Examples: + +- `./bntl_cli create sqlite3.dll "windows-x86_64" ./headers/ ./output/` + - Places a single `sqlite.dll.bntl` file in the `output` directory, as headers have no dependency names associated they will be named `sqlite.dll`. +- `./bntl_cli create myproject "windows-x86_64" binaryninja://enterprise/https://enterprise.com/23ce5eaa-f532-4a93-80f2-a7d7f0aed040/ ./output/` + - Downloads and processes all files in the project, placing potentially multiple `.bntl` files in the `output` directory. +- `./bntl_cli create sqlite3.dll "windows-x86_64" ./winmd/ ./output/` + - `winmd` files are also supported as input, they will be processed together. You also probably want to provide some apiset schema files as well. + +#### Dump + +Export a type library back into a C header file for inspection. + +Examples: + +- `./bntl_cli dump sqlite3.dll.bntl ./output/sqlite.h` + +#### Diff + +Compare two type libraries and generate a .diff file containing a similarity ratio. + +Examples: + +- `./bntl_cli diff sqlite3.dll.bntl sqlite3.dll.bntl ./output/sqlite.diff` + +#### Validate + +Check type libraries for common errors, ensuring all referenced types exist across specified platforms. + +Examples: + +- `./bntl_cli validate ./typelibs/ ./output/` + - Pass in a directory containing `.bntl` files to validate, outputting a JSON file for each type library containing any errors. -- cgit v1.3.1