rename uchook to uc_hook, ucengine to uc_engine, uc_hook_t to uc_hook_type

This commit is contained in:
Nguyen Anh Quynh
2015-09-05 11:20:32 +08:00
parent 74c069dc22
commit d1bdbd11e7
29 changed files with 190 additions and 190 deletions

View File

@@ -1,11 +1,11 @@
#include <unicorn/unicorn.h>
#include "_cgo_export.h"
uc_err uc_hook_add_i1(uch handle, uch *h2, uc_hook_t type, void *callback, void *user, int arg1) {
uc_err uc_hook_add_i1(uch handle, uch *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_t type, void *callback, void *user, uint64_t arg1, uint64_t arg2) {
uc_err uc_hook_add_u2(uch handle, uch *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);
}

View File

@@ -101,9 +101,9 @@ func (u *Uc) HookAdd(htype int, cb interface{}, extra ...uint64) (C.uch, error)
} else {
uarg1, uarg2 = 1, 0
}
C.uc_hook_add_u2(u.Handle, &h2, C.uc_hook_t(htype), callback, unsafe.Pointer(data), uarg1, uarg2)
C.uc_hook_add_u2(u.Handle, &h2, C.uc_hook_type(htype), callback, unsafe.Pointer(data), uarg1, uarg2)
} else {
C.uc_hook_add_i1(u.Handle, &h2, C.uc_hook_t(htype), callback, unsafe.Pointer(data), iarg1)
C.uc_hook_add_i1(u.Handle, &h2, C.uc_hook_type(htype), callback, unsafe.Pointer(data), iarg1)
}
hookRetain[h2] = data
return h2, nil

View File

@@ -1,5 +1,5 @@
uc_err uc_hook_add_i1(uch handle, uch *h2, uc_hook_t type, void *callback, void *user_data, int arg1);
uc_err uc_hook_add_u2(uch handle, uch *h2, uc_hook_t type, void *callback, void *user_data, uint64_t arg1, uint64_t arg2);
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);

View File

@@ -73,7 +73,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_BLOCK
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param address The address of the instruction being executed
* @param size The size of the basic block being executed
* @see hook_add, unicorn.BlockHook
@@ -93,7 +93,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_INTR
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param intno The interrupt number
* @see hook_add, unicorn.InterruptHook
*/
@@ -112,7 +112,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_CODE
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param address The address of the instruction being executed
* @param size The size of the instruction being executed
* @see hook_add, unicorn.CodeHook
@@ -132,7 +132,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_MEM_INVALID
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param type This memory is being read (UC_MEM_READ), or written (UC_MEM_WRITE)
* @param address Address of instruction being executed
* @param size Size of data being read or written
@@ -157,7 +157,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_MEM_READ
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param address Address of instruction being executed
* @param size Size of data being read
* @see hook_add, unicorn.ReadHook
@@ -177,7 +177,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_MEM_WRITE
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param address Address of instruction being executed
* @param size Size of data being read
* @param value value being written
@@ -198,7 +198,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_MEM_READ_WRITE
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param type Type of access being performed (UC_MEM_READ, UC_MEM_WRITE, UC_MEM_READ_WRITE)
* @param address Address of instruction being executed
* @param size Size of data being read
@@ -221,7 +221,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_INSN
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param port I/O Port number
* @param size Data size (1/2/4) to be read from this port
* @return Data supplied from the input port
@@ -245,7 +245,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_INSN
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param port I/O Port number
* @param size Data size (1/2/4) to be written to this port
* @see hook_add, unicorn.OutHook
@@ -267,7 +267,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
* This function gets invoked from the native C callback registered for
* for UC_HOOK_INSN
*
* @param eng A Unicorn ucengine* eng returned by uc_open
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @see hook_add, unicorn.SyscallHook
*/
private static void invokeSyscallCallbacks(long eng) {
@@ -340,7 +340,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
public native static boolean arch_supported(int arch);
/**
* Close the underlying ucengine* eng associated with this Unicorn object
* Close the underlying uc_engine* eng associated with this Unicorn object
*
*/
public native void close() throws UnicornException;
@@ -417,7 +417,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
/**
* Hook registration helper for hook types that require no additional arguments.
*
* @param eng Internal unicorn ucengine* eng associated with hooking Unicorn object
* @param eng Internal unicorn uc_engine* eng associated with hooking Unicorn object
* @param type UC_HOOK_* hook type
* @return Unicorn uch returned for registered hook function
*/
@@ -426,7 +426,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
/**
* Hook registration helper for hook types that require one additional argument.
*
* @param eng Internal unicorn ucengine* eng associated with hooking Unicorn object
* @param eng Internal unicorn uc_engine* eng associated with hooking Unicorn object
* @param type UC_HOOK_* hook type
* @param arg1 Additional varargs argument
* @return Unicorn uch returned for registered hook function
@@ -436,7 +436,7 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
/**
* Hook registration helper for hook types that require two additional arguments.
*
* @param eng Internal unicorn ucengine* eng associated with hooking Unicorn object
* @param eng Internal unicorn uc_engine* eng associated with hooking Unicorn object
* @param type UC_HOOK_* hook type
* @param arg1 First additional varargs argument
* @param arg2 Second additional varargs argument

View File

@@ -61,40 +61,40 @@ def _setup_prototype(lib, fname, restype, *argtypes):
getattr(lib, fname).argtypes = argtypes
ucerr = ctypes.c_int
ucengine = ctypes.c_void_p
uc_engine = ctypes.c_void_p
uc_hook_h = ctypes.c_size_t
_setup_prototype(_uc, "uc_version", ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
_setup_prototype(_uc, "uc_arch_supported", ctypes.c_bool, ctypes.c_int)
_setup_prototype(_uc, "uc_open", ucerr, ctypes.c_uint, ctypes.c_uint, ctypes.POINTER(ucengine))
_setup_prototype(_uc, "uc_close", ucerr, ucengine)
_setup_prototype(_uc, "uc_open", ucerr, ctypes.c_uint, ctypes.c_uint, ctypes.POINTER(uc_engine))
_setup_prototype(_uc, "uc_close", ucerr, uc_engine)
_setup_prototype(_uc, "uc_strerror", ctypes.c_char_p, ucerr)
_setup_prototype(_uc, "uc_errno", ucerr, ucengine)
_setup_prototype(_uc, "uc_reg_read", ucerr, ucengine, ctypes.c_int, ctypes.c_void_p)
_setup_prototype(_uc, "uc_reg_write", ucerr, ucengine, ctypes.c_int, ctypes.c_void_p)
_setup_prototype(_uc, "uc_mem_read", ucerr, ucengine, ctypes.c_uint64, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t)
_setup_prototype(_uc, "uc_mem_write", ucerr, ucengine, ctypes.c_uint64, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t)
_setup_prototype(_uc, "uc_emu_start", ucerr, ucengine, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_size_t)
_setup_prototype(_uc, "uc_emu_stop", ucerr, ucengine)
_setup_prototype(_uc, "uc_hook_del", ucerr, ucengine, uc_hook_h)
_setup_prototype(_uc, "uc_mem_map", ucerr, ucengine, ctypes.c_uint64, ctypes.c_size_t, ctypes.c_uint32)
_setup_prototype(_uc, "uc_errno", ucerr, uc_engine)
_setup_prototype(_uc, "uc_reg_read", ucerr, uc_engine, ctypes.c_int, ctypes.c_void_p)
_setup_prototype(_uc, "uc_reg_write", ucerr, uc_engine, ctypes.c_int, ctypes.c_void_p)
_setup_prototype(_uc, "uc_mem_read", ucerr, uc_engine, ctypes.c_uint64, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t)
_setup_prototype(_uc, "uc_mem_write", ucerr, uc_engine, ctypes.c_uint64, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t)
_setup_prototype(_uc, "uc_emu_start", ucerr, uc_engine, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_size_t)
_setup_prototype(_uc, "uc_emu_stop", ucerr, uc_engine)
_setup_prototype(_uc, "uc_hook_del", ucerr, uc_engine, uc_hook_h)
_setup_prototype(_uc, "uc_mem_map", ucerr, uc_engine, ctypes.c_uint64, ctypes.c_size_t, ctypes.c_uint32)
# uc_hook_add is special due to variable number of arguments
_uc.uc_hook_add = getattr(_uc, "uc_hook_add")
_uc.uc_hook_add.restype = ucerr
UC_HOOK_CODE_CB = ctypes.CFUNCTYPE(None, ucengine, ctypes.c_uint64, ctypes.c_size_t, ctypes.c_void_p)
UC_HOOK_MEM_INVALID_CB = ctypes.CFUNCTYPE(ctypes.c_bool, ucengine, ctypes.c_int, \
UC_HOOK_CODE_CB = ctypes.CFUNCTYPE(None, uc_engine, ctypes.c_uint64, ctypes.c_size_t, ctypes.c_void_p)
UC_HOOK_MEM_INVALID_CB = ctypes.CFUNCTYPE(ctypes.c_bool, uc_engine, ctypes.c_int, \
ctypes.c_uint64, ctypes.c_int, ctypes.c_int64, ctypes.c_void_p)
UC_HOOK_MEM_ACCESS_CB = ctypes.CFUNCTYPE(None, ucengine, ctypes.c_int, \
UC_HOOK_MEM_ACCESS_CB = ctypes.CFUNCTYPE(None, uc_engine, ctypes.c_int, \
ctypes.c_uint64, ctypes.c_int, ctypes.c_int64, ctypes.c_void_p)
UC_HOOK_INTR_CB = ctypes.CFUNCTYPE(None, ucengine, ctypes.c_uint32, \
UC_HOOK_INTR_CB = ctypes.CFUNCTYPE(None, uc_engine, ctypes.c_uint32, \
ctypes.c_void_p)
UC_HOOK_INSN_IN_CB = ctypes.CFUNCTYPE(ctypes.c_uint32, ucengine, ctypes.c_uint32, \
UC_HOOK_INSN_IN_CB = ctypes.CFUNCTYPE(ctypes.c_uint32, uc_engine, ctypes.c_uint32, \
ctypes.c_int, ctypes.c_void_p)
UC_HOOK_INSN_OUT_CB = ctypes.CFUNCTYPE(None, ucengine, ctypes.c_uint32, \
UC_HOOK_INSN_OUT_CB = ctypes.CFUNCTYPE(None, uc_engine, ctypes.c_uint32, \
ctypes.c_int, ctypes.c_uint32, ctypes.c_void_p)
UC_HOOK_INSN_SYSCALL_CB = ctypes.CFUNCTYPE(None, ucengine, ctypes.c_void_p)
UC_HOOK_INSN_SYSCALL_CB = ctypes.CFUNCTYPE(None, uc_engine, ctypes.c_void_p)
# access to error code via @errno of UcError