mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 12:48:16 +00:00
Go: update test hooks
This commit is contained in:
parent
693719e732
commit
475c8de3de
2 changed files with 5 additions and 5 deletions
|
@ -100,9 +100,9 @@ func (u *uc) HookAdd(htype int, cb interface{}, begin, end uint64, extra ...int)
|
|||
data := &HookData{u, cb}
|
||||
uptr := uintptr(unsafe.Pointer(data))
|
||||
if insnMode {
|
||||
C.uc_hook_add_wrap(u.handle, &h2, C.uc_hook_type(htype), callback, C.uintptr_t(uptr), C.uint64_t(begin), C.uint64_t(end))
|
||||
} else {
|
||||
C.uc_hook_add_insn(u.handle, &h2, C.uc_hook_type(htype), callback, C.uintptr_t(uptr), C.uint64_t(begin), C.uint64_t(end), insn)
|
||||
} else {
|
||||
C.uc_hook_add_wrap(u.handle, &h2, C.uc_hook_type(htype), callback, C.uintptr_t(uptr), C.uint64_t(begin), C.uint64_t(end))
|
||||
}
|
||||
hookDataMap[uptr] = data
|
||||
hookToUintptr[Hook(h2)] = uptr
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestX86InOut(t *testing.T) {
|
|||
default:
|
||||
return 0
|
||||
}
|
||||
}, X86_INS_IN)
|
||||
}, 1, 0, X86_INS_IN)
|
||||
mu.HookAdd(HOOK_INSN, func(_ Unicorn, port, size, value uint32) {
|
||||
outCalled = true
|
||||
var err error
|
||||
|
@ -111,7 +111,7 @@ func TestX86InOut(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}, X86_INS_OUT)
|
||||
}, 1, 0, X86_INS_OUT)
|
||||
if err := mu.Start(ADDRESS, ADDRESS+uint64(len(code))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func TestX86Syscall(t *testing.T) {
|
|||
mu.HookAdd(HOOK_INSN, func(_ Unicorn) {
|
||||
rax, _ := mu.RegRead(X86_REG_RAX)
|
||||
mu.RegWrite(X86_REG_RAX, rax+1)
|
||||
}, X86_INS_SYSCALL)
|
||||
}, 1, 0, X86_INS_SYSCALL)
|
||||
mu.RegWrite(X86_REG_RAX, 0x100)
|
||||
err = mu.Start(ADDRESS, ADDRESS+uint64(len(code)))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue