s/uc_hook_h/uchook/g

This commit is contained in:
Jonathon Reinhart 2015-09-03 22:39:23 -04:00
parent 99e34d212a
commit 5f32e2c1ae
20 changed files with 38 additions and 38 deletions

2
hook.c
View file

@ -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 // return 0 on success, -1 on failure
uc_err hook_del(struct uc_struct *uc, uc_hook_h hh) uc_err hook_del(struct uc_struct *uc, uchook hh)
{ {
if (hh == uc->hook_block_idx) { if (hh == uc->hook_block_idx) {
uc->hook_block_idx = 0; uc->hook_block_idx = 0;

View file

@ -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); 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 // return 0 on success, -1 on failure
uc_err hook_del(struct uc_struct *uc, uc_hook_h hh); uc_err hook_del(struct uc_struct *uc, uchook hh);
// return NULL on failure // return NULL on failure
struct hook_struct *hook_find(struct uc_struct *uc, int type, uint64_t address); struct hook_struct *hook_find(struct uc_struct *uc, int type, uint64_t address);

View file

@ -22,7 +22,7 @@ extern "C" {
struct uc_struct; struct uc_struct;
typedef struct uc_struct ucengine; typedef struct uc_struct ucengine;
typedef size_t uc_hook_h; typedef size_t uchook;
#include "m68k.h" #include "m68k.h"
#include "x86.h" #include "x86.h"
@ -375,7 +375,7 @@ uc_err uc_emu_stop(ucengine *uc);
for detailed error). for detailed error).
*/ */
UNICORN_EXPORT UNICORN_EXPORT
uc_err uc_hook_add(ucengine *uc, uc_hook_h *hh, uc_hook_t type, void *callback, void *user_data, ...); uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, void *user_data, ...);
/* /*
Unregister (remove) a hook callback. Unregister (remove) a hook callback.
@ -390,7 +390,7 @@ uc_err uc_hook_add(ucengine *uc, uc_hook_h *hh, uc_hook_t type, void *callback,
for detailed error). for detailed error).
*/ */
UNICORN_EXPORT UNICORN_EXPORT
uc_err uc_hook_del(ucengine *uc, uc_hook_h hh); uc_err uc_hook_del(ucengine *uc, uchook hh);
typedef enum uc_prot { typedef enum uc_prot {
UC_PROT_NONE = 0, UC_PROT_NONE = 0,

View file

@ -62,7 +62,7 @@ int main() {
} }
fprintf(stderr, "ok %d - uc_mem_write\n", count++); fprintf(stderr, "ok %d - uc_mem_write\n", count++);
uc_hook_h h1, h2; uchook h1, h2;
err = uc_hook_add(uc, &h1, UC_HOOK_BLOCK, cb_hookblock, NULL, (uint64_t)1, (uint64_t)0); err = uc_hook_add(uc, &h1, UC_HOOK_BLOCK, cb_hookblock, NULL, (uint64_t)1, (uint64_t)0);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {

View file

@ -55,7 +55,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint32_t eax, ebx; uint32_t eax, ebx;

View file

@ -90,7 +90,7 @@ static void hook_mem_write(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint8_t buf1[100], readbuf[100]; uint8_t buf1[100], readbuf[100];

View file

@ -95,7 +95,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint8_t bytes[8]; uint8_t bytes[8];
uint32_t esp; uint32_t esp;

View file

@ -21,7 +21,7 @@ int main()
int size; int size;
uint8_t *buf; uint8_t *buf;
ucengine *uc; ucengine *uc;
uc_hook_h uh_trap; uchook uh_trap;
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc); uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
if (err) { if (err) {
fprintf (stderr, "Cannot initialize unicorn\n"); fprintf (stderr, "Cannot initialize unicorn\n");

View file

@ -38,7 +38,7 @@ static void test_arm(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r0 = 0x1234; // R0 register int r0 = 0x1234; // R0 register
int r2 = 0x6789; // R1 register int r2 = 0x6789; // R1 register
@ -94,7 +94,7 @@ static void test_thumb(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int sp = 0x1234; // R0 register int sp = 0x1234; // R0 register

View file

@ -143,7 +143,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint32_t esp, eip; uint32_t esp, eip;
int32_t buf1[1024], buf2[1024], readbuf[1024]; int32_t buf1[1024], buf2[1024], readbuf[1024];

View file

@ -161,7 +161,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint32_t addr, testval; uint32_t addr, testval;
int32_t buf1[1024], buf2[1024], readbuf[1024]; int32_t buf1[1024], buf2[1024], readbuf[1024];

View file

@ -156,7 +156,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
uint32_t addr, testval; uint32_t addr, testval;
int32_t buf1[1024], buf2[1024], readbuf[1024]; int32_t buf1[1024], buf2[1024], readbuf[1024];

View file

@ -29,7 +29,7 @@ static void test_arm(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r0 = 0x1234; // R0 register int r0 = 0x1234; // R0 register
int r2 = 0x6789; // R1 register int r2 = 0x6789; // R1 register
@ -85,7 +85,7 @@ static void test_thumb(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int sp = 0x1234; // R0 register int sp = 0x1234; // R0 register

View file

@ -28,7 +28,7 @@ static void test_arm64(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int64_t x11 = 0x1234; // X11 register int64_t x11 = 0x1234; // X11 register
int64_t x13 = 0x6789; // X13 register int64_t x13 = 0x6789; // X13 register

View file

@ -25,7 +25,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_
static void test_m68k(void) static void test_m68k(void)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1, trace2; uchook trace1, trace2;
uc_err err; uc_err err;
int d0 = 0x0000; // d0 data register int d0 = 0x0000; // d0 data register

View file

@ -29,7 +29,7 @@ static void test_mips_eb(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r1 = 0x6789; // R1 register int r1 = 0x6789; // R1 register
@ -78,7 +78,7 @@ static void test_mips_el(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r1 = 0x6789; // R1 register int r1 = 0x6789; // R1 register

View file

@ -29,7 +29,7 @@ static void test_sparc(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int g1 = 0x1230; // G1 register int g1 = 0x1230; // G1 register
int g2 = 0x6789; // G2 register int g2 = 0x6789; // G2 register

View file

@ -171,7 +171,7 @@ static void test_i386(void)
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uint32_t tmp; uint32_t tmp;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r_ecx = 0x1234; // ECX register int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register int r_edx = 0x7890; // EDX register
@ -232,7 +232,7 @@ static void test_i386_jump(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
printf("===================================\n"); printf("===================================\n");
printf("Emulate i386 code with jump\n"); printf("Emulate i386 code with jump\n");
@ -328,7 +328,7 @@ static void test_i386_invalid_mem_read(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r_ecx = 0x1234; // ECX register int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register int r_edx = 0x7890; // EDX register
@ -385,7 +385,7 @@ static void test_i386_invalid_mem_write(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2, trace3; uchook trace1, trace2, trace3;
uint32_t tmp; uint32_t tmp;
int r_ecx = 0x1234; // ECX register int r_ecx = 0x1234; // ECX register
@ -457,7 +457,7 @@ static void test_i386_jump_invalid(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r_ecx = 0x1234; // ECX register int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register int r_edx = 0x7890; // EDX register
@ -513,7 +513,7 @@ static void test_i386_inout(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2, trace3, trace4; uchook trace1, trace2, trace3, trace4;
int r_eax = 0x1234; // EAX register int r_eax = 0x1234; // EAX register
int r_ecx = 0x6789; // ECX register int r_ecx = 0x6789; // ECX register
@ -574,7 +574,7 @@ static void test_x86_64(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2, trace3, trace4; uchook trace1, trace2, trace3, trace4;
int64_t rax = 0x71f3029efd49d41d; int64_t rax = 0x71f3029efd49d41d;
int64_t rbx = 0xd87b45277f133ddb; int64_t rbx = 0xd87b45277f133ddb;
@ -689,7 +689,7 @@ static void test_x86_64(void)
static void test_x86_64_syscall(void) static void test_x86_64_syscall(void)
{ {
ucengine *uc; ucengine *uc;
uc_hook_h trace1; uchook trace1;
uc_err err; uc_err err;
int64_t rax = 0x100; int64_t rax = 0x100;

View file

@ -90,7 +90,7 @@ static void test_i386(void)
{ {
ucengine *uc; ucengine *uc;
uc_err err; uc_err err;
uc_hook_h trace1, trace2; uchook trace1, trace2;
int r_esp = ADDRESS + 0x200000; // ESP register int r_esp = ADDRESS + 0x200000; // ESP register

14
uc.c
View file

@ -521,7 +521,7 @@ uc_err uc_emu_stop(ucengine *uc)
static int _hook_code(ucengine *uc, int type, uint64_t begin, uint64_t end, static int _hook_code(ucengine *uc, int type, uint64_t begin, uint64_t end,
void *callback, void *user_data, uc_hook_h *hh) void *callback, void *user_data, uchook *hh)
{ {
int i; int i;
@ -537,7 +537,7 @@ 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(ucengine *uc, uc_hook_t type,
uint64_t begin, uint64_t end, uint64_t begin, uint64_t end,
void *callback, void *user_data, uc_hook_h *hh) void *callback, void *user_data, uchook *hh)
{ {
int i; int i;
@ -806,7 +806,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, static uc_err _hook_mem_invalid(struct uc_struct* uc, uc_cb_eventmem_t callback,
void *user_data, uc_hook_h *evh) void *user_data, uchook *evh)
{ {
size_t i; size_t i;
@ -825,7 +825,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, static uc_err _hook_intr(struct uc_struct* uc, void *callback,
void *user_data, uc_hook_h *evh) void *user_data, uchook *evh)
{ {
size_t i; size_t i;
@ -844,7 +844,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, static uc_err _hook_insn(struct uc_struct *uc, unsigned int insn_id, void *callback,
void *user_data, uc_hook_h *evh) void *user_data, uchook *evh)
{ {
size_t i; size_t i;
@ -895,7 +895,7 @@ static uc_err _hook_insn(struct uc_struct *uc, unsigned int insn_id, void *callb
} }
UNICORN_EXPORT UNICORN_EXPORT
uc_err uc_hook_add(ucengine *uc, uc_hook_h *hh, uc_hook_t type, void *callback, void *user_data, ...) uc_err uc_hook_add(ucengine *uc, uchook *hh, uc_hook_t type, void *callback, void *user_data, ...)
{ {
va_list valist; va_list valist;
int ret = UC_ERR_OK; int ret = UC_ERR_OK;
@ -951,7 +951,7 @@ uc_err uc_hook_add(ucengine *uc, uc_hook_h *hh, uc_hook_t type, void *callback,
} }
UNICORN_EXPORT UNICORN_EXPORT
uc_err uc_hook_del(ucengine *uc, uc_hook_h hh) uc_err uc_hook_del(ucengine *uc, uchook hh)
{ {
return hook_del(uc, hh); return hook_del(uc, hh);
} }