From 3098871098535217641117052875831268461095 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 21 Mar 2023 17:29:10 -0400 Subject: DebugInfo: Make datavar types have confidence --- binaryninjacore.h | 4 +++- rust/src/debuginfo.rs | 16 ++++++++++++++++ rust/src/types.rs | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/binaryninjacore.h b/binaryninjacore.h index 1aebc6d1..9a763b39 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -36,7 +36,7 @@ // Current ABI version for linking to the core. This is incremented any time // there are changes to the API that affect linking, including new functions, // new types, or modifications to existing functions or types. -#define BN_CURRENT_CORE_ABI_VERSION 33 +#define BN_CURRENT_CORE_ABI_VERSION 34 // Minimum ABI version that is supported for loading of plugins. Plugins that // are linked to an ABI version less than this will not be able to load and @@ -6426,6 +6426,8 @@ extern "C" BINARYNINJACOREAPI void BNFreeDebugFunctions(BNDebugFunctionInfo* functions, size_t count); BINARYNINJACOREAPI bool BNAddDebugDataVariable( BNDebugInfo* const debugInfo, uint64_t address, const BNType* const type, const char* name); + BINARYNINJACOREAPI bool BNAddDebugDataVariableInfo( + BNDebugInfo* const debugInfo, const BNDataVariableAndName* var); BINARYNINJACOREAPI BNDataVariableAndName* BNGetDebugDataVariables( BNDebugInfo* const debugInfo, const char* const name, size_t* count); BINARYNINJACOREAPI BNDataVariableAndName* BNGetDebugDataVariableByName( diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs index 36cbc5b7..fb108a21 100644 --- a/rust/src/debuginfo.rs +++ b/rust/src/debuginfo.rs @@ -791,6 +791,22 @@ impl DebugInfo { }, } } + + pub fn add_data_variable_info(&self, var: DataVariableAndName) -> bool { + let name = var.name.into_bytes_with_nul(); + unsafe { + BNAddDebugDataVariableInfo( + self.handle, + &mut BNDataVariableAndName { + address: var.address, + type_: var.t.contents.handle, + name: name.as_ref().as_ptr() as *mut _, + autoDiscovered: var.auto_discovered, + typeConfidence: var.t.confidence, + }, + ) + } + } } unsafe impl RefCountable for DebugInfo { diff --git a/rust/src/types.rs b/rust/src/types.rs index 6bd85d0e..11934ceb 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -2179,6 +2179,15 @@ impl DataVariableAndName { } impl DataVariableAndName { + pub fn new(address: u64, t: Conf>, auto_discovered: bool, name: S) -> Self { + Self { + address, + t, + auto_discovered, + name, + } + } + pub fn type_with_confidence(&self) -> Conf> { Conf::new(self.t.contents.clone(), self.t.confidence) } -- cgit v1.3.1