summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/lib.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 068aa8c3..0c1022c0 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -173,6 +173,8 @@ pub mod types;
pub mod update;
pub mod workflow;
+use std::collections::HashMap;
+use std::ffi::CStr;
use std::path::PathBuf;
use std::ptr;
@@ -596,6 +598,21 @@ pub fn path_relative_to_user_directory<S: string::BnStrCompatible>(path: S) -> R
))
}
+pub fn memory_info() -> HashMap<String, u64> {
+ let mut count = 0;
+ let mut usage = HashMap::new();
+ unsafe {
+ let info_ptr = binaryninjacore_sys::BNGetMemoryUsageInfo(&mut count);
+ let info_list = std::slice::from_raw_parts(info_ptr, count);
+ for info in info_list {
+ let info_name = CStr::from_ptr(info.name).to_str().unwrap().to_string();
+ usage.insert(info_name, info.value);
+ }
+ binaryninjacore_sys::BNFreeMemoryUsageInfo(info_ptr, count);
+ }
+ usage
+}
+
pub fn version() -> string::BnString {
unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetVersionString()) }
}