diff options
| author | KyleMiles <krm504@nyu.edu> | 2023-02-14 00:09:13 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2023-02-14 00:15:57 -0500 |
| commit | 9e91eaf63aed340a2c0a61ad8f70e9a7883e3aba (patch) | |
| tree | a77dc4618b1f2848b09694a4fb81b4fa193a1566 /rust/src/function.rs | |
| parent | 60f49f32d989355696b1eb78aee98140f417952c (diff) | |
Rust API: Misc changes and improvements
Diffstat (limited to 'rust/src/function.rs')
| -rw-r--r-- | rust/src/function.rs | 39 |
1 files changed, 26 insertions, 13 deletions
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<CoreArchitecture>, @@ -144,7 +144,7 @@ impl Function { pub fn symbol(&self) -> Ref<Symbol> { 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<Ref<Type>> { + let result = unsafe { BNGetFunctionReturnType(self.handle) }; + + Conf::new( + unsafe { Type::ref_from_raw(result.type_) }, + result.confidence, + ) + } + + pub fn function_type(&self) -> Ref<Type> { + 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 +} |
