diff options
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/headless.rs | 9 | ||||
| -rw-r--r-- | rust/src/lib.rs | 11 | ||||
| -rw-r--r-- | rust/src/metadata.rs | 7 |
3 files changed, 9 insertions, 18 deletions
diff --git a/rust/src/headless.rs b/rust/src/headless.rs index 15754aba..d4d8892a 100644 --- a/rust/src/headless.rs +++ b/rust/src/headless.rs @@ -14,9 +14,8 @@ use crate::{ binaryview, - metadata::Metadata, - rc::{self, Ref}, - string::BnStrCompatible, + rc, + string::{BnStrCompatible, IntoJson}, }; use std::env; @@ -146,11 +145,11 @@ impl Session { /// let bv = headless_session.load_with_options("/bin/cat", true, Some(settings)) /// .expect("Couldn't open `/bin/cat`"); /// ``` - pub fn load_with_options( + pub fn load_with_options<O: IntoJson>( &self, filename: &str, update_analysis_and_wait: bool, - options: Option<Ref<Metadata>>, + options: Option<O>, ) -> Option<rc::Ref<binaryview::BinaryView>> { crate::load_with_options(filename, update_analysis_and_wait, options) } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index f20a33a9..cb511a7a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -197,12 +197,13 @@ 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 options = ""; let handle = unsafe { binaryninjacore_sys::BNLoadFilename( filename.as_ref().as_ptr() as *mut _, true, - std::ptr::null(), + options.as_ptr() as *mut core::ffi::c_char, None, ) }; @@ -216,15 +217,13 @@ 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()`] /// +/// <div class="warning">Your JSON needs to be compliant with RapidJSON's format, which basically means you just need to escape double quotes (\") and single quotes won't work.</div> +/// /// ```no_run /// use binaryninja::{metadata::Metadata, rc::Ref}; /// use std::collections::HashMap; /// -/// let settings: Ref<Metadata> = HashMap::from([ -/// ("analysis.linearSweep.autorun", false.into()), -/// ]).into(); -/// -/// let bv = binaryninja::load_with_options("/bin/cat", true, Some(settings)) +/// let bv = binaryninja::load_with_options("/bin/cat", true, Some("{\"analysis.linearSweep.autorun\": false}")) /// .expect("Couldn't open `/bin/cat`"); /// ``` pub fn load_with_options<S: BnStrCompatible, O: IntoJson>( diff --git a/rust/src/metadata.rs b/rust/src/metadata.rs index 96571207..9eeff8fa 100644 --- a/rust/src/metadata.rs +++ b/rust/src/metadata.rs @@ -710,13 +710,6 @@ impl IntoJson for &Metadata { } } -impl IntoJson for Metadata { - type Output = BnString; - fn get_json_string(self) -> Result<BnString, ()> { - Metadata::get_json_string(&self) - } -} - impl IntoJson for Ref<Metadata> { type Output = BnString; fn get_json_string(self) -> Result<BnString, ()> { |
