Skip to content

Commit 6e6df28

Browse files
committed
[Rust] Misc documentation improvements
1 parent b3de826 commit 6e6df28

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

rust/README.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ More examples can be found in [here](https://github.com/Vector35/binaryninja-api
4545

4646
### Requirements
4747

48-
- Having BinaryNinja installed (and your license registered)
48+
- Having [Binary Ninja] installed (and your license registered)
4949
- For headless operation you must have a headless supporting license.
5050
- Clang
5151
- Rust
@@ -65,7 +65,7 @@ binaryninjacore-sys = { git = "https://github.com/Vector35/binaryninja-api.git",
6565
```
6666

6767
`build.rs`:
68-
```doctestinjectablerust
68+
```rust
6969
fn main() {
7070
let link_path =
7171
std::env::var_os("DEP_BINARYNINJACORE_PATH").expect("DEP_BINARYNINJACORE_PATH not specified");
@@ -112,14 +112,27 @@ pub extern "C" fn CorePluginInit() -> bool {
112112
}
113113
```
114114

115-
Examples for writing a plugin can be found [here](https://github.com/Vector35/binaryninja-api/tree/dev/plugins).
115+
Examples for writing a plugin can be found [here](https://github.com/Vector35/binaryninja-api/tree/dev/rust/plugin_examples) and [here](https://github.com/Vector35/binaryninja-api/tree/dev/plugins).
116+
117+
#### Sending Logs
118+
119+
To send logs from your plugin to Binary Ninja, you can use the [tracing](https://docs.rs/tracing/latest/tracing/) crate.
120+
At the beginning of your plugin's initialization routine, register the tracing subscriber with [`crate::tracing_init!`],
121+
for more details see the documentation of that macro.
122+
123+
#### Plugin Compatibility
124+
125+
A built plugin can only be loaded into a compatible Binary Ninja version, this is determined by the ABI version of the
126+
plugin. The ABI version is located at the top of the `binaryninjacore.h` header file, and as such plugins should pin
127+
their binary ninja dependency to a specific tag or commit hash. See the cargo documentation [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#choice-of-commit)
128+
for more details.
116129

117130
### Write a Standalone Executable
118131

119132
If you have a headless supporting license, you are able to use Binary Ninja as a regular dynamically loaded library.
120133

121-
Standalone executables must initialize the core themselves. `binaryninja::headless::init()` to initialize the core, and
122-
`binaryninja::headless::shutdown()` to shutdown the core. Prefer using `binaryninja::headless::Session` as it will
134+
Standalone executables must initialize the core themselves. [`crate::headless::init()`] to initialize the core, and
135+
[`crate::headless::shutdown()`] to shutdown the core. Prefer using [`crate::headless::Session`] as it will
123136
shut down for you once it is dropped.
124137

125138
`main.rs`:
@@ -131,6 +144,12 @@ fn main() {
131144
}
132145
```
133146

147+
#### Capturing Logs
148+
149+
To capture logs from Binary Ninja, you can use the [tracing](https://docs.rs/tracing/latest/tracing/) crate. Before initializing
150+
the core but after registering your tracing subscriber, register a [`crate::tracing::TracingLogListener`], for more details see
151+
the documentation for that type.
152+
134153
## Offline Documentation
135154

136155
Offline documentation can be generated like any other rust crate, using `cargo doc`.
@@ -161,18 +180,6 @@ it will likely confuse someone else, and you should make an issue or ask for gui
161180

162181
#### Attribution
163182

164-
This project makes use of:
165-
- [log] ([log license] - MIT)
166-
- [rayon] ([rayon license] - MIT)
167-
- [thiserror] ([thiserror license] - MIT)
168-
- [serde_json] ([serde_json license] - MIT)
169-
170-
[log]: https://github.com/rust-lang/log
171-
[log license]: https://github.com/rust-lang/log/blob/master/LICENSE-MIT
172-
[rayon]: https://github.com/rayon-rs/rayon
173-
[rayon license]: https://github.com/rayon-rs/rayon/blob/master/LICENSE-MIT
174-
[thiserror]: https://github.com/dtolnay/thiserror
175-
[thiserror license]: https://github.com/dtolnay/thiserror/blob/master/LICENSE-MIT
176-
[serde_json]: https://github.com/serde-rs/json
177-
[serde_json license]: https://github.com/serde-rs/json/blob/master/LICENSE-MIT
178-
[Binary Ninja]: https://binary.ninja
183+
For attribution, please refer to the [Rust Licenses section](https://docs.binary.ninja/about/open-source.html#rust-licenses) of the user documentation.
184+
185+
[Binary Ninja]: https://binary.ninja/

rust/plugin_examples/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Plugin Examples
2+
3+
These are examples of plugins that can be used to extend Binary Ninja's functionality. Each directory contains a crate
4+
that when built produces a shared library that can then be placed into the `plugins` directory of your Binary Ninja
5+
installation.
6+
7+
For more information on installing plugins, refer to the user documentation [here](https://docs.binary.ninja/guide/plugins.html#using-plugins).
8+
9+
For more examples of plugins, see the [plugins directory](https://github.com/Vector35/binaryninja-api/tree/dev/plugins)
10+
which contains a number of plugins bundled with Binary Ninja.

0 commit comments

Comments
 (0)