Format the code
This commit is contained in:
@ -1,13 +1,12 @@
|
||||
use std::fmt::format;
|
||||
use std::result::Result;
|
||||
use std::{env, process::Command};
|
||||
use std::path::{Path, PathBuf};
|
||||
use bytes::Buf;
|
||||
use flate2::read::GzDecoder;
|
||||
use reqwest::header::USER_AGENT;
|
||||
use std::fmt::format;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::result::Result;
|
||||
use std::{env, process::Command};
|
||||
use tar::Archive;
|
||||
|
||||
|
||||
fn find_unicorn(unicorn_dir: &PathBuf) -> Option<PathBuf> {
|
||||
for entry in std::fs::read_dir(unicorn_dir).ok()? {
|
||||
let entry = entry.unwrap();
|
||||
@ -37,8 +36,10 @@ fn download_unicorn() -> Option<String> {
|
||||
pkg_version
|
||||
))
|
||||
.header(USER_AGENT, "unicorn-engine-rust-bindings")
|
||||
.send().unwrap()
|
||||
.bytes().unwrap();
|
||||
.send()
|
||||
.unwrap()
|
||||
.bytes()
|
||||
.unwrap();
|
||||
let tar = GzDecoder::new(resp.reader());
|
||||
|
||||
let mut archive = Archive::new(tar);
|
||||
@ -46,12 +47,11 @@ fn download_unicorn() -> Option<String> {
|
||||
|
||||
match find_unicorn(&out_dir) {
|
||||
Some(dir) => Some(String::from(out_dir.join(dir).to_str()?)),
|
||||
None => None
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let profile = env::var("PROFILE").unwrap();
|
||||
|
||||
let unicorn_dir = download_unicorn().unwrap();
|
||||
|
@ -1,6 +1,8 @@
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use unicorn_engine::unicorn_const::{uc_error, Arch, HookType, MemType, Mode, Permission, SECOND_SCALE};
|
||||
use unicorn_engine::unicorn_const::{
|
||||
uc_error, Arch, HookType, MemType, Mode, Permission, SECOND_SCALE,
|
||||
};
|
||||
use unicorn_engine::{InsnSysX86, RegisterARM, RegisterMIPS, RegisterPPC, RegisterX86};
|
||||
|
||||
pub static X86_REGISTERS: [RegisterX86; 125] = [
|
||||
@ -602,8 +604,8 @@ fn x86_context_save_and_restore() {
|
||||
let x86_code: Vec<u8> = vec![
|
||||
0x48, 0xB8, 0xEF, 0xBE, 0xAD, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x05,
|
||||
];
|
||||
let mut unicorn =
|
||||
unicorn_engine::Unicorn::new(Arch::X86, mode).expect("failed to initialize unicorn instance");
|
||||
let mut unicorn = unicorn_engine::Unicorn::new(Arch::X86, mode)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
let mut emu = unicorn.borrow();
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code), Ok(()));
|
||||
@ -619,8 +621,8 @@ fn x86_context_save_and_restore() {
|
||||
let context = context.unwrap();
|
||||
|
||||
/* and create a new emulator, into which we will "restore" that context */
|
||||
let mut unicorn2 =
|
||||
unicorn_engine::Unicorn::new(Arch::X86, mode).expect("failed to initialize unicorn instance");
|
||||
let mut unicorn2 = unicorn_engine::Unicorn::new(Arch::X86, mode)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
let emu2 = unicorn2.borrow();
|
||||
assert_eq!(emu2.context_restore(&context), Ok(()));
|
||||
for register in X86_REGISTERS.iter() {
|
||||
|
Reference in New Issue
Block a user