mirror of
https://github.com/Vita3K/unicorn.git
synced 2024-12-02 18:36:28 +00:00
update go bindings for type changes
This commit is contained in:
parent
f9d8387175
commit
70c42731c2
@ -1,38 +1,38 @@
|
||||
#include <unicorn/unicorn.h>
|
||||
#include "_cgo_export.h"
|
||||
|
||||
uc_err uc_hook_add_i1(uch handle, uch *h2, uc_hook_type type, void *callback, void *user, int arg1) {
|
||||
uc_err uc_hook_add_i1(uc_engine *handle, uc_hook *h2, uc_hook_type type, void *callback, void *user, int arg1) {
|
||||
return uc_hook_add(handle, h2, type, callback, user, arg1);
|
||||
}
|
||||
|
||||
uc_err uc_hook_add_u2(uch handle, uch *h2, uc_hook_type type, void *callback, void *user, uint64_t arg1, uint64_t arg2) {
|
||||
uc_err uc_hook_add_u2(uc_engine *handle, uc_hook *h2, uc_hook_type type, void *callback, void *user, uint64_t arg1, uint64_t arg2) {
|
||||
return uc_hook_add(handle, h2, type, callback, user, arg1, arg2);
|
||||
}
|
||||
|
||||
void hookCode_cgo(uch handle, uint64_t addr, uint32_t size, void *user) {
|
||||
void hookCode_cgo(uc_engine *handle, uint64_t addr, uint32_t size, void *user) {
|
||||
hookCode(handle, addr, size, user);
|
||||
}
|
||||
|
||||
bool hookMemInvalid_cgo(uch handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user) {
|
||||
bool hookMemInvalid_cgo(uc_engine *handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user) {
|
||||
return hookMemInvalid(handle, type, addr, size, value, user);
|
||||
}
|
||||
|
||||
void hookMemAccess_cgo(uch handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user) {
|
||||
void hookMemAccess_cgo(uc_engine *handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user) {
|
||||
hookMemAccess(handle, type, addr, size, value, user);
|
||||
}
|
||||
|
||||
void hookInterrupt_cgo(uch handle, uint32_t intno, void *user) {
|
||||
void hookInterrupt_cgo(uc_engine *handle, uint32_t intno, void *user) {
|
||||
hookInterrupt(handle, intno, user);
|
||||
}
|
||||
|
||||
uint32_t hookX86In_cgo(uch handle, uint32_t port, uint32_t size, void *user) {
|
||||
uint32_t hookX86In_cgo(uc_engine *handle, uint32_t port, uint32_t size, void *user) {
|
||||
return hookX86In(handle, port, size, user);
|
||||
}
|
||||
|
||||
void hookX86Out_cgo(uch handle, uint32_t port, uint32_t size, uint32_t value, void *user) {
|
||||
void hookX86Out_cgo(uc_engine *handle, uint32_t port, uint32_t size, uint32_t value, void *user) {
|
||||
hookX86Out(handle, port, size, value, user);
|
||||
}
|
||||
|
||||
void hookX86Syscall_cgo(uch handle, void *user) {
|
||||
void hookX86Syscall_cgo(uc_engine *handle, void *user) {
|
||||
hookX86Syscall(handle, user);
|
||||
}
|
||||
|
@ -17,50 +17,50 @@ type HookData struct {
|
||||
}
|
||||
|
||||
//export hookCode
|
||||
func hookCode(handle C.uch, addr uint64, size uint32, user unsafe.Pointer) {
|
||||
func hookCode(handle *C.uc_engine, addr uint64, size uint32, user unsafe.Pointer) {
|
||||
hook := (*HookData)(user)
|
||||
hook.Callback.(func(*Uc, uint64, uint32))(hook.Uc, uint64(addr), uint32(size))
|
||||
}
|
||||
|
||||
//export hookMemInvalid
|
||||
func hookMemInvalid(handle C.uch, typ C.uc_mem_type, addr uint64, size int, value int64, user unsafe.Pointer) bool {
|
||||
func hookMemInvalid(handle *C.uc_engine, typ C.uc_mem_type, addr uint64, size int, value int64, user unsafe.Pointer) bool {
|
||||
hook := (*HookData)(user)
|
||||
return hook.Callback.(func(*Uc, int, uint64, int, int64) bool)(hook.Uc, int(typ), addr, size, value)
|
||||
}
|
||||
|
||||
//export hookMemAccess
|
||||
func hookMemAccess(handle C.uch, typ C.uc_mem_type, addr uint64, size int, value int64, user unsafe.Pointer) {
|
||||
func hookMemAccess(handle *C.uc_engine, typ C.uc_mem_type, addr uint64, size int, value int64, user unsafe.Pointer) {
|
||||
hook := (*HookData)(user)
|
||||
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) {
|
||||
func hookInterrupt(handle *C.uc_engine, 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 {
|
||||
func hookX86In(handle *C.uc_engine, port, size uint32, user unsafe.Pointer) uint32 {
|
||||
hook := (*HookData)(user)
|
||||
return hook.Callback.(func(*Uc, uint32, uint32) uint32)(hook.Uc, port, size)
|
||||
}
|
||||
|
||||
//export hookX86Out
|
||||
func hookX86Out(handle C.uch, port, size, value uint32, user unsafe.Pointer) {
|
||||
func hookX86Out(handle *C.uc_engine, port, size, value uint32, user unsafe.Pointer) {
|
||||
hook := (*HookData)(user)
|
||||
hook.Callback.(func(*Uc, uint32, uint32, uint32))(hook.Uc, port, size, value)
|
||||
}
|
||||
|
||||
//export hookX86Syscall
|
||||
func hookX86Syscall(handle C.uch, user unsafe.Pointer) {
|
||||
func hookX86Syscall(handle *C.uc_engine, user unsafe.Pointer) {
|
||||
hook := (*HookData)(user)
|
||||
hook.Callback.(func(*Uc))(hook.Uc)
|
||||
}
|
||||
|
||||
var hookRetain = make(map[C.uch]*HookData)
|
||||
var hookRetain = make(map[C.uc_hook]*HookData)
|
||||
|
||||
func (u *Uc) HookAdd(htype int, cb interface{}, extra ...uint64) (C.uch, error) {
|
||||
func (u *Uc) HookAdd(htype int, cb interface{}, extra ...uint64) (C.uc_hook, error) {
|
||||
var callback unsafe.Pointer
|
||||
var iarg1 C.int
|
||||
var uarg1, uarg2 C.uint64_t
|
||||
@ -92,7 +92,7 @@ func (u *Uc) HookAdd(htype int, cb interface{}, extra ...uint64) (C.uch, error)
|
||||
default:
|
||||
return 0, errors.New("Unknown hook type.")
|
||||
}
|
||||
var h2 C.uch
|
||||
var h2 C.uc_hook
|
||||
data := &HookData{u, cb}
|
||||
if rangeMode {
|
||||
if len(extra) == 2 {
|
||||
@ -109,7 +109,7 @@ func (u *Uc) HookAdd(htype int, cb interface{}, extra ...uint64) (C.uch, error)
|
||||
return h2, nil
|
||||
}
|
||||
|
||||
func (u *Uc) HookDel(hook *C.uch) error {
|
||||
delete(hookRetain, *hook)
|
||||
func (u *Uc) HookDel(hook C.uc_hook) error {
|
||||
delete(hookRetain, hook)
|
||||
return errReturn(C.uc_hook_del(u.Handle, hook))
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
uc_err uc_hook_add_i1(uch handle, uch *h2, uc_hook_type type, void *callback, void *user_data, int arg1);
|
||||
uc_err uc_hook_add_u2(uch handle, uch *h2, uc_hook_type type, void *callback, void *user_data, uint64_t arg1, uint64_t arg2);
|
||||
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);
|
||||
uc_err uc_hook_add_i1(uc_engine *handle, uc_hook *h2, uc_hook_type type, void *callback, void *user_data, int arg1);
|
||||
uc_err uc_hook_add_u2(uc_engine *handle, uc_hook *h2, uc_hook_type type, void *callback, void *user_data, uint64_t arg1, uint64_t arg2);
|
||||
void hookCode_cgo(uc_engine *handle, uint64_t addr, uint32_t size, void *user);
|
||||
bool hookMemInvalid_cgo(uc_engine *handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user);
|
||||
void hookMemAccess_cgo(uc_engine *handle, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user);
|
||||
void hookInterrupt_cgo(uc_engine *handle, uint32_t intno, void *user);
|
||||
uint32_t hookX86In_cgo(uc_engine *handle, uint32_t port, uint32_t size, void *user);
|
||||
void hookX86Out_cgo(uc_engine *handle, uint32_t port, uint32_t size, uint32_t value, void *user);
|
||||
void hookX86Syscall_cgo(uc_engine *handle, void *user);
|
||||
|
@ -24,7 +24,7 @@ func errReturn(err C.uc_err) error {
|
||||
}
|
||||
|
||||
type Uc struct {
|
||||
Handle C.uch
|
||||
Handle *C.uc_engine
|
||||
Arch, Mode int
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ func NewUc(arch, mode int) (*Uc, error) {
|
||||
if major != C.UC_API_MAJOR || minor != C.UC_API_MINOR {
|
||||
return nil, UcError(UC_ERR_VERSION)
|
||||
}
|
||||
var handle C.uch
|
||||
var handle *C.uc_engine
|
||||
if ucerr := C.uc_open(C.uc_arch(arch), C.uc_mode(mode), &handle); ucerr != UC_ERR_OK {
|
||||
return nil, UcError(ucerr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user