From 6664c9d7853c0266456cbca64ede3da44b382569 Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Tue, 14 May 2024 15:49:36 -0300 Subject: [PATCH] add Function::unresolved_indirect_branches method --- rust/src/function.rs | 9 ++++++++- rust/src/types.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/rust/src/function.rs b/rust/src/function.rs index 1333c4950..5d48474d6 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -32,7 +32,7 @@ use crate::{ Conf, ConstantReference, HighlightColor, IndirectBranchInfo, IntegerDisplayType, MergedVariable, NamedTypedVariable, QualifiedName, RegisterList, RegisterSet, RegisterStackAdjustment, RegisterValue, RegisterValueType, StackVariableReference, Type, - Variable, + UnresolvedIndirectBranches, Variable, }, }; use crate::{databuffer::DataBuffer, disassembly::InstructionTextToken, rc::*}; @@ -2050,6 +2050,13 @@ impl Function { unsafe { BNHasUnresolvedIndirectBranches(self.handle) } } + /// List of address of unresolved indirect branches + pub fn unresolved_indirect_branches(&self) -> Array { + let mut count = 0; + let result = unsafe { BNGetUnresolvedIndirectBranches(self.handle, &mut count) }; + unsafe { Array::new(result, count, ()) } + } + /// Returns a string representing the provenance. This portion of the API /// is under develoment. Currently the provenance information is /// undocumented, not persistent, and not saved to a database. diff --git a/rust/src/types.rs b/rust/src/types.rs index c9bc8a599..abcd6f6b6 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -3753,3 +3753,30 @@ unsafe impl CoreArrayProviderInner for MergedVariable { } } } + +///////////////////////// +// UnresolvedIndirectBranches + +// NOTE only exists as part of an Array, never owned +pub struct UnresolvedIndirectBranches(u64); + +impl UnresolvedIndirectBranches { + pub fn address(&self) -> u64 { + self.0 + } +} + +impl CoreArrayProvider for UnresolvedIndirectBranches { + type Raw = u64; + type Context = (); + type Wrapped<'a> = Self; +} + +unsafe impl CoreArrayProviderInner for UnresolvedIndirectBranches { + unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { + BNFreeAddressList(raw) + } + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + Self(*raw) + } +}