summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-05-31 16:16:46 -0400
committerJosh F <negasora@users.noreply.github.com>2024-05-31 18:31:12 -0400
commit725d4450e850eb64d4c3fcda7ae567750f4c741f (patch)
tree5e3889e7f5c25d7683fcf94d721f7364109bcf5f /rust/src
parent87d236e815b3c8c92eaef76b2b4e69c84229d40a (diff)
Add binaryninja::load_view
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/lib.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 1c2dacd0..e24a3f78 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -269,6 +269,41 @@ pub fn load_with_options<S: BnStrCompatible, O: IntoJson>(
}
}
+pub fn load_view<O: IntoJson>(
+ bv: &BinaryView,
+ update_analysis_and_wait: bool,
+ options: Option<O>,
+) -> Option<rc::Ref<binaryview::BinaryView>> {
+ let options_or_default = if let Some(opt) = options {
+ opt.get_json_string()
+ .ok()?
+ .into_bytes_with_nul()
+ .as_ref()
+ .to_vec()
+ } else {
+ Metadata::new_of_type(MetadataType::KeyValueDataType)
+ .get_json_string()
+ .ok()?
+ .as_ref()
+ .to_vec()
+ };
+
+ let handle = unsafe {
+ binaryninjacore_sys::BNLoadBinaryView(
+ bv.handle as *mut _,
+ update_analysis_and_wait,
+ options_or_default.as_ptr() as *mut core::ffi::c_char,
+ None,
+ )
+ };
+
+ if handle.is_null() {
+ None
+ } else {
+ Some(unsafe { BinaryView::from_raw(handle) })
+ }
+}
+
pub fn install_directory() -> Result<PathBuf, ()> {
let s: *mut std::os::raw::c_char = unsafe { binaryninjacore_sys::BNGetInstallDirectory() };
if s.is_null() {