From aa9c28e91b5c2ef6ab0e2aff7e44f8a16de998f7 Mon Sep 17 00:00:00 2001 From: Zichuan Li <34680029+river-li@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:19:57 -0400 Subject: Add data_variable_at_address and fixed the type propagation issue in riscv --- rust/src/binaryview.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'rust/src/binaryview.rs') diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index 8d7a2db4..bf14580c 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -564,6 +564,17 @@ pub trait BinaryViewExt: BinaryViewBase { } } + fn data_variable_at_address(&self, addr: u64) -> Option> { + let dv = BNDataVariable::default(); + unsafe { + if BNGetDataVariableAtAddress(self.as_ref().handle, addr, std::mem::transmute(&dv)) { + Some(DataVariable(dv).to_owned()) + } else { + None + } + } + } + fn define_auto_data_var<'a, T: Into>>(&self, addr: u64, ty: T) { unsafe { BNDefineDataVariable(self.as_ref().handle, addr, &mut ty.into().into()); -- cgit v1.3.1