summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2022-01-27 22:43:28 -0500
committerKyleMiles <krm504@nyu.edu>2022-01-28 00:24:06 -0500
commit6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch)
treedace4156d03148bcaf02df138ab4e0d93e61bc6f /rust
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
Diffstat (limited to 'rust')
-rw-r--r--rust/examples/basic_script/build.rs79
-rw-r--r--rust/examples/template/build.rs79
-rw-r--r--rust/src/disassembly.rs6
-rw-r--r--rust/src/types.rs16
4 files changed, 95 insertions, 85 deletions
diff --git a/rust/examples/basic_script/build.rs b/rust/examples/basic_script/build.rs
index 7ad93884..5ba9bcde 100644
--- a/rust/examples/basic_script/build.rs
+++ b/rust/examples/basic_script/build.rs
@@ -14,54 +14,55 @@ static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun");
// Check last run location for path to BinaryNinja; Otherwise check the default install locations
fn link_path() -> PathBuf {
- use std::io::prelude::*;
+ use std::io::prelude::*;
- let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
- let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
+ let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
+ let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
- File::open(lastrun)
- .and_then(|f| {
- let mut binja_path = String::new();
- let mut reader = BufReader::new(f);
+ File::open(lastrun)
+ .and_then(|f| {
+ let mut binja_path = String::new();
+ let mut reader = BufReader::new(f);
- reader.read_line(&mut binja_path)?;
- Ok(PathBuf::from(binja_path.trim()))
- })
- .unwrap_or_else(|_| {
- #[cfg(target_os = "macos")]
- return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
+ reader.read_line(&mut binja_path)?;
+ Ok(PathBuf::from(binja_path.trim()))
+ })
+ .unwrap_or_else(|_| {
+ #[cfg(target_os = "macos")]
+ return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
- #[cfg(target_os = "linux")]
- return home.join("binaryninja");
+ #[cfg(target_os = "linux")]
+ return home.join("binaryninja");
- #[cfg(windows)]
- return PathBuf::from(env::var("PROGRAMFILES").unwrap()).join("Vector35\\BinaryNinja\\");
- })
+ #[cfg(windows)]
+ return PathBuf::from(env::var("PROGRAMFILES").unwrap())
+ .join("Vector35\\BinaryNinja\\");
+ })
}
fn main() {
- // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
- let install_path = env::var("BINARYNINJADIR")
- .map(PathBuf::from)
- .unwrap_or_else(|_| link_path());
+ // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
+ let install_path = env::var("BINARYNINJADIR")
+ .map(PathBuf::from)
+ .unwrap_or_else(|_| link_path());
- #[cfg(target_os = "linux")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "linux")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "macos")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "macos")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "windows")]
- {
- println!("cargo:rustc-link-lib=binaryninjacore");
- println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
- }
+ #[cfg(target_os = "windows")]
+ {
+ println!("cargo:rustc-link-lib=binaryninjacore");
+ println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
+ }
}
diff --git a/rust/examples/template/build.rs b/rust/examples/template/build.rs
index 7ad93884..5ba9bcde 100644
--- a/rust/examples/template/build.rs
+++ b/rust/examples/template/build.rs
@@ -14,54 +14,55 @@ static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun");
// Check last run location for path to BinaryNinja; Otherwise check the default install locations
fn link_path() -> PathBuf {
- use std::io::prelude::*;
+ use std::io::prelude::*;
- let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
- let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
+ let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap());
+ let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1);
- File::open(lastrun)
- .and_then(|f| {
- let mut binja_path = String::new();
- let mut reader = BufReader::new(f);
+ File::open(lastrun)
+ .and_then(|f| {
+ let mut binja_path = String::new();
+ let mut reader = BufReader::new(f);
- reader.read_line(&mut binja_path)?;
- Ok(PathBuf::from(binja_path.trim()))
- })
- .unwrap_or_else(|_| {
- #[cfg(target_os = "macos")]
- return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
+ reader.read_line(&mut binja_path)?;
+ Ok(PathBuf::from(binja_path.trim()))
+ })
+ .unwrap_or_else(|_| {
+ #[cfg(target_os = "macos")]
+ return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS");
- #[cfg(target_os = "linux")]
- return home.join("binaryninja");
+ #[cfg(target_os = "linux")]
+ return home.join("binaryninja");
- #[cfg(windows)]
- return PathBuf::from(env::var("PROGRAMFILES").unwrap()).join("Vector35\\BinaryNinja\\");
- })
+ #[cfg(windows)]
+ return PathBuf::from(env::var("PROGRAMFILES").unwrap())
+ .join("Vector35\\BinaryNinja\\");
+ })
}
fn main() {
- // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
- let install_path = env::var("BINARYNINJADIR")
- .map(PathBuf::from)
- .unwrap_or_else(|_| link_path());
+ // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults
+ let install_path = env::var("BINARYNINJADIR")
+ .map(PathBuf::from)
+ .unwrap_or_else(|_| link_path());
- #[cfg(target_os = "linux")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "linux")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "macos")]
- println!(
- "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
- install_path.to_str().unwrap(),
- install_path.to_str().unwrap(),
- );
+ #[cfg(target_os = "macos")]
+ println!(
+ "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore",
+ install_path.to_str().unwrap(),
+ install_path.to_str().unwrap(),
+ );
- #[cfg(target_os = "windows")]
- {
- println!("cargo:rustc-link-lib=binaryninjacore");
- println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
- }
+ #[cfg(target_os = "windows")]
+ {
+ println!("cargo:rustc-link-lib=binaryninjacore");
+ println!("cargo:rustc-link-search={}", install_path.to_str().unwrap());
+ }
}
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs
index c4ca2b33..8edf3c4f 100644
--- a/rust/src/disassembly.rs
+++ b/rust/src/disassembly.rs
@@ -128,7 +128,7 @@ impl From<Vec<InstructionTextToken>> for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
@@ -168,7 +168,7 @@ impl From<&Vec<&str>> for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
@@ -197,7 +197,7 @@ impl Default for DisassemblyTextLine {
hasTypeInfo: false,
parentType: ptr::null_mut(),
fieldIndex: usize::MAX,
- offset: 0
+ offset: 0,
},
})
}
diff --git a/rust/src/types.rs b/rust/src/types.rs
index 17721361..221fcb17 100644
--- a/rust/src/types.rs
+++ b/rust/src/types.rs
@@ -405,7 +405,7 @@ impl TypeBuilder {
0,
1,
&mut is_const,
- &mut is_volatile
+ &mut is_volatile,
))
}
}
@@ -727,7 +727,11 @@ impl Type {
unsafe { Self::ref_from_raw(BNCreateArrayType(&t.into().into(), count)) }
}
- pub fn enumeration(enumeration: &Enumeration, width: usize, is_signed: Conf<bool>) -> Ref<Self> {
+ pub fn enumeration(
+ enumeration: &Enumeration,
+ width: usize,
+ is_signed: Conf<bool>,
+ ) -> Ref<Self> {
//! The C/C++ APIs require an associated architecture, but in the core we only query the default_int_size if the given width is 0
//! For simplicity's sake, that convention isn't followed and you can query the default_int_size from an arch, if you have it, if you need to
unsafe {
@@ -749,11 +753,15 @@ impl Type {
pub fn named_type(type_reference: &NamedTypeReference) -> Ref<Self> {
let mut is_const = Conf::new(false, min_confidence()).into();
let mut is_volatile = Conf::new(false, min_confidence()).into();
- unsafe { Self::ref_from_raw(BNCreateNamedTypeReference(type_reference.handle,
+ unsafe {
+ Self::ref_from_raw(BNCreateNamedTypeReference(
+ type_reference.handle,
0,
1,
&mut is_const,
- &mut is_volatile)) }
+ &mut is_volatile,
+ ))
+ }
}
pub fn named_type_from_type<S: BnStrCompatible>(name: S, t: &Type) -> Ref<Self> {