diff options
| author | KyleMiles <krm504@nyu.edu> | 2021-01-21 18:35:20 +0000 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2021-01-21 19:07:07 +0000 |
| commit | 2fcacc55d5466a7d17bdc0b3ce988772aa6d0653 (patch) | |
| tree | 9d0f2ba19117843575936f2b93e0b6a578a84dc8 /rust/src/function.rs | |
| parent | a0da07c5c2860a5bd69921d38e438bbc1d43912f (diff) | |
cargo fmt and all my changes
Diffstat (limited to 'rust/src/function.rs')
| -rw-r--r-- | rust/src/function.rs | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/rust/src/function.rs b/rust/src/function.rs index 9a65f837..ec83fa41 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -1,18 +1,32 @@ +// Copyright 2021 Vector 35 Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + use std::fmt; 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::basicblock::{BasicBlock, BlockContext}; use crate::types::Type; use crate::llil; -use crate::string::*; use crate::rc::*; +use crate::string::*; pub struct Location { pub arch: Option<CoreArchitecture>, @@ -53,13 +67,16 @@ impl Iterator for NativeBlockIter { if res >= self.end { None } else { - self.bv.get_instruction_len(&self.arch, res).map(|x| { - self.cur += x as u64; - res - }).or_else(|| { - self.cur = self.end; - None - }) + self.bv + .get_instruction_len(&self.arch, res) + .map(|x| { + self.cur += x as u64; + res + }) + .or_else(|| { + self.cur = self.end; + None + }) } } } @@ -107,7 +124,7 @@ impl Function { } pub fn arch(&self) -> CoreArchitecture { - unsafe { + unsafe { let arch = BNGetFunctionArchitecture(self.handle); CoreArchitecture::from_raw(arch) } @@ -142,7 +159,7 @@ impl Function { unsafe { BnString::from_raw(BNGetFunctionComment(self.handle)) } } - pub fn set_comment<S: BnStrCompatible>(&self, comment: S) { + pub fn set_comment<S: BnStrCompatible>(&self, comment: S) { let raw = comment.as_bytes_with_nul(); unsafe { @@ -154,7 +171,7 @@ impl Function { unsafe { BnString::from_raw(BNGetCommentForAddress(self.handle, addr)) } } - pub fn set_comment_at<S: BnStrCompatible>(&self, addr: u64, comment: S) { + pub fn set_comment_at<S: BnStrCompatible>(&self, addr: u64, comment: S) { let raw = comment.as_bytes_with_nul(); unsafe { @@ -172,7 +189,11 @@ impl Function { } } - pub fn basic_block_containing(&self, arch: &CoreArchitecture, addr: u64) -> Option<Ref<BasicBlock<NativeBlock>>> { + pub fn basic_block_containing( + &self, + arch: &CoreArchitecture, + addr: u64, + ) -> Option<Ref<BasicBlock<NativeBlock>>> { unsafe { let block = BNGetFunctionBasicBlockAtAddress(self.handle, arch.0, addr); let context = NativeBlock { _priv: () }; @@ -218,7 +239,13 @@ impl Function { impl fmt::Debug for Function { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "<func '{}' ({}) {:x}>", self.symbol().name(), self.platform().name(), self.start()) + write!( + f, + "<func '{}' ({}) {:x}>", + self.symbol().full_name(), + self.platform().name(), + self.start() + ) } } |
