diff options
Diffstat (limited to 'rust/src/llil/function.rs')
| -rw-r--r-- | rust/src/llil/function.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/rust/src/llil/function.rs b/rust/src/llil/function.rs index f0aba63a..8f1eac62 100644 --- a/rust/src/llil/function.rs +++ b/rust/src/llil/function.rs @@ -20,6 +20,7 @@ use binaryninjacore_sys::BNNewLowLevelILFunctionReference; use std::borrow::Borrow; use std::marker::PhantomData; +use crate::architecture::CoreArchitecture; use crate::basicblock::BasicBlock; use crate::rc::*; @@ -174,6 +175,37 @@ where } } +// Allow instantiating Lifted IL functions for querying Lifted IL from Architectures +impl Function<CoreArchitecture, Mutable, NonSSA<LiftedNonSSA>> { + pub fn new( + arch: CoreArchitecture, + source_func: Option<crate::function::Function>, + ) -> Result<Ref<Self>, ()> { + use binaryninjacore_sys::BNCreateLowLevelILFunction; + use std::ptr::null_mut; + + let handle = unsafe { + match source_func { + Some(func) => BNCreateLowLevelILFunction(arch.0, func.handle), + None => BNCreateLowLevelILFunction(arch.0, null_mut()), + } + }; + if handle.is_null() { + return Err(()); + } + + Ok(unsafe { + Ref::new(Self { + borrower: arch, + handle, + _arch: PhantomData, + _mutability: PhantomData, + _form: PhantomData, + }) + }) + } +} + impl<'func, A, M, F> ToOwned for Function<A, M, F> where A: 'func + Architecture, |
