diff options
| author | Mason Reed <mason@vector35.com> | 2025-07-10 01:32:32 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-07-15 12:34:43 -0400 |
| commit | 1c01b00d87e45c7ae8eb6320b20e7dcf67915d77 (patch) | |
| tree | e861d689ad737bb1140cd24654d74bbd82c3068d /rust/src/low_level_il/instruction.rs | |
| parent | 99e442620e8e19053120dc44239372d1fb5a3053 (diff) | |
Move LLIL instruction retrieval into the LLIL function where it belongs
The python API was kept the same seeing as we are close to the release, will likely start deprecating some of those API's soon.
Diffstat (limited to 'rust/src/low_level_il/instruction.rs')
| -rw-r--r-- | rust/src/low_level_il/instruction.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/rust/src/low_level_il/instruction.rs b/rust/src/low_level_il/instruction.rs index 04a1d2d5..2d96d121 100644 --- a/rust/src/low_level_il/instruction.rs +++ b/rust/src/low_level_il/instruction.rs @@ -13,16 +13,16 @@ // limitations under the License. use crate::basic_block::BasicBlock; -use crate::rc::Ref; +use crate::rc::{CoreArrayProvider, CoreArrayProviderInner, Ref}; use super::block::LowLevelILBlock; use super::operation; use super::operation::Operation; use super::VisitorAction; use super::*; -use binaryninjacore_sys::BNGetLowLevelILByIndex; use binaryninjacore_sys::BNGetLowLevelILIndexForInstruction; use binaryninjacore_sys::BNLowLevelILInstruction; +use binaryninjacore_sys::{BNFreeILInstructionList, BNGetLowLevelILByIndex}; use std::fmt::{Debug, Display, Formatter}; #[repr(transparent)] @@ -53,6 +53,22 @@ impl Display for LowLevelInstructionIndex { } } +impl CoreArrayProvider for LowLevelInstructionIndex { + type Raw = usize; + type Context = (); + type Wrapped<'a> = Self; +} + +unsafe impl CoreArrayProviderInner for LowLevelInstructionIndex { + unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { + BNFreeILInstructionList(raw) + } + + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + Self::from(*raw) + } +} + // TODO: Probably want to rename this with a LowLevelIL prefix to avoid collisions when we add handlers for other ILs pub trait InstructionHandler<'func, M, F> where |
