From ae144062dbdb047b924c2071a37a8154864cb07b Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Tue, 5 Dec 2023 13:05:44 -0500 Subject: 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. --- rust/examples/basic_script/src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'rust/examples/basic_script/src') diff --git a/rust/examples/basic_script/src/main.rs b/rust/examples/basic_script/src/main.rs index 85187747..b979c156 100644 --- a/rust/examples/basic_script/src/main.rs +++ b/rust/examples/basic_script/src/main.rs @@ -3,10 +3,12 @@ use binaryninja::binaryview::{BinaryViewBase, BinaryViewExt}; fn main() { println!("Loading plugins..."); // This loads all the core architecture, platform, etc plugins - 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`"); println!("Filename: `{}`", bv.file().filename()); println!("File size: `{:#x}`", bv.len()); @@ -32,7 +34,4 @@ fn main() { } } } - - // Important! You need to call shutdown or your script will hang forever - binaryninja::headless::shutdown(); } -- cgit v1.3.1