diff --git a/bindings/go/unicorn/hook.c b/bindings/go/unicorn/hook.c index e715e1a2..a06f9901 100644 --- a/bindings/go/unicorn/hook.c +++ b/bindings/go/unicorn/hook.c @@ -17,6 +17,10 @@ void hookMemAccess_cgo(uch handle, uc_mem_type type, uint64_t addr, int size, in hookMemAccess(handle, type, addr, size, value, user); } +void hookInterrupt_cgo(uch handle, uint32_t intno, void *user) { + hookInterrupt(handle, intno, user); +} + uint32_t hookX86In_cgo(uch handle, uint32_t port, uint32_t size, void *user) { return hookX86In(handle, port, size, user); } diff --git a/bindings/go/unicorn/hook.go b/bindings/go/unicorn/hook.go index ea6ce40e..dcab893a 100644 --- a/bindings/go/unicorn/hook.go +++ b/bindings/go/unicorn/hook.go @@ -34,6 +34,12 @@ func hookMemAccess(handle C.uch, typ C.uc_mem_type, addr uint64, size int, value hook.Callback.(func(*Uc, int, uint64, int, int64))(hook.Uc, int(typ), addr, size, value) } +//export hookInterrupt +func hookInterrupt(handle C.uch, intno uint32, user unsafe.Pointer) { + hook := (*HookData)(user) + hook.Callback.(func(*Uc, uint32))(hook.Uc, intno) +} + //export hookX86In func hookX86In(handle C.uch, port, size uint32, user unsafe.Pointer) uint32 { hook := (*HookData)(user) @@ -64,6 +70,8 @@ func (u *Uc) HookAdd(htype int, cb interface{}, insn ...int) (C.uch, error) { callback = C.hookMemInvalid_cgo case UC_HOOK_MEM_READ, UC_HOOK_MEM_WRITE, UC_HOOK_MEM_READ_WRITE: callback = C.hookMemAccess_cgo + case UC_HOOK_INTR: + callback = C.hookInterrupt_cgo case UC_HOOK_INSN: extra = C.int(insn[0]) switch extra { diff --git a/bindings/go/unicorn/hook.h b/bindings/go/unicorn/hook.h index a89d8ec0..c8c22267 100644 --- a/bindings/go/unicorn/hook.h +++ b/bindings/go/unicorn/hook.h @@ -2,6 +2,7 @@ uc_err uc_hook_add2(uch handle, uch *h2, uc_hook_t type, void *callback, void *u void hookCode_cgo(uch handle, uint64_t addr, uint32_t size, void *user); bool hookMemInvalid_cgo(uch handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user); void hookMemAccess_cgo(uch handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user); +void hookInterrupt_cgo(uch handle, uint32_t intno, void *user); uint32_t hookX86In_cgo(uch handle, uint32_t port, uint32_t size, void *user); void hookX86Out_cgo(uch handle, uint32_t port, uint32_t size, uint32_t value, void *user); void hookX86Syscall_cgo(uch handle, void *user);