diff --git a/bindings/go/unicorn/hook.c b/bindings/go/unicorn/hook.c index f24dd1f1..68141993 100644 --- a/bindings/go/unicorn/hook.c +++ b/bindings/go/unicorn/hook.c @@ -1,11 +1,11 @@ #include #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); } diff --git a/bindings/go/unicorn/hook.go b/bindings/go/unicorn/hook.go index e6e01617..b6350e54 100644 --- a/bindings/go/unicorn/hook.go +++ b/bindings/go/unicorn/hook.go @@ -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 diff --git a/bindings/go/unicorn/hook.h b/bindings/go/unicorn/hook.h index b35fca27..e3e24433 100644 --- a/bindings/go/unicorn/hook.h +++ b/bindings/go/unicorn/hook.h @@ -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); diff --git a/bindings/java/unicorn/Unicorn.java b/bindings/java/unicorn/Unicorn.java index f5af24de..40476ae0 100644 --- a/bindings/java/unicorn/Unicorn.java +++ b/bindings/java/unicorn/Unicorn.java @@ -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 diff --git a/bindings/python/unicorn/unicorn.py b/bindings/python/unicorn/unicorn.py index ef3c03a3..080481ce 100644 --- a/bindings/python/unicorn/unicorn.py +++ b/bindings/python/unicorn/unicorn.py @@ -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 diff --git a/hook.c b/hook.c index 109a20d2..c201c315 100644 --- a/hook.c +++ b/hook.c @@ -91,7 +91,7 @@ size_t hook_add(struct uc_struct *uc, int type, uint64_t begin, uint64_t end, vo } // return 0 on success, -1 on failure -uc_err hook_del(struct uc_struct *uc, uchook hh) +uc_err hook_del(struct uc_struct *uc, uc_hook hh) { if (hh == uc->hook_block_idx) { uc->hook_block_idx = 0; diff --git a/include/hook.h b/include/hook.h index 08e9e9b0..6fbdf509 100644 --- a/include/hook.h +++ b/include/hook.h @@ -8,7 +8,7 @@ size_t hook_add(struct uc_struct *uc, int type, uint64_t begin, uint64_t end, void *callback, void *user_data); // return 0 on success, -1 on failure -uc_err hook_del(struct uc_struct *uc, uchook hh); +uc_err hook_del(struct uc_struct *uc, uc_hook hh); // return NULL on failure struct hook_struct *hook_find(struct uc_struct *uc, int type, uint64_t address); diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index fef7661d..0aca12f3 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -20,9 +20,9 @@ extern "C" { #include "platform.h" struct uc_struct; -typedef struct uc_struct ucengine; +typedef struct uc_struct uc_engine; -typedef size_t uchook; +typedef size_t uc_hook; #include "m68k.h" #include "x86.h" @@ -129,24 +129,24 @@ typedef enum uc_err { // @address: address where the code is being executed // @size: size of machine instruction(s) being executed, or 0 when size is unknown // @user_data: user data passed to tracing APIs. -typedef void (*uc_cb_hookcode_t)(ucengine *uc, uint64_t address, uint32_t size, void *user_data); +typedef void (*uc_cb_hookcode_t)(uc_engine *uc, uint64_t address, uint32_t size, void *user_data); // Callback function for tracing interrupts (for uc_hook_intr()) // @intno: interrupt number // @user_data: user data passed to tracing APIs. -typedef void (*uc_cb_hookintr_t)(ucengine *uc, uint32_t intno, void *user_data); +typedef void (*uc_cb_hookintr_t)(uc_engine *uc, uint32_t intno, void *user_data); // Callback function for tracing IN instruction of X86 // @port: port number // @size: data size (1/2/4) to be read from this port // @user_data: user data passed to tracing APIs. -typedef uint32_t (*uc_cb_insn_in_t)(ucengine *uc, uint32_t port, int size, void *user_data); +typedef uint32_t (*uc_cb_insn_in_t)(uc_engine *uc, uint32_t port, int size, void *user_data); // x86's handler for OUT // @port: port number // @size: data size (1/2/4) to be written to this port // @value: data value to be written to this port -typedef void (*uc_cb_insn_out_t)(ucengine *uc, uint32_t port, int size, uint32_t value, void *user_data); +typedef void (*uc_cb_insn_out_t)(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data); // All type of memory accesses for UC_HOOK_MEM_* typedef enum uc_mem_type { @@ -160,7 +160,7 @@ typedef enum uc_mem_type { } uc_mem_type; // All type of hooks for uc_hook_add() API. -typedef enum uc_hook_t { +typedef enum uc_hook_type { UC_HOOK_INTR = 32, // Hook all interrupt events UC_HOOK_INSN, // Hook a particular instruction UC_HOOK_CODE, // Hook a range of code @@ -169,7 +169,7 @@ typedef enum uc_hook_t { UC_HOOK_MEM_READ, // Hook all memory read events. UC_HOOK_MEM_WRITE, // Hook all memory write events. UC_HOOK_MEM_READ_WRITE, // Hook all memory accesses (either READ or WRITE). -} uc_hook_t; +} uc_hook_type; // Callback function for hooking memory (UC_HOOK_MEM_*) // @type: this memory is being READ, or WRITE @@ -177,7 +177,7 @@ typedef enum uc_hook_t { // @size: size of data being read or written // @value: value of data being written to memory, or irrelevant if type = READ. // @user_data: user data passed to tracing APIs -typedef void (*uc_cb_hookmem_t)(ucengine *uc, uc_mem_type type, +typedef void (*uc_cb_hookmem_t)(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data); // Callback function for handling memory events (for UC_HOOK_MEM_INVALID) @@ -187,7 +187,7 @@ typedef void (*uc_cb_hookmem_t)(ucengine *uc, uc_mem_type type, // @value: value of data being written to memory, or irrelevant if type = READ. // @user_data: user data passed to tracing APIs // @return: return true to continue, or false to stop program (due to invalid memory). -typedef bool (*uc_cb_eventmem_t)(ucengine *uc, uc_mem_type type, +typedef bool (*uc_cb_eventmem_t)(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data); @@ -228,13 +228,13 @@ bool uc_arch_supported(uc_arch arch); @arch: architecture type (UC_ARCH_*) @mode: hardware mode. This is combined of UC_MODE_* - @uc: pointer to ucengine, which will be updated at return time + @uc: pointer to uc_engine, which will be updated at return time @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum for detailed error). */ UNICORN_EXPORT -uc_err uc_open(uc_arch arch, uc_mode mode, ucengine **uc); +uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **uc); /* Close UC instance: MUST do to release the handle when it is not used anymore. @@ -249,7 +249,7 @@ uc_err uc_open(uc_arch arch, uc_mode mode, ucengine **uc); for detailed error). */ UNICORN_EXPORT -uc_err uc_close(ucengine *uc); +uc_err uc_close(uc_engine *uc); /* Report the last error number when some API function fail. @@ -260,7 +260,7 @@ uc_err uc_close(ucengine *uc); @return: error code of uc_err enum type (UC_ERR_*, see above) */ UNICORN_EXPORT -uc_err uc_errno(ucengine *uc); +uc_err uc_errno(uc_engine *uc); /* Return a string describing given error code. @@ -284,7 +284,7 @@ const char *uc_strerror(uc_err code); for detailed error). */ UNICORN_EXPORT -uc_err uc_reg_write(ucengine *uc, int regid, const void *value); +uc_err uc_reg_write(uc_engine *uc, int regid, const void *value); /* Read register value. @@ -297,7 +297,7 @@ uc_err uc_reg_write(ucengine *uc, int regid, const void *value); for detailed error). */ UNICORN_EXPORT -uc_err uc_reg_read(ucengine *uc, int regid, void *value); +uc_err uc_reg_read(uc_engine *uc, int regid, void *value); /* Write to a range of bytes in memory. @@ -313,7 +313,7 @@ uc_err uc_reg_read(ucengine *uc, int regid, void *value); for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_write(ucengine *uc, uint64_t address, const uint8_t *bytes, size_t size); +uc_err uc_mem_write(uc_engine *uc, uint64_t address, const uint8_t *bytes, size_t size); /* Read a range of bytes in memory. @@ -329,7 +329,7 @@ uc_err uc_mem_write(ucengine *uc, uint64_t address, const uint8_t *bytes, size_t for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_read(ucengine *uc, uint64_t address, uint8_t *bytes, size_t size); +uc_err uc_mem_read(uc_engine *uc, uint64_t address, uint8_t *bytes, size_t size); /* Emulate machine code in a specific duration of time. @@ -346,7 +346,7 @@ uc_err uc_mem_read(ucengine *uc, uint64_t address, uint8_t *bytes, size_t size); for detailed error). */ UNICORN_EXPORT -uc_err uc_emu_start(ucengine *uc, uint64_t begin, uint64_t until, uint64_t timeout, size_t count); +uc_err uc_emu_start(uc_engine *uc, uint64_t begin, uint64_t until, uint64_t timeout, size_t count); /* Stop emulation (which was started by uc_emu_start() API. @@ -359,7 +359,7 @@ uc_err uc_emu_start(ucengine *uc, uint64_t begin, uint64_t until, uint64_t timeo for detailed error). */ UNICORN_EXPORT -uc_err uc_emu_stop(ucengine *uc); +uc_err uc_emu_stop(uc_engine *uc); /* Register callback for a hook event. @@ -377,7 +377,7 @@ uc_err uc_emu_stop(ucengine *uc); for detailed error). */ UNICORN_EXPORT -uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, void *user_data, ...); +uc_err uc_hook_add(uc_engine *uc, uc_hook *hh, uc_hook_type type, void *callback, void *user_data, ...); /* Unregister (remove) a hook callback. @@ -392,7 +392,7 @@ uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, voi for detailed error). */ UNICORN_EXPORT -uc_err uc_hook_del(ucengine *uc, uchook hh); +uc_err uc_hook_del(uc_engine *uc, uc_hook hh); typedef enum uc_prot { UC_PROT_NONE = 0, @@ -419,7 +419,7 @@ typedef enum uc_prot { for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_map(ucengine *uc, uint64_t address, size_t size, uint32_t perms); +uc_err uc_mem_map(uc_engine *uc, uint64_t address, size_t size, uint32_t perms); /* Unmap a region of emulation memory. @@ -435,7 +435,7 @@ uc_err uc_mem_map(ucengine *uc, uint64_t address, size_t size, uint32_t perms); for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_unmap(ucengine *uc, uint64_t address, size_t size); +uc_err uc_mem_unmap(uc_engine *uc, uint64_t address, size_t size); /* Set memory permissions for emulation memory. @@ -454,7 +454,7 @@ uc_err uc_mem_unmap(ucengine *uc, uint64_t address, size_t size); for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_protect(ucengine *uc, uint64_t address, size_t size, uint32_t perms); +uc_err uc_mem_protect(uc_engine *uc, uint64_t address, size_t size, uint32_t perms); #ifdef __cplusplus } diff --git a/regress/block_test.c b/regress/block_test.c index 4cc2a826..9a648f07 100644 --- a/regress/block_test.c +++ b/regress/block_test.c @@ -13,7 +13,7 @@ static int count = 1; // @address: address where the code is being executed // @size: size of machine instruction being executed // @user_data: user data passed to tracing APIs. -void cb_hookblock(ucengine *uc, uint64_t address, uint32_t size, void *user_data) { +void cb_hookblock(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { fprintf(stderr, "# >>> Tracing basic block at 0x%"PRIx64", block size = 0x%x\n", address, size); if (address != 0x1000000 && address != 0x1000200) { fprintf(stderr, "not ok %d - address != 0x1000000 && address != 0x1000200\n", count++); @@ -28,7 +28,7 @@ void cb_hookblock(ucengine *uc, uint64_t address, uint32_t size, void *user_data } int main() { - ucengine *uc; + uc_engine *uc; fprintf(stderr, "# basic block callback test\n"); fprintf(stderr, "# there are only two basic blocks 0x1000000-0x10001ff and 0x1000200-0x10003ff\n"); @@ -63,7 +63,7 @@ int main() { } fprintf(stderr, "ok %d - uc_mem_write\n", count++); - uchook h1, h2; + uc_hook h1, h2; err = uc_hook_add(uc, &h1, UC_HOOK_BLOCK, cb_hookblock, NULL, (uint64_t)1, (uint64_t)0); if (err != UC_ERR_OK) { diff --git a/regress/map_crash.c b/regress/map_crash.c index e7fbf38c..f794b4d7 100644 --- a/regress/map_crash.c +++ b/regress/map_crash.c @@ -10,7 +10,7 @@ int main() { int size; uint8_t *buf; - ucengine *uc; + uc_engine *uc; uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc); if (err) { fprintf (stderr, "Cannot initialize unicorn\n"); diff --git a/regress/map_write.c b/regress/map_write.c index 40fada8d..7d64cda8 100644 --- a/regress/map_write.c +++ b/regress/map_write.c @@ -8,7 +8,7 @@ int main() { - ucengine *uc; + uc_engine *uc; uint8_t *buf, *buf2; int i; uc_err err; diff --git a/regress/mem_exec.c b/regress/mem_exec.c index 3b63012c..dc0dfdec 100644 --- a/regress/mem_exec.c +++ b/regress/mem_exec.c @@ -78,7 +78,7 @@ static int log_num = 1; #define CODE_SIZE 0x1000 // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data) { uint8_t opcode; @@ -104,14 +104,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat } // callback for tracing memory access (READ or WRITE) -static void hook_mem_write(ucengine *uc, uc_mem_type type, +static void hook_mem_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value); } // callback for tracing invalid memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { switch(type) { @@ -142,8 +142,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint32_t esp, eip; int32_t buf1[1024], buf2[1024], readbuf[1024]; diff --git a/regress/mem_protect.c b/regress/mem_protect.c index dfabd0fb..072c9819 100644 --- a/regress/mem_protect.c +++ b/regress/mem_protect.c @@ -77,7 +77,7 @@ static int log_num = 1; #define CODE_SIZE 0x1000 // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data) { uint8_t opcode; uint32_t testval; @@ -125,14 +125,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat } // callback for tracing memory access (READ or WRITE) -static void hook_mem_write(ucengine *uc, uc_mem_type type, +static void hook_mem_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value); } // callback for tracing invalid memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { uint32_t testval; @@ -160,8 +160,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint32_t addr, testval; int32_t buf1[1024], buf2[1024], readbuf[1024]; diff --git a/regress/mem_unmap.c b/regress/mem_unmap.c index 0bf61911..a2dc33c9 100644 --- a/regress/mem_unmap.c +++ b/regress/mem_unmap.c @@ -72,7 +72,7 @@ static int log_num = 1; #define CODE_SIZE 0x1000 // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data) { uint8_t opcode; uint32_t testval; @@ -120,14 +120,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat } // callback for tracing memory access (READ or WRITE) -static void hook_mem_write(ucengine *uc, uc_mem_type type, +static void hook_mem_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value); } // callback for tracing invalid memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { uint32_t testval; @@ -155,8 +155,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint32_t addr, testval; int32_t buf1[1024], buf2[1024], readbuf[1024]; diff --git a/regress/nr_mem_test.c b/regress/nr_mem_test.c index 4aa6db9c..3fb1f0f4 100644 --- a/regress/nr_mem_test.c +++ b/regress/nr_mem_test.c @@ -36,7 +36,7 @@ bits 32 */ // callback for tracing memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data) { @@ -54,8 +54,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint32_t eax, ebx; diff --git a/regress/rep_movsb.c b/regress/rep_movsb.c index 0d91cbef..d6632a33 100644 --- a/regress/rep_movsb.c +++ b/regress/rep_movsb.c @@ -50,7 +50,7 @@ hlt static int log_num = 1; // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data) { uint8_t opcode; if (uc_mem_read(uc, addr, &opcode, 1) != UC_ERR_OK) { @@ -74,7 +74,7 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat } // callback for tracing memory access (READ or WRITE) -static void hook_mem_write(ucengine *uc, uc_mem_type type, +static void hook_mem_write(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value); @@ -89,8 +89,8 @@ static void hook_mem_write(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint8_t buf1[100], readbuf[100]; diff --git a/regress/ro_mem_test.c b/regress/ro_mem_test.c index 330e3c49..02e13bac 100644 --- a/regress/ro_mem_test.c +++ b/regress/ro_mem_test.c @@ -46,7 +46,7 @@ bottom: */ // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { uint32_t esp; printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); @@ -57,7 +57,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_ } // callback for tracing memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data) { uint32_t esp; @@ -94,8 +94,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, int main(int argc, char **argv, char **envp) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint8_t bytes[8]; uint32_t esp; diff --git a/regress/sigill.c b/regress/sigill.c index b7317888..8ce230cd 100644 --- a/regress/sigill.c +++ b/regress/sigill.c @@ -8,7 +8,7 @@ int got_sigill = 0; -void _interrupt(ucengine *uc, uint32_t intno, void *user_data) +void _interrupt(uc_engine *uc, uint32_t intno, void *user_data) { if (intno == 6) { uc_emu_stop(uc); @@ -20,8 +20,8 @@ int main() { int size; uint8_t *buf; - ucengine *uc; - uchook uh_trap; + uc_engine *uc; + uc_hook uh_trap; uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc); if (err) { fprintf (stderr, "Cannot initialize unicorn\n"); diff --git a/regress/sigill2.c b/regress/sigill2.c index 1d955144..1e5b7284 100644 --- a/regress/sigill2.c +++ b/regress/sigill2.c @@ -10,7 +10,7 @@ int main() { int size; uint8_t *buf; - ucengine *uc; + uc_engine *uc; uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc); if (err) { diff --git a/regress/timeout_segfault.c b/regress/timeout_segfault.c index 73070978..de5b8761 100644 --- a/regress/timeout_segfault.c +++ b/regress/timeout_segfault.c @@ -24,21 +24,21 @@ https://github.com/unicorn-engine/unicorn/issues/78 // number of seconds to wait before timeout #define TIMEOUT 5 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_arm(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r0 = 0x1234; // R0 register int r2 = 0x6789; // R1 register @@ -92,9 +92,9 @@ static void test_arm(void) static void test_thumb(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int sp = 0x1234; // R0 register diff --git a/samples/mem_apis.c b/samples/mem_apis.c index 191b7c62..6237c578 100644 --- a/samples/mem_apis.c +++ b/samples/mem_apis.c @@ -31,7 +31,7 @@ static int insts_executed; // callback for tracing instructions, detect HLT and terminate emulation -static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data) { uint8_t opcode; unsigned char buf[256]; @@ -72,7 +72,7 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat } // callback for tracing invalid memory access (READ/WRITE/EXEC) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t addr, int size, int64_t value, void *user_data) { switch(type) { @@ -99,8 +99,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, static void do_nx_demo(bool cause_fault) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint8_t code_buf[0x3000]; @@ -181,8 +181,8 @@ static const uint8_t WRITE_DEMO[] = static void do_perms_demo(bool change_perms) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint8_t code_buf[0x3000]; @@ -257,8 +257,8 @@ static void perms_test() static void do_unmap_demo(bool do_unmap) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; uint8_t code_buf[0x3000]; diff --git a/samples/sample_arm.c b/samples/sample_arm.c index 81ec691b..de0c970b 100644 --- a/samples/sample_arm.c +++ b/samples/sample_arm.c @@ -15,21 +15,21 @@ // memory address where emulation starts #define ADDRESS 0x10000 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_arm(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r0 = 0x1234; // R0 register int r2 = 0x6789; // R1 register @@ -83,9 +83,9 @@ static void test_arm(void) static void test_thumb(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int sp = 0x1234; // R0 register diff --git a/samples/sample_arm64.c b/samples/sample_arm64.c index 3541b2f6..b0d53e07 100644 --- a/samples/sample_arm64.c +++ b/samples/sample_arm64.c @@ -14,21 +14,21 @@ // memory address where emulation starts #define ADDRESS 0x10000 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_arm64(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int64_t x11 = 0x1234; // X11 register int64_t x13 = 0x6789; // X13 register diff --git a/samples/sample_m68k.c b/samples/sample_m68k.c index b8fef353..a584c18d 100644 --- a/samples/sample_m68k.c +++ b/samples/sample_m68k.c @@ -12,20 +12,20 @@ // memory address where emulation starts #define ADDRESS 0x10000 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_m68k(void) { - ucengine *uc; - uchook trace1, trace2; + uc_engine *uc; + uc_hook trace1, trace2; uc_err err; int d0 = 0x0000; // d0 data register diff --git a/samples/sample_mips.c b/samples/sample_mips.c index e604563c..0b6e1a1b 100644 --- a/samples/sample_mips.c +++ b/samples/sample_mips.c @@ -15,21 +15,21 @@ // memory address where emulation starts #define ADDRESS 0x10000 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_mips_eb(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r1 = 0x6789; // R1 register @@ -76,9 +76,9 @@ static void test_mips_eb(void) static void test_mips_el(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r1 = 0x6789; // R1 register diff --git a/samples/sample_sparc.c b/samples/sample_sparc.c index 540b7d36..803bdfd7 100644 --- a/samples/sample_sparc.c +++ b/samples/sample_sparc.c @@ -15,21 +15,21 @@ // memory address where emulation starts #define ADDRESS 0x10000 -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_sparc(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int g1 = 0x1230; // G1 register int g2 = 0x6789; // G2 register diff --git a/samples/sample_x86.c b/samples/sample_x86.c index aecad6b5..1062aa15 100644 --- a/samples/sample_x86.c +++ b/samples/sample_x86.c @@ -32,13 +32,13 @@ #define ADDRESS 0x1000000 // callback for tracing basic blocks -static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { int eflags; printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); @@ -52,7 +52,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_ } // callback for tracing instruction -static void hook_code64(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code64(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { uint64_t rip; @@ -66,7 +66,7 @@ static void hook_code64(ucengine *uc, uint64_t address, uint32_t size, void *use } // callback for tracing memory access (READ or WRITE) -static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, +static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data) { switch(type) { @@ -83,7 +83,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type, } } -static void hook_mem64(ucengine *uc, uc_mem_type type, +static void hook_mem64(uc_engine *uc, uc_mem_type type, uint64_t address, int size, int64_t value, void *user_data) { switch(type) { @@ -101,7 +101,7 @@ static void hook_mem64(ucengine *uc, uc_mem_type type, // callback for IN instruction (X86). // this returns the data read from the port -static uint32_t hook_in(ucengine *uc, uint32_t port, int size, void *user_data) +static uint32_t hook_in(uc_engine *uc, uint32_t port, int size, void *user_data) { uint32_t eip; @@ -126,7 +126,7 @@ static uint32_t hook_in(ucengine *uc, uint32_t port, int size, void *user_data) } // callback for OUT instruction (X86). -static void hook_out(ucengine *uc, uint32_t port, int size, uint32_t value, void *user_data) +static void hook_out(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data) { uint32_t tmp; uint32_t eip; @@ -154,7 +154,7 @@ static void hook_out(ucengine *uc, uint32_t port, int size, uint32_t value, void } // callback for SYSCALL instruction (X86). -static void hook_syscall(ucengine *uc, void *user_data) +static void hook_syscall(uc_engine *uc, void *user_data) { uint64_t rax; @@ -168,10 +168,10 @@ static void hook_syscall(ucengine *uc, void *user_data) static void test_i386(void) { - ucengine *uc; + uc_engine *uc; uc_err err; uint32_t tmp; - uchook trace1, trace2; + uc_hook trace1, trace2; int r_ecx = 0x1234; // ECX register int r_edx = 0x7890; // EDX register @@ -230,9 +230,9 @@ static void test_i386(void) static void test_i386_jump(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; printf("===================================\n"); printf("Emulate i386 code with jump\n"); @@ -275,7 +275,7 @@ static void test_i386_jump(void) // emulate code that loop forever static void test_i386_loop(void) { - ucengine *uc; + uc_engine *uc; uc_err err; int r_ecx = 0x1234; // ECX register @@ -326,9 +326,9 @@ static void test_i386_loop(void) // emulate code that read invalid memory static void test_i386_invalid_mem_read(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r_ecx = 0x1234; // ECX register int r_edx = 0x7890; // EDX register @@ -383,9 +383,9 @@ static void test_i386_invalid_mem_read(void) // emulate code that read invalid memory static void test_i386_invalid_mem_write(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2, trace3; + uc_hook trace1, trace2, trace3; uint32_t tmp; int r_ecx = 0x1234; // ECX register @@ -455,9 +455,9 @@ static void test_i386_invalid_mem_write(void) // emulate code that jump to invalid memory static void test_i386_jump_invalid(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r_ecx = 0x1234; // ECX register int r_edx = 0x7890; // EDX register @@ -511,9 +511,9 @@ static void test_i386_jump_invalid(void) static void test_i386_inout(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2, trace3, trace4; + uc_hook trace1, trace2, trace3, trace4; int r_eax = 0x1234; // EAX register int r_ecx = 0x6789; // ECX register @@ -572,9 +572,9 @@ static void test_i386_inout(void) static void test_x86_64(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2, trace3, trace4; + uc_hook trace1, trace2, trace3, trace4; int64_t rax = 0x71f3029efd49d41d; int64_t rbx = 0xd87b45277f133ddb; @@ -688,8 +688,8 @@ static void test_x86_64(void) static void test_x86_64_syscall(void) { - ucengine *uc; - uchook trace1; + uc_engine *uc; + uc_hook trace1; uc_err err; int64_t rax = 0x100; @@ -739,7 +739,7 @@ static void test_x86_64_syscall(void) static void test_x86_16(void) { - ucengine *uc; + uc_engine *uc; uc_err err; uint8_t tmp; diff --git a/samples/shellcode.c b/samples/shellcode.c index 80ed1d16..d8ef6385 100644 --- a/samples/shellcode.c +++ b/samples/shellcode.c @@ -20,7 +20,7 @@ #define MIN(a, b) (a < b? a : b) // callback for tracing instruction -static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data) +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { int r_eip; char tmp[16]; @@ -42,7 +42,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_ // callback for handling interrupt // ref: http://syscalls.kernelgrok.com/ -static void hook_intr(ucengine *uc, uint32_t intno, void *user_data) +static void hook_intr(uc_engine *uc, uint32_t intno, void *user_data) { int32_t r_eax, r_ecx, r_eip; uint32_t r_edx, size; @@ -87,9 +87,9 @@ static void hook_intr(ucengine *uc, uint32_t intno, void *user_data) static void test_i386(void) { - ucengine *uc; + uc_engine *uc; uc_err err; - uchook trace1, trace2; + uc_hook trace1, trace2; int r_esp = ADDRESS + 0x200000; // ESP register diff --git a/uc.c b/uc.c index 732e6d04..b204c75c 100644 --- a/uc.c +++ b/uc.c @@ -45,7 +45,7 @@ unsigned int uc_version(unsigned int *major, unsigned int *minor) UNICORN_EXPORT -uc_err uc_errno(ucengine *uc) +uc_err uc_errno(uc_engine *uc) { return uc->errnum; } @@ -128,7 +128,7 @@ bool uc_arch_supported(uc_arch arch) UNICORN_EXPORT -uc_err uc_open(uc_arch arch, uc_mode mode, ucengine **result) +uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **result) { struct uc_struct *uc; @@ -247,7 +247,7 @@ uc_err uc_open(uc_arch arch, uc_mode mode, ucengine **result) UNICORN_EXPORT -uc_err uc_close(ucengine *uc) +uc_err uc_close(uc_engine *uc) { if (uc->release) uc->release(uc->tcg_ctx); @@ -287,7 +287,7 @@ uc_err uc_close(ucengine *uc) UNICORN_EXPORT -uc_err uc_reg_read(ucengine *uc, int regid, void *value) +uc_err uc_reg_read(uc_engine *uc, int regid, void *value) { if (uc->reg_read) uc->reg_read(uc, regid, value); @@ -299,7 +299,7 @@ uc_err uc_reg_read(ucengine *uc, int regid, void *value) UNICORN_EXPORT -uc_err uc_reg_write(ucengine *uc, int regid, const void *value) +uc_err uc_reg_write(uc_engine *uc, int regid, const void *value) { if (uc->reg_write) uc->reg_write(uc, regid, value); @@ -312,7 +312,7 @@ uc_err uc_reg_write(ucengine *uc, int regid, const void *value) // check if a memory area is mapped // this is complicated because an area can overlap adjacent blocks -static bool check_mem_area(ucengine *uc, uint64_t address, size_t size) +static bool check_mem_area(uc_engine *uc, uint64_t address, size_t size) { size_t count = 0, len; @@ -331,7 +331,7 @@ static bool check_mem_area(ucengine *uc, uint64_t address, size_t size) UNICORN_EXPORT -uc_err uc_mem_read(ucengine *uc, uint64_t address, uint8_t *bytes, size_t size) +uc_err uc_mem_read(uc_engine *uc, uint64_t address, uint8_t *bytes, size_t size) { if (!check_mem_area(uc, address, size)) return UC_ERR_MEM_READ; @@ -359,7 +359,7 @@ uc_err uc_mem_read(ucengine *uc, uint64_t address, uint8_t *bytes, size_t size) } UNICORN_EXPORT -uc_err uc_mem_write(ucengine *uc, uint64_t address, const uint8_t *bytes, size_t size) +uc_err uc_mem_write(uc_engine *uc, uint64_t address, const uint8_t *bytes, size_t size) { if (!check_mem_area(uc, address, size)) return UC_ERR_MEM_WRITE; @@ -418,7 +418,7 @@ static void *_timeout_fn(void *arg) return NULL; } -static void enable_emu_timer(ucengine *uc, uint64_t timeout) +static void enable_emu_timer(uc_engine *uc, uint64_t timeout) { uc->timeout = timeout; qemu_thread_create(uc, &uc->timer, "timeout", _timeout_fn, @@ -426,7 +426,7 @@ static void enable_emu_timer(ucengine *uc, uint64_t timeout) } UNICORN_EXPORT -uc_err uc_emu_start(ucengine* uc, uint64_t begin, uint64_t until, uint64_t timeout, size_t count) +uc_err uc_emu_start(uc_engine* uc, uint64_t begin, uint64_t until, uint64_t timeout, size_t count) { // reset the counter uc->emu_counter = 0; @@ -509,7 +509,7 @@ uc_err uc_emu_start(ucengine* uc, uint64_t begin, uint64_t until, uint64_t timeo UNICORN_EXPORT -uc_err uc_emu_stop(ucengine *uc) +uc_err uc_emu_stop(uc_engine *uc) { if (uc->emulation_done) return UC_ERR_OK; @@ -522,8 +522,8 @@ uc_err uc_emu_stop(ucengine *uc) } -static int _hook_code(ucengine *uc, int type, uint64_t begin, uint64_t end, - void *callback, void *user_data, uchook *hh) +static int _hook_code(uc_engine *uc, int type, uint64_t begin, uint64_t end, + void *callback, void *user_data, uc_hook *hh) { int i; @@ -537,9 +537,9 @@ static int _hook_code(ucengine *uc, int type, uint64_t begin, uint64_t end, } -static uc_err _hook_mem_access(ucengine *uc, uc_hook_t type, +static uc_err _hook_mem_access(uc_engine *uc, uc_hook_type type, uint64_t begin, uint64_t end, - void *callback, void *user_data, uchook *hh) + void *callback, void *user_data, uc_hook *hh) { int i; @@ -553,7 +553,7 @@ static uc_err _hook_mem_access(ucengine *uc, uc_hook_t type, } UNICORN_EXPORT -uc_err uc_mem_map(ucengine *uc, uint64_t address, size_t size, uint32_t perms) +uc_err uc_mem_map(uc_engine *uc, uint64_t address, size_t size, uint32_t perms) { MemoryRegion **regions; @@ -817,7 +817,7 @@ MemoryRegion *memory_mapping(struct uc_struct* uc, uint64_t address) } static uc_err _hook_mem_invalid(struct uc_struct* uc, uc_cb_eventmem_t callback, - void *user_data, uchook *evh) + void *user_data, uc_hook *evh) { size_t i; @@ -836,7 +836,7 @@ static uc_err _hook_mem_invalid(struct uc_struct* uc, uc_cb_eventmem_t callback, static uc_err _hook_intr(struct uc_struct* uc, void *callback, - void *user_data, uchook *evh) + void *user_data, uc_hook *evh) { size_t i; @@ -855,7 +855,7 @@ static uc_err _hook_intr(struct uc_struct* uc, void *callback, static uc_err _hook_insn(struct uc_struct *uc, unsigned int insn_id, void *callback, - void *user_data, uchook *evh) + void *user_data, uc_hook *evh) { size_t i; @@ -906,7 +906,7 @@ static uc_err _hook_insn(struct uc_struct *uc, unsigned int insn_id, void *callb } UNICORN_EXPORT -uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, void *user_data, ...) +uc_err uc_hook_add(uc_engine *uc, uc_hook *hh, uc_hook_type type, void *callback, void *user_data, ...) { va_list valist; int ret = UC_ERR_OK; @@ -962,7 +962,7 @@ uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, voi } UNICORN_EXPORT -uc_err uc_hook_del(ucengine *uc, uchook hh) +uc_err uc_hook_del(uc_engine *uc, uc_hook hh) { return hook_del(uc, hh); }