From eb19d9bff595830643b81d3a093675e6984dfa6b Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Thu, 24 Sep 2015 01:01:39 -0700 Subject: [PATCH] update Go bindings for #149 --- bindings/go/unicorn/hook.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bindings/go/unicorn/hook.go b/bindings/go/unicorn/hook.go index bfa72c80..c286f08f 100644 --- a/bindings/go/unicorn/hook.go +++ b/bindings/go/unicorn/hook.go @@ -71,10 +71,7 @@ func (u *uc) HookAdd(htype int, cb interface{}, extra ...uint64) (Hook, error) { case HOOK_BLOCK, HOOK_CODE: rangeMode = true callback = C.hookCode_cgo - case HOOK_MEM_INVALID: - rangeMode = true - callback = C.hookMemInvalid_cgo - case HOOK_MEM_READ, HOOK_MEM_WRITE, HOOK_MEM_READ_WRITE: + case HOOK_MEM_READ, HOOK_MEM_WRITE, HOOK_MEM_READ | HOOK_MEM_WRITE: rangeMode = true callback = C.hookMemAccess_cgo case HOOK_INTR: @@ -92,7 +89,14 @@ func (u *uc) HookAdd(htype int, cb interface{}, extra ...uint64) (Hook, error) { return 0, errors.New("Unknown instruction type.") } default: - return 0, errors.New("Unknown hook type.") + // special case for mask + if htype&(HOOK_MEM_READ_INVALID|HOOK_MEM_WRITE_INVALID|HOOK_MEM_FETCH_INVALID| + HOOK_MEM_READ_PROT|HOOK_MEM_WRITE_PROT|HOOK_MEM_FETCH_PROT) != 0 { + rangeMode = true + callback = C.hookMemInvalid_cgo + } else { + return 0, errors.New("Unknown hook type.") + } } var h2 C.uc_hook data := &HookData{u, cb}