diff options
| author | Brian Potchik <brian@vector35.com> | 2024-05-27 15:29:48 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2024-05-27 15:29:48 -0400 |
| commit | a348dab8b14b8ddd36c400ae39a7a48b6a28e829 (patch) | |
| tree | c5aa3b6274b57660d263de44ac1eccc9bfa8739d /rust | |
| parent | 309d606f1c51168c0ef30ccf7850d483429fa35b (diff) | |
Update load APIs to take a JSON string for options.
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/lib.rs | 5 | ||||
| -rw-r--r-- | rust/src/metadata.rs | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs index d2894b20..de38be4d 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -197,14 +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 metadata = Metadata::new_of_type(MetadataType::KeyValueDataType); let handle = unsafe { binaryninjacore_sys::BNLoadFilename( filename.as_ref().as_ptr() as *mut _, true, + std::ptr::null(), None, - metadata.handle, ) }; @@ -245,8 +244,8 @@ pub fn load_with_options<S: BnStrCompatible>( binaryninjacore_sys::BNLoadFilename( filename.as_ref().as_ptr() as *mut _, update_analysis_and_wait, + options_or_default.get_json_string().unwrap().as_ref().as_ptr() as *mut _, None, - options_or_default.as_ref().handle, ) }; diff --git a/rust/src/metadata.rs b/rust/src/metadata.rs index c8c532f3..f635700f 100644 --- a/rust/src/metadata.rs +++ b/rust/src/metadata.rs @@ -166,6 +166,19 @@ impl Metadata { } } + pub fn get_json_string(&self) -> Result<BnString, ()> { + match self.get_type() { + MetadataType::StringDataType => { + let ptr: *mut c_char = unsafe { BNMetadataGetJsonString(self.handle) }; + if ptr.is_null() { + return Err(()); + } + Ok(unsafe { BnString::from_raw(ptr) }) + } + _ => Err(()), + } + } + pub fn get_raw(&self) -> Result<Vec<u8>, ()> { match self.get_type() { MetadataType::RawDataType => { |
