diff options
| author | Mason Reed <mason@vector35.com> | 2025-01-31 13:02:22 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-01-31 16:17:30 -0500 |
| commit | f5b7f5b2779b1b29e14856efd2a2e56a7c3b0113 (patch) | |
| tree | b1722f62166390c0d4b245a6695e359652ec6cf5 /rust/src/low_level_il/operation.rs | |
| parent | c00727ed11624018b286f57215a677b1140de2ff (diff) | |
Add LLIL_REG_STACK_POP and LLIL_REG_STACK_PUSH to Rust API
These were unhandled and x87 register stack LLIL would emit a bunch of warnings
Diffstat (limited to 'rust/src/low_level_il/operation.rs')
| -rw-r--r-- | rust/src/low_level_il/operation.rs | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs index dcc761dd..46d99a97 100644 --- a/rust/src/low_level_il/operation.rs +++ b/rust/src/low_level_il/operation.rs @@ -15,7 +15,7 @@ use binaryninjacore_sys::{BNGetLowLevelILByIndex, BNLowLevelILInstruction}; use super::*; -use crate::architecture::{FlagGroupId, FlagId, FlagWriteId, IntrinsicId}; +use crate::architecture::{FlagGroupId, FlagId, FlagWriteId, IntrinsicId, RegisterStackId}; use std::collections::BTreeMap; use std::fmt::{Debug, Formatter}; use std::marker::PhantomData; @@ -537,6 +537,88 @@ where } } +// LLIL_REG_STACK_PUSH +pub struct RegStackPush; + +impl<'func, A, M, F> Operation<'func, A, M, F, RegStackPush> +where + A: Architecture, + M: FunctionMutability, + F: FunctionForm, +{ + pub fn size(&self) -> usize { + self.op.size + } + + pub fn dest_reg_stack(&self) -> A::RegisterStack { + let raw_id = self.op.operands[0] as u32; + self.function + .arch() + .register_stack_from_id(RegisterStackId(raw_id)) + .expect("Bad register stack ID") + } + + pub fn source_expr(&self) -> LowLevelILExpression<'func, A, M, F, ValueExpr> { + LowLevelILExpression::new( + self.function, + LowLevelExpressionIndex(self.op.operands[1] as usize), + ) + } +} + +impl<A, M, F> Debug for Operation<'_, A, M, F, RegStackPush> +where + A: Architecture, + M: FunctionMutability, + F: FunctionForm, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RegStackPush") + .field("address", &self.address()) + .field("size", &self.size()) + .field("dest_reg_stack", &self.dest_reg_stack()) + .field("source_expr", &self.source_expr()) + .finish() + } +} + +// LLIL_REG_STACK_POP +pub struct RegStackPop; + +impl<'func, A, M, F> Operation<'func, A, M, F, RegStackPop> +where + A: Architecture, + M: FunctionMutability, + F: FunctionForm, +{ + pub fn size(&self) -> usize { + self.op.size + } + + pub fn source_reg_stack(&self) -> A::RegisterStack { + let raw_id = self.op.operands[0] as u32; + self.function + .arch() + .register_stack_from_id(RegisterStackId(raw_id)) + .expect("Bad register stack ID") + } +} + +impl<A, M, F> Debug for Operation<'_, A, M, F, RegStackPop> +where + A: Architecture, + M: FunctionMutability, + F: FunctionForm, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RegStackPop") + .field("address", &self.address()) + .field("size", &self.size()) + .field("source_reg_stack", &self.source_reg_stack()) + .finish() + } +} + // LLIL_FLAG, LLIL_FLAG_SSA pub struct Flag; @@ -1343,6 +1425,8 @@ impl OperationArguments for Load {} impl OperationArguments for Store {} impl OperationArguments for Reg {} impl OperationArguments for RegSplit {} +impl OperationArguments for RegStackPush {} +impl OperationArguments for RegStackPop {} impl OperationArguments for Flag {} impl OperationArguments for FlagBit {} impl OperationArguments for Jump {} |
