fixed testcases
This commit is contained in:
parent
0dfc0cba1f
commit
d7ead41a51
|
@ -118,15 +118,10 @@ where
|
|||
}
|
||||
|
||||
/// Drop UC
|
||||
/// TODO: !!! Right now, this leaks the unicorn instance on purpose.
|
||||
/// UC 1 for some platforms, for example aarch64, seems to crash on cleanup.
|
||||
/// After updating to Unicorn 2, we should call `uc_close` again!
|
||||
impl<'a, D> Drop for Unicorn<'a, D> {
|
||||
fn drop(&mut self) {
|
||||
if !self.uc.is_null() {
|
||||
// TODO: !!!
|
||||
// This is a deliberate leak, get rid of it after updating to UC2!
|
||||
// unsafe { ffi::uc_close(self.uc) };
|
||||
unsafe { ffi::uc_close(self.uc) };
|
||||
}
|
||||
self.uc = ptr::null_mut();
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ pub static X86_REGISTERS: [RegisterX86; 125] = [
|
|||
fn emulate_x86() {
|
||||
let x86_code32: Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, 0)
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.reg_write(RegisterX86::EAX as i32, 123), Ok(()));
|
||||
assert_eq!(emu.reg_read(RegisterX86::EAX as i32), Ok(123));
|
||||
|
@ -207,7 +207,7 @@ fn x86_code_callback() {
|
|||
|
||||
let x86_code32: Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
@ -237,7 +237,7 @@ fn x86_intr_callback() {
|
|||
|
||||
let x86_code32: Vec<u8> = vec![0xcd, 0x80]; // INT 0x80;
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
@ -285,7 +285,7 @@ fn x86_mem_callback() {
|
|||
0xB8, 0xEF, 0xBE, 0xAD, 0xDE, 0xA3, 0x00, 0x20, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x01, 0x00,
|
||||
];
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
@ -322,7 +322,7 @@ fn x86_insn_in_callback() {
|
|||
|
||||
let x86_code32: Vec<u8> = vec![0xe5, 0x10]; // IN eax, 0x10;
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
@ -358,7 +358,7 @@ fn x86_insn_out_callback() {
|
|||
|
||||
let x86_code32: Vec<u8> = vec![0xb0, 0x32, 0xe6, 0x46]; // MOV al, 0x32; OUT 0x46, al;
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
@ -399,7 +399,7 @@ fn x86_insn_sys_callback() {
|
|||
0x48, 0xB8, 0xEF, 0xBE, 0xAD, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x05,
|
||||
];
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_64, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_64)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code), Ok(()));
|
||||
|
@ -425,7 +425,7 @@ fn x86_insn_sys_callback() {
|
|||
fn emulate_arm() {
|
||||
let arm_code32: Vec<u8> = vec![0x83, 0xb0]; // sub sp, #0xc
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::ARM, Mode::THUMB, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::ARM, Mode::THUMB)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.reg_write(RegisterARM::R1 as i32, 123), Ok(()));
|
||||
assert_eq!(emu.reg_read(RegisterARM::R1 as i32), Ok(123));
|
||||
|
@ -465,7 +465,7 @@ fn emulate_arm() {
|
|||
fn emulate_mips() {
|
||||
let mips_code32 = vec![0x56, 0x34, 0x21, 0x34]; // ori $at, $at, 0x3456;
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::MIPS, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::MIPS, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &mips_code32), Ok(()));
|
||||
|
@ -490,7 +490,7 @@ fn emulate_mips() {
|
|||
fn emulate_ppc() {
|
||||
let ppc_code32 = vec![0x7F, 0x46, 0x1A, 0x14]; // add 26, 6, 3
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::PPC, Mode::PPC32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::PPC, Mode::PPC32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &ppc_code32), Ok(()));
|
||||
|
@ -514,7 +514,7 @@ fn emulate_ppc() {
|
|||
|
||||
#[test]
|
||||
fn mem_unmapping() {
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_unmap(0x1000, 0x4000), Ok(()));
|
||||
|
@ -526,7 +526,7 @@ fn mem_map_ptr() {
|
|||
let mut mem: [u8; 4000] = [0; 4000];
|
||||
let x86_code32: Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
|
||||
// Attempt to write to memory before mapping it.
|
||||
|
@ -604,7 +604,7 @@ 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 emu = unicorn_emulator::Unicorn::new(Arch::X86, *mode, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, *mode)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code), Ok(()));
|
||||
|
@ -620,7 +620,7 @@ fn x86_context_save_and_restore() {
|
|||
let context = context.unwrap();
|
||||
|
||||
/* and create a new emulator, into which we will "restore" that context */
|
||||
let emu2 = unicorn_emulator::Unicorn::new(Arch::X86, *mode, ())
|
||||
let emu2 = unicorn_engine::Unicorn::new(Arch::X86, *mode)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu2.context_restore(&context), Ok(()));
|
||||
for register in X86_REGISTERS.iter() {
|
||||
|
@ -649,7 +649,7 @@ fn x86_block_callback() {
|
|||
|
||||
let x86_code32: Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx
|
||||
|
||||
let mut emu = unicorn_emulator::Unicorn::new(Arch::X86, Mode::MODE_32, ())
|
||||
let mut emu = unicorn_engine::Unicorn::new(Arch::X86, Mode::MODE_32)
|
||||
.expect("failed to initialize unicorn instance");
|
||||
assert_eq!(emu.mem_map(0x1000, 0x4000, Permission::ALL), Ok(()));
|
||||
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
|
||||
|
|
Loading…
Reference in New Issue