summaryrefslogtreecommitdiff
path: root/rust/src/function.rs
diff options
context:
space:
mode:
authorBrandon Miller <brandon@vector35.com>2026-06-02 09:00:15 -0400
committerBrandon Miller <brandon@vector35.com>2026-06-02 09:00:15 -0400
commit5953d087a9a104e7abb63c5739091214edf2faca (patch)
treeabd95a2698f32b8e1f6ae7feaa9647cff8d218ae /rust/src/function.rs
parent68215ea14cfbaa4966f830d85d98f7f49b416455 (diff)
Add support for multiple global pointer registers
Diffstat (limited to 'rust/src/function.rs')
-rw-r--r--rust/src/function.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/rust/src/function.rs b/rust/src/function.rs
index 9806a5ca..f9b63524 100644
--- a/rust/src/function.rs
+++ b/rust/src/function.rs
@@ -2230,10 +2230,44 @@ impl Function {
unsafe { Array::new(refs, count, ()) }
}
+ /// Deprecated. Use [`Function::global_pointer_values`] instead.
+ ///
/// Discovered value of the global pointer register, if the function uses one
pub fn global_pointer_value(&self) -> Conf<RegisterValue> {
- let result = unsafe { BNGetFunctionGlobalPointerValue(self.handle) };
- Conf::new(result.value.into(), result.confidence)
+ self.global_pointer_values()
+ .into_iter()
+ .next()
+ .map(|(_, value)| value)
+ .unwrap_or_else(|| {
+ Conf::new(
+ RegisterValue::new(RegisterValueType::UndeterminedValue, 0, 0, 0),
+ 255,
+ )
+ })
+ }
+
+ /// Discovered values of the global pointer registers, if the function uses any
+ pub fn global_pointer_values(&self) -> Vec<(RegisterId, Conf<RegisterValue>)> {
+ unsafe {
+ let mut count = 0;
+ let values_ptr = BNGetFunctionGlobalPointerValues(self.handle, &mut count);
+ if values_ptr.is_null() {
+ return Vec::new();
+ }
+
+ let values = std::slice::from_raw_parts(values_ptr, count);
+ let result = values
+ .iter()
+ .map(|value| {
+ (
+ RegisterId::from(value.reg),
+ Conf::new(value.value.value.into(), value.value.confidence),
+ )
+ })
+ .collect();
+ BNFreeRegisterValueWithConfidenceAndRegisterList(values_ptr);
+ result
+ }
}
pub fn type_tokens(