Sync HOOK_INSN hooks
This commit is contained in:
@@ -28,10 +28,11 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "exec/memory.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "uc_priv.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
|
||||
void cpu_outb(struct uc_struct *uc, uint32_t addr, uint8_t val)
|
||||
void cpu_outb(struct uc_struct *uc, uint32_t addr, uint8_t val, uintptr_t retaddr)
|
||||
{
|
||||
// address_space_write(&uc->address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
|
||||
// &val, 1);
|
||||
@@ -39,17 +40,22 @@ void cpu_outb(struct uc_struct *uc, uint32_t addr, uint8_t val)
|
||||
//LOG_IOPORT("outb: %04"FMT_pioaddr" %02"PRIx8"\n", addr, val);
|
||||
// Unicorn: call registered OUT callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_OUT) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
JIT_CALLBACK_GUARD(((uc_cb_insn_out_t)hook->callback)(uc, addr, 1, val, hook->user_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cpu_outw(struct uc_struct *uc, uint32_t addr, uint16_t val)
|
||||
void cpu_outw(struct uc_struct *uc, uint32_t addr, uint16_t val, uintptr_t retaddr)
|
||||
{
|
||||
// uint8_t buf[2];
|
||||
|
||||
@@ -60,17 +66,22 @@ void cpu_outw(struct uc_struct *uc, uint32_t addr, uint16_t val)
|
||||
//LOG_IOPORT("outw: %04"FMT_pioaddr" %04"PRIx16"\n", addr, val);
|
||||
// Unicorn: call registered OUT callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_OUT) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
JIT_CALLBACK_GUARD(((uc_cb_insn_out_t)hook->callback)(uc, addr, 2, val, hook->user_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cpu_outl(struct uc_struct *uc, uint32_t addr, uint32_t val)
|
||||
void cpu_outl(struct uc_struct *uc, uint32_t addr, uint32_t val, uintptr_t retaddr)
|
||||
{
|
||||
// uint8_t buf[4];
|
||||
|
||||
@@ -81,17 +92,22 @@ void cpu_outl(struct uc_struct *uc, uint32_t addr, uint32_t val)
|
||||
//LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
|
||||
// Unicorn: call registered OUT callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_OUT) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
JIT_CALLBACK_GUARD(((uc_cb_insn_out_t)hook->callback)(uc, addr, 4, val, hook->user_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t cpu_inb(struct uc_struct *uc, uint32_t addr)
|
||||
uint8_t cpu_inb(struct uc_struct *uc, uint32_t addr, uintptr_t retaddr)
|
||||
{
|
||||
// uint8_t val;
|
||||
|
||||
@@ -101,11 +117,16 @@ uint8_t cpu_inb(struct uc_struct *uc, uint32_t addr)
|
||||
//LOG_IOPORT("inb : %04"FMT_pioaddr" %02"PRIx8"\n", addr, val);
|
||||
// Unicorn: call registered IN callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_IN) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
uint8_t ret;
|
||||
JIT_CALLBACK_GUARD_VAR(ret, ((uc_cb_insn_in_t)hook->callback)(uc, addr, 1, hook->user_data));
|
||||
return ret;
|
||||
@@ -115,7 +136,7 @@ uint8_t cpu_inb(struct uc_struct *uc, uint32_t addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t cpu_inw(struct uc_struct *uc, uint32_t addr)
|
||||
uint16_t cpu_inw(struct uc_struct *uc, uint32_t addr, uintptr_t retaddr)
|
||||
{
|
||||
// uint8_t buf[2];
|
||||
// uint16_t val;
|
||||
@@ -126,11 +147,16 @@ uint16_t cpu_inw(struct uc_struct *uc, uint32_t addr)
|
||||
//LOG_IOPORT("inw : %04"FMT_pioaddr" %04"PRIx16"\n", addr, val);
|
||||
// Unicorn: call registered IN callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_IN) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
uint16_t ret;
|
||||
JIT_CALLBACK_GUARD_VAR(ret, ((uc_cb_insn_in_t)hook->callback)(uc, addr, 2, hook->user_data));
|
||||
return ret;
|
||||
@@ -140,7 +166,7 @@ uint16_t cpu_inw(struct uc_struct *uc, uint32_t addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t cpu_inl(struct uc_struct *uc, uint32_t addr)
|
||||
uint32_t cpu_inl(struct uc_struct *uc, uint32_t addr, uintptr_t retaddr)
|
||||
{
|
||||
// uint8_t buf[4];
|
||||
// uint32_t val;
|
||||
@@ -153,11 +179,16 @@ uint32_t cpu_inl(struct uc_struct *uc, uint32_t addr)
|
||||
//LOG_IOPORT("inl : %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);
|
||||
// Unicorn: call registered IN callbacks
|
||||
struct hook *hook;
|
||||
bool synced = false;
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(uc, hook, UC_HOOK_INSN) {
|
||||
if (hook->to_delete)
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_IN) {
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && retaddr) {
|
||||
cpu_restore_state(uc->cpu, retaddr, false);
|
||||
synced = true;
|
||||
}
|
||||
uint32_t ret;
|
||||
JIT_CALLBACK_GUARD_VAR(ret, ((uc_cb_insn_in_t)hook->callback)(uc, addr, 4, hook->user_data));
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user