From 9e91eaf63aed340a2c0a61ad8f70e9a7883e3aba Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Tue, 14 Feb 2023 00:09:13 -0500 Subject: Rust API: Misc changes and improvements --- rust/src/function.rs | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'rust/src/function.rs') diff --git a/rust/src/function.rs b/rust/src/function.rs index 2eed562e..426f936b 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::{fmt, mem}; - use binaryninjacore_sys::*; -use crate::architecture::CoreArchitecture; -use crate::basicblock::{BasicBlock, BlockContext}; -use crate::binaryview::{BinaryView, BinaryViewExt}; -use crate::platform::Platform; -use crate::symbol::Symbol; -use crate::types::Type; - -use crate::llil; - use crate::rc::*; use crate::string::*; +use crate::{ + architecture::CoreArchitecture, + basicblock::{BasicBlock, BlockContext}, + binaryview::{BinaryView, BinaryViewExt}, + llil, + platform::Platform, + symbol::Symbol, + types::{Conf, Type}, +}; + +use std::{fmt, mem}; pub struct Location { pub arch: Option, @@ -144,7 +144,7 @@ impl Function { pub fn symbol(&self) -> Ref { unsafe { let sym = BNGetFunctionSymbol(self.handle); - Ref::new(Symbol::from_raw(sym)) + Symbol::ref_from_raw(sym) } } @@ -240,6 +240,19 @@ impl Function { } } + pub fn return_type(&self) -> Conf> { + let result = unsafe { BNGetFunctionReturnType(self.handle) }; + + Conf::new( + unsafe { Type::ref_from_raw(result.type_) }, + result.confidence, + ) + } + + pub fn function_type(&self) -> Ref { + unsafe { Type::ref_from_raw(BNGetFunctionType(self.handle)) } + } + pub fn set_user_type(&self, t: Type) { unsafe { BNSetFunctionUserType(self.handle, t.handle); @@ -330,4 +343,4 @@ unsafe impl<'a> CoreArrayWrapper<'a> for AddressRange { unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { mem::transmute(raw) } -} \ No newline at end of file +} -- cgit v1.3.1