diff options
| author | KyleMiles <krm504@nyu.edu> | 2021-05-03 18:45:59 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2021-05-11 16:53:24 -0400 |
| commit | 4bd1f6b1477b910b580a0bcfcde118bcefc1ddc0 (patch) | |
| tree | b8e18454053a22c3f97645c6c52a0e6b0bc6a4e3 /rust/README.md | |
| parent | eb7a52bf4bd3b19c22f2eadda444ab045c674fe3 (diff) | |
Easier Building with Rust (now requires nightly)
Diffstat (limited to 'rust/README.md')
| -rw-r--r-- | rust/README.md | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/rust/README.md b/rust/README.md index 8fca9c07..533494d6 100644 --- a/rust/README.md +++ b/rust/README.md @@ -2,10 +2,15 @@ > :warning: **These bindings are in a very early beta, only have partial support for the core APIs and are still actively under development. Compatibility _will_ break and conventions _will_ change! They are being used for core Binary Ninja features however, so we expect much of what is already there to be reliable enough to build on, just don't be surprised if your plugins/scripts need to hit a moving target.** +> :warning: This project requires Rust Nightly to build with those fancy linker arguments + + ## Dependencies Having BinaryNinja installed (and your license registered) Clang +Rust **Nightly** + ## How to use @@ -18,40 +23,49 @@ crate-type = ["cdylib"] [dependencies] binaryninja = {git = "https://github.com/Vector35/binaryninja-api.git", branch = "dev"} - ``` `src/main.rs`: -See the `./examples/` +See the `./examples/`. Plugin registration commands are in `binaryninja::command::*` + -### To write a headless script +### To write a headless script: `Cargo.toml`: ``` [dependencies] -binaryninja = { git = "https://github.com/Vector35/binaryninja-api.git", branch = "dev", features = ["headless"] } - +binaryninja = { git = "https://github.com/Vector35/binaryninja-api.git", branch = "dev"} ``` `src/main.rs`: ``` use binaryninja::version; +use binaryninja::architecture::Architecture; +use binaryninja::binaryview::{BinaryViewBase, BinaryViewExt}; fn main() { println!("BinaryNinja Version: `{}`", version()); -} -``` -## Contributing + println!("Loading plugins..."); // This loads all the core architecture, platform, etc plugins + binaryninja::headless::init(); + + println!("Loading binary..."); + let bv = binaryninja::open_view("/bin/cat").expect("Couldn't open `/bin/cat`"); -If you want to advance the binaryninjacore.h reference, simply change the commit ID in `build.rs` + println!("Filename: `{}`", bv.metadata().filename()); + println!("File size: `{:#x}`", bv.len()); + println!("Function count: {}", bv.functions().len()); -## WIP : TODO + for func in &bv.functions() { + println!(" `{}`:", func.symbol().full_name()); + } + + // Important! You need to call shutdown or your script will hang forever + binaryninja::headless::shutdown(); +} +``` - - Logging needs to be redone - - Update libc requirement on binaryninja:: - - Rename `section_by_name` to `get_section_by_name` and similar -many other todos are still scattered in the codebase +All headless scripts should call both `binaryninja::headless::init()` and `binaryninja::headless::shutdown()`. --- |
