diff options
| author | Mark Rowe <mark@vector35.com> | 2025-08-11 10:42:07 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-08-27 15:59:48 -0700 |
| commit | 28ff277a2a7693d5a9ab1929bc459049c2e52b27 (patch) | |
| tree | d69846ee37ea1e4f4ceca580f2b53f340e7a7ab7 /rust/src | |
| parent | 86974363659160a4fa5ff1818e8e1317c74c9a0a (diff) | |
[Rust] Add LowLevelILFunction::{get_ssa_register_value, get_ssa_flag_value}
These are available on `LowLevelILFunction<M, SSA>`.
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/low_level_il/function.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index 1955c147..177b2a1a 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -18,11 +18,12 @@ use std::marker::PhantomData; use binaryninjacore_sys::*; -use crate::architecture::CoreArchitecture; +use crate::architecture::{CoreArchitecture, CoreFlag}; use crate::basic_block::BasicBlock; use crate::function::Function; use crate::low_level_il::block::LowLevelILBlock; use crate::rc::*; +use crate::variable::RegisterValue; use super::*; @@ -297,6 +298,37 @@ impl<M: FunctionMutability> Ref<LowLevelILFunction<M, SSA>> { }; self.instruction_from_index(LowLevelInstructionIndex(instr_idx)) } + + /// Returns the value of the given SSA register. + #[must_use] + pub fn get_ssa_register_value<R: ArchReg>( + &self, + reg: &LowLevelILSSARegisterKind<R>, + ) -> Option<RegisterValue> { + let register_id = match reg { + LowLevelILSSARegisterKind::Full { kind, .. } => kind.id(), + LowLevelILSSARegisterKind::Partial { partial_reg, .. } => partial_reg.id(), + }; + let value = unsafe { + BNGetLowLevelILSSARegisterValue(self.handle, register_id.into(), reg.version() as usize) + }; + if value.state == BNRegisterValueType::UndeterminedValue { + return None; + } + Some(value.into()) + } + + /// Returns the value of the given SSA flag. + #[must_use] + pub fn get_ssa_flag_value(&self, flag: &LowLevelILSSAFlag<CoreFlag>) -> Option<RegisterValue> { + let value = unsafe { + BNGetLowLevelILSSAFlagValue(self.handle, flag.flag.id().0, flag.version as usize) + }; + if value.state == BNRegisterValueType::UndeterminedValue { + return None; + } + Some(value.into()) + } } impl<M, F> ToOwned for LowLevelILFunction<M, F> |
