From b57662e43d03e17a2514941c9280fecc812fd728 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Wed, 26 Aug 2015 07:06:12 -0400 Subject: [PATCH] change uch to uc_struct (target-i386) --- qemu/target-i386/seg_helper.c | 2 +- qemu/target-i386/translate.c | 4 ++-- qemu/target-i386/unicorn.c | 21 ++++++--------------- qemu/target-i386/unicorn.h | 6 +++--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/qemu/target-i386/seg_helper.c b/qemu/target-i386/seg_helper.c index 0bae3ca..2111ac7 100644 --- a/qemu/target-i386/seg_helper.c +++ b/qemu/target-i386/seg_helper.c @@ -949,7 +949,7 @@ void helper_syscall(CPUX86State *env, int next_eip_addend) struct uc_struct *uc = env->uc; if (uc->hook_syscall_idx) { ((uc_cb_insn_syscall_t)uc->hook_callbacks[uc->hook_syscall_idx].callback)( - (uch)uc, uc->hook_callbacks[uc->hook_syscall_idx].user_data); + uc, uc->hook_callbacks[uc->hook_syscall_idx].user_data); env->eip += next_eip_addend; } diff --git a/qemu/target-i386/translate.c b/qemu/target-i386/translate.c index 7ce37ef..776f73c 100644 --- a/qemu/target-i386/translate.c +++ b/qemu/target-i386/translate.c @@ -4756,7 +4756,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, // Unicorn: trace this instruction on request if (env->uc->hook_insn) { - trace = hook_find((uch)env->uc, UC_HOOK_CODE, pc_start); + trace = hook_find(env->uc, UC_HOOK_CODE, pc_start); if (trace) { if (s->last_cc_op != s->cc_op) { sync_eflags(s, tcg_ctx); @@ -8353,7 +8353,7 @@ static inline void gen_intermediate_code_internal(uint8_t *gen_opc_cc_op, // Only hook this block if it is not broken from previous translation due to // full translation cache if (env->uc->hook_block && !env->uc->block_full) { - struct hook_struct *trace = hook_find((uch)env->uc, UC_HOOK_BLOCK, pc_start); + struct hook_struct *trace = hook_find(env->uc, UC_HOOK_BLOCK, pc_start); if (trace) { env->uc->block_addr = pc_start; gen_uc_tracecode(tcg_ctx, 0xf8f8f8f8, trace->callback, env->uc, pc_start, trace->user_data); diff --git a/qemu/target-i386/unicorn.c b/qemu/target-i386/unicorn.c index c635021..9db3fb6 100644 --- a/qemu/target-i386/unicorn.c +++ b/qemu/target-i386/unicorn.c @@ -48,12 +48,9 @@ void x86_release(void *ctx) g_free(s->tb_ctx.tbs); } -void x86_reg_reset(uch handle) +void x86_reg_reset(struct uc_struct *uc) { - struct uc_struct *uc = (struct uc_struct *) handle; - CPUArchState *env; - - env = first_cpu->env_ptr; + CPUArchState *env = first_cpu->env_ptr; env->invalid_error = UC_ERR_OK; // no error memset(env->regs, 0, sizeof(env->regs)); @@ -138,12 +135,9 @@ void x86_reg_reset(uch handle) } } -int x86_reg_read(uch handle, unsigned int regid, void *value) +int x86_reg_read(struct uc_struct *uc, unsigned int regid, void *value) { - CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; - - mycpu = first_cpu; + CPUState *mycpu = first_cpu; switch(uc->mode) { default: @@ -540,12 +534,9 @@ int x86_reg_read(uch handle, unsigned int regid, void *value) #define WRITE_BYTE_H(x, b) (x = (x & ~0xff00) | (b & 0xff)) #define WRITE_BYTE_L(x, b) (x = (x & ~0xff) | (b & 0xff)) -int x86_reg_write(uch handle, unsigned int regid, const void *value) +int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value) { - CPUState *mycpu; - struct uc_struct *uc = (struct uc_struct *) handle; - - mycpu = first_cpu; + CPUState *mycpu = first_cpu; switch(uc->mode) { default: diff --git a/qemu/target-i386/unicorn.h b/qemu/target-i386/unicorn.h index b710236..a4dda81 100644 --- a/qemu/target-i386/unicorn.h +++ b/qemu/target-i386/unicorn.h @@ -5,10 +5,10 @@ #define UC_QEMU_TARGET_I386_H // functions to read & write registers -int x86_reg_read(uch handle, unsigned int regid, void *value); -int x86_reg_write(uch handle, unsigned int regid, const void *value); +int x86_reg_read(struct uc_struct *uc, unsigned int regid, void *value); +int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value); -void x86_reg_reset(uch handle); +void x86_reg_reset(struct uc_struct *uc); void x86_uc_init(struct uc_struct* uc); int x86_uc_machine_init(struct uc_struct *uc);