Merge pull request #1928 from mlgiraud/feat/add_start_end_to_hook

Feature: Bindings: add start end to block hook
This commit is contained in:
lazymio 2024-03-11 19:50:46 +08:00 committed by GitHub
commit 227ff1d8bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -620,6 +620,8 @@ impl<'a, D> Unicorn<'a, D> {
/// Add a block hook. /// Add a block hook.
pub fn add_block_hook<F: 'a>( pub fn add_block_hook<F: 'a>(
&mut self, &mut self,
begin: u64,
end: u64,
callback: F, callback: F,
) -> Result<UcHookId, uc_error> ) -> Result<UcHookId, uc_error>
where where
@ -638,8 +640,8 @@ impl<'a, D> Unicorn<'a, D> {
HookType::BLOCK, HookType::BLOCK,
ffi::block_hook_proxy::<D, F> as _, ffi::block_hook_proxy::<D, F> as _,
user_data.as_mut() as *mut _ as _, user_data.as_mut() as *mut _ as _,
1, begin,
0, end,
) )
} }
.and_then(|| { .and_then(|| {

View File

@ -763,7 +763,7 @@ fn x86_block_callback() {
assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(())); assert_eq!(emu.mem_write(0x1000, &x86_code32), Ok(()));
let hook = emu let hook = emu
.add_block_hook(callback) .add_block_hook(1, 0, callback)
.expect("failed to add block hook"); .expect("failed to add block hook");
assert_eq!( assert_eq!(
emu.emu_start(0x1000, 0x1002, 10 * SECOND_SCALE, 1000), emu.emu_start(0x1000, 0x1002, 10 * SECOND_SCALE, 1000),