summaryrefslogtreecommitdiff
path: root/rust/src/base_detection.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-02-13 16:03:31 -0500
committerMason Reed <mason@vector35.com>2025-02-13 16:03:35 -0500
commit6d267ec0604ef5036f173761d67d0fb4adc8a8fa (patch)
treea5d4a8dfdf468065fdab74613d013532b4830d72 /rust/src/base_detection.rs
parentb366ebd28bcb44492719b487f9dd34b6da56d23f (diff)
Fix base detection in rust API failing on auto arch detection
Also added actual test for base address detection
Diffstat (limited to 'rust/src/base_detection.rs')
-rw-r--r--rust/src/base_detection.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/rust/src/base_detection.rs b/rust/src/base_detection.rs
index 46a56842..1fd45ef6 100644
--- a/rust/src/base_detection.rs
+++ b/rust/src/base_detection.rs
@@ -1,9 +1,8 @@
use binaryninjacore_sys::*;
-use std::ffi::CStr;
+use std::ffi::{c_char, CStr};
use crate::architecture::CoreArchitecture;
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner};
-use crate::string::BnString;
use std::num::NonZeroU32;
use std::ptr::NonNull;
@@ -11,6 +10,9 @@ pub type BaseAddressDetectionPOISetting = BNBaseAddressDetectionPOISetting;
pub type BaseAddressDetectionConfidence = BNBaseAddressDetectionConfidence;
pub type BaseAddressDetectionPOIType = BNBaseAddressDetectionPOIType;
+/// This is the architecture name used to use the architecture auto-detection feature.
+const BASE_ADDRESS_AUTO_DETECTION_ARCH: &CStr = c"auto detect";
+
pub enum BaseAddressDetectionAnalysis {
Basic,
ControlFlow,
@@ -169,9 +171,12 @@ pub struct BaseAddressDetectionSettings {
impl BaseAddressDetectionSettings {
pub(crate) fn into_raw(value: &Self) -> BNBaseAddressDetectionSettings {
- let arch_name = value.arch.map(|a| a.name()).unwrap_or(BnString::new(""));
+ let arch_name = value
+ .arch
+ .map(|a| a.name().as_ptr())
+ .unwrap_or(BASE_ADDRESS_AUTO_DETECTION_ARCH.as_ptr() as *const c_char);
BNBaseAddressDetectionSettings {
- Architecture: arch_name.as_ptr(),
+ Architecture: arch_name,
Analysis: value.analysis.as_raw().as_ptr(),
MinStrlen: value.min_string_len,
Alignment: value.alignment.get(),