diff options
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 |
