From 00680412d3f770d1435aecac7ae01ee7225ed05d Mon Sep 17 00:00:00 2001 From: Mark Giraud Date: Mon, 26 Feb 2024 11:20:27 +0100 Subject: [PATCH 1/2] feat: Add start and end address to rust block hook binding --- bindings/rust/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index 45962acf..51e86e5a 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -620,6 +620,8 @@ impl<'a, D> Unicorn<'a, D> { /// Add a block hook. pub fn add_block_hook( &mut self, + begin: u64, + end: u64, callback: F, ) -> Result where @@ -638,8 +640,8 @@ impl<'a, D> Unicorn<'a, D> { HookType::BLOCK, ffi::block_hook_proxy:: as _, user_data.as_mut() as *mut _ as _, - 1, - 0, + begin, + end, ) } .and_then(|| { From d4f5bf1be292db18f729aa3f4d1e4b8b2bfd0df1 Mon Sep 17 00:00:00 2001 From: Mark Giraud Date: Mon, 11 Mar 2024 12:31:54 +0100 Subject: [PATCH 2/2] fix: Fix rust test that was missing a parameter --- tests/rust-tests/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rust-tests/main.rs b/tests/rust-tests/main.rs index 1267b86f..b35e395f 100644 --- a/tests/rust-tests/main.rs +++ b/tests/rust-tests/main.rs @@ -763,7 +763,7 @@ fn x86_block_callback() { assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(())); let hook = emu - .add_block_hook(callback) + .add_block_hook(1, 0, callback) .expect("failed to add block hook"); assert_eq!( emu.emu_start(0x1000, 0x1002, 10 * SECOND_SCALE, 1000),