summaryrefslogtreecommitdiff
path: root/rust/src/llil/function.rs
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2024-03-05 02:09:39 -0500
committerGlenn Smith <glenn@vector35.com>2024-03-05 14:01:31 -0500
commit0609276712622908254065546102381466033141 (patch)
tree2b5fe0e1e16f0fcb21e09c5fb87e360f1968a76d /rust/src/llil/function.rs
parent2596349220399080054037011947884060414345 (diff)
Rust: Implement instruction_llil for CoreArchitecture
Diffstat (limited to 'rust/src/llil/function.rs')
-rw-r--r--rust/src/llil/function.rs32
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,