summaryrefslogtreecommitdiff
path: root/rust/src/lib.rs
diff options
context:
space:
mode:
authorRubens Brandao <git@rubens.io>2024-05-16 16:44:24 -0300
committerMason Reed <mason@vector35.com>2024-07-26 18:38:40 -0400
commit031456e41d4b1bc5a185934fb7a0a506618d3a8d (patch)
tree94c51bd5593a3a3a73fc283e44a9be13b3a86c95 /rust/src/lib.rs
parent8a5cd4b42efd254672d9e3e60e13702de7149ad4 (diff)
Add more core API's to rust
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r--rust/src/lib.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index c086478d..baac888b 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -138,6 +138,7 @@ pub mod databuffer;
pub mod debuginfo;
pub mod demangle;
pub mod disassembly;
+pub mod enterprise;
pub mod component;
pub mod downloadprovider;
pub mod externallibrary;
@@ -434,6 +435,75 @@ pub fn version() -> string::BnString {
unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetVersionString()) }
}
+pub fn build_id() -> u32 {
+ unsafe { binaryninjacore_sys::BNGetBuildId() }
+}
+
+#[derive(Clone, PartialEq, Eq, Hash)]
+pub struct VersionInfo {
+ pub major: u32,
+ pub minor: u32,
+ pub build: u32,
+ pub channel: string::BnString,
+}
+
+pub fn version_info() -> VersionInfo {
+ let info_raw = unsafe { binaryninjacore_sys::BNGetVersionInfo() };
+ VersionInfo {
+ major: info_raw.major,
+ minor: info_raw.minor,
+ build: info_raw.build,
+ channel: unsafe { string::BnString::from_raw(info_raw.channel) },
+ }
+}
+
+pub fn serial_number() -> string::BnString {
+ unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetSerialNumber()) }
+}
+
+pub fn is_license_validated() -> bool {
+ unsafe { binaryninjacore_sys::BNIsLicenseValidated() }
+}
+
+pub fn licensed_user_email() -> string::BnString {
+ unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetLicensedUserEmail()) }
+}
+
+pub fn license_count() -> i32 {
+ unsafe { binaryninjacore_sys::BNGetLicenseCount() }
+}
+
+pub fn set_license<S: string::BnStrCompatible>(license: S) {
+ let license = license.into_bytes_with_nul();
+ let license_slice = license.as_ref();
+ unsafe { binaryninjacore_sys::BNSetLicense(license_slice.as_ptr() as *const i8) }
+}
+
+pub fn product() -> string::BnString {
+ unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetProduct()) }
+}
+
+pub fn product_type() -> string::BnString {
+ unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetProductType()) }
+}
+
+pub fn license_expiration_time() -> std::time::SystemTime {
+ let m = std::time::Duration::from_secs(unsafe {
+ binaryninjacore_sys::BNGetLicenseExpirationTime()
+ });
+ std::time::UNIX_EPOCH + m
+}
+
+pub fn is_ui_enabled() -> bool {
+ unsafe { binaryninjacore_sys::BNIsUIEnabled() }
+}
+
+pub fn is_database<S: string::BnStrCompatible>(filename: S) -> bool {
+ let filename = filename.into_bytes_with_nul();
+ let filename_slice = filename.as_ref();
+ unsafe { binaryninjacore_sys::BNIsDatabase(filename_slice.as_ptr() as *const i8) }
+}
+
pub fn plugin_abi_version() -> u32 {
binaryninjacore_sys::BN_CURRENT_CORE_ABI_VERSION
}