diff options
| author | KyleMiles <krm504@nyu.edu> | 2023-12-05 13:05:44 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2023-12-05 13:05:44 -0500 |
| commit | ae144062dbdb047b924c2071a37a8154864cb07b (patch) | |
| tree | bd4237b33e29dde60ae49ea60cef3e7d4a4abe54 /rust/src/lib.rs | |
| parent | b02b6584f7da7d22c82f7d9839f55ea38e51de95 (diff) | |
Resolves #3714: Adds core initialization/shutdown wrapper object (to the Rust API) that you can initialize at the top of your script and it'll auto-cleanup at the end of your script. Also some misc doc fixes.
Diffstat (limited to 'rust/src/lib.rs')
| -rw-r--r-- | rust/src/lib.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 3eff5ea1..d6161d53 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -72,20 +72,17 @@ //! The most up-to-date version of the suggested [`build.rs` is here]. //! //! ### `main.rs` -//! All standalone binaries need to call [`headless::init()`] at start and [`headless::shutdown()`] at shutdown. +//! Standalone binaries need to initialize Binary Ninja before they can work. You can do this through [`headless::Session`], [`headless::script_helper`], or [`headless::init()`] at start and [`headless::shutdown()`] at shutdown. //! ```rust //! fn main() { //! // This loads all the core architecture, platform, etc plugins //! // Standalone executables need to call this, but plugins do not -//! binaryninja::headless::init(); +//! let headless_session = binaryninja::headless::Session::new(); //! //! println!("Loading binary..."); -//! let bv = binaryninja::load("/bin/cat").expect("Couldn't open `/bin/cat`"); +//! let bv = headless_session.load("/bin/cat").expect("Couldn't open `/bin/cat`"); //! //! // Your code here... -//! -//! // Important! Standalone executables need to call shutdown or they will hang forever -//! binaryninja::headless::shutdown(); //! } //! ``` //! @@ -123,7 +120,6 @@ extern crate rayon; // cc possible values // bv reorg // core fileaccessor (for bv saving) -// headless wrapper for shutdown // platform cc #[macro_use] @@ -196,6 +192,7 @@ use string::BnStrCompatible; const BN_FULL_CONFIDENCE: u8 = 255; const BN_INVALID_EXPR: usize = usize::MAX; +/// The main way to open and load files into Binary Ninja. Make sure you've properly initialized the core before calling this function. See [`crate::headless::init()`] pub fn load<S: BnStrCompatible>(filename: S) -> Option<rc::Ref<binaryview::BinaryView>> { let filename = filename.into_bytes_with_nul(); let metadata = Metadata::new_of_type(MetadataType::KeyValueDataType); @@ -216,6 +213,8 @@ pub fn load<S: BnStrCompatible>(filename: S) -> Option<rc::Ref<binaryview::Binar } } +/// The main way to open and load files (with options) into Binary Ninja. Make sure you've properly initialized the core before calling this function. See [`crate::headless::init()`] +/// /// ```rust /// let settings = [("analysis.linearSweep.autorun", false)].into(); /// |
