add missing interrupt hook for Go bindings

This commit is contained in:
Ryan Hileman 2015-08-30 15:53:06 -07:00
parent f83ddf5ad4
commit ac1fc4d631
3 changed files with 13 additions and 0 deletions

View File

@ -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);
}

View File

@ -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 {

View File

@ -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);