diff options
| author | Rubens Brandao <git@rubens.io> | 2023-11-22 18:57:28 -0300 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2024-02-02 13:32:45 -0500 |
| commit | f682ca69b356755fe6c06bcdd8f4fab73f7d2c78 (patch) | |
| tree | 3cfc324cfe8043ccc8db1161f1f90c448d097c8a /rust/src/llil/function.rs | |
| parent | e1a6bdcd576f7caeaa6f97ff1e337a259057b333 (diff) | |
Rust API : Add HLIL Bindings
Diffstat (limited to 'rust/src/llil/function.rs')
| -rw-r--r-- | rust/src/llil/function.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/rust/src/llil/function.rs b/rust/src/llil/function.rs index 46d3e6d1..f0aba63a 100644 --- a/rust/src/llil/function.rs +++ b/rust/src/llil/function.rs @@ -13,6 +13,7 @@ // limitations under the License. use binaryninjacore_sys::BNFreeLowLevelILFunction; +use binaryninjacore_sys::BNGetLowLevelILOwnerFunction; use binaryninjacore_sys::BNLowLevelILFunction; use binaryninjacore_sys::BNNewLowLevelILFunctionReference; @@ -65,14 +66,14 @@ unsafe impl<A: Architecture, M: FunctionMutability, F: FunctionForm> Sync for Fu impl<A: Architecture, M: FunctionMutability, F: FunctionForm> Eq for Function<A, M, F> {} impl<A: Architecture, M: FunctionMutability, F: FunctionForm> PartialEq for Function<A, M, F> { fn eq(&self, rhs: &Self) -> bool { - self.handle == rhs.handle + self.get_function().eq(&rhs.get_function()) } } use std::hash::{Hash, Hasher}; impl<A: Architecture, M: FunctionMutability, F: FunctionForm> Hash for Function<A, M, F> { fn hash<H: Hasher>(&self, state: &mut H) { - self.handle.hash(state); + self.get_function().hash(state) } } @@ -82,7 +83,10 @@ where M: FunctionMutability, F: FunctionForm, { - pub(crate) unsafe fn from_raw(borrower: A::Handle, handle: *mut BNLowLevelILFunction) -> Self { + pub(crate) unsafe fn from_raw( + borrower: A::Handle, + handle: *mut BNLowLevelILFunction, + ) -> Ref<Self> { debug_assert!(!handle.is_null()); Self { @@ -92,6 +96,7 @@ where _mutability: PhantomData, _form: PhantomData, } + .to_owned() } pub(crate) fn arch(&self) -> &A { @@ -139,6 +144,13 @@ where BNGetLowLevelILInstructionCount(self.handle) } } + + pub fn get_function(&self) -> Ref<crate::function::Function> { + unsafe { + let func = BNGetLowLevelILOwnerFunction(self.handle); + crate::function::Function::from_raw(func) + } + } } // LLIL basic blocks are not available until the function object |
