Skip to content

Commit

Permalink
add Function::unresolved_indirect_branches method
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran committed May 14, 2024
1 parent 7b935df commit 6664c9d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rust/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*};
Expand Down Expand Up @@ -2050,6 +2050,13 @@ impl Function {
unsafe { BNHasUnresolvedIndirectBranches(self.handle) }
}

/// List of address of unresolved indirect branches
pub fn unresolved_indirect_branches(&self) -> Array<UnresolvedIndirectBranches> {
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.
Expand Down
27 changes: 27 additions & 0 deletions rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 6664c9d

Please sign in to comment.