From 12f916450b444427685688bf34de65e11bf849e2 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Mon, 25 Jan 2021 16:45:06 -0500 Subject: Add ABI version verification for plugins --- rust/src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'rust/src') diff --git a/rust/src/lib.rs b/rust/src/lib.rs index bdef8368..3d287321 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -215,3 +215,25 @@ pub mod logger { pub fn version() -> string::BnString { unsafe { string::BnString::from_raw(binaryninjacore_sys::BNGetVersionString()) } } + +pub fn plugin_abi_version() -> u32 { + binaryninjacore_sys::BN_CURRENT_CORE_ABI_VERSION +} + +pub fn plugin_abi_minimum_version() -> u32 { + binaryninjacore_sys::BN_MINIMUM_CORE_ABI_VERSION +} + +pub fn core_abi_version() -> u32 { + unsafe { binaryninjacore_sys::BNGetCurrentCoreABIVersion() } +} + +pub fn core_abi_minimum_version() -> u32 { + unsafe { binaryninjacore_sys::BNGetMinimumCoreABIVersion() } +} + +// Provide ABI version automatically so that the core can verify binary compatibility +#[cfg(not(feature = "headless"))] +#[no_mangle] +#[allow(non_snake_case)] +pub extern "C" fn CorePluginABIVersion() -> u32 { plugin_abi_version() } -- cgit v1.3.1