more PC sync for HOOK_INSN
This commit is contained in:
@@ -974,6 +974,7 @@ void helper_syscall(CPUX86State *env, int next_eip_addend)
|
||||
// Unicorn: call registered syscall hooks
|
||||
struct hook *hook;
|
||||
uc_engine *uc = env->uc;
|
||||
bool synced = false;
|
||||
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(env->uc, hook, UC_HOOK_INSN) {
|
||||
@@ -982,6 +983,11 @@ void helper_syscall(CPUX86State *env, int next_eip_addend)
|
||||
if (!HOOK_BOUND_CHECK(hook, env->eip))
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_SYSCALL) {
|
||||
uintptr_t pc = GETPC();
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && pc) {
|
||||
cpu_restore_state(uc->cpu, pc, false);
|
||||
synced = true;
|
||||
}
|
||||
JIT_CALLBACK_GUARD(((uc_cb_insn_syscall_t)hook->callback)(env->uc, hook->user_data));
|
||||
}
|
||||
|
||||
@@ -2352,6 +2358,7 @@ void helper_sysenter(CPUX86State *env, int next_eip_addend)
|
||||
// Unicorn: call registered SYSENTER hooks
|
||||
struct hook *hook;
|
||||
uc_engine *uc = env->uc;
|
||||
bool synced = false;
|
||||
|
||||
HOOK_FOREACH_VAR_DECLARE;
|
||||
HOOK_FOREACH(env->uc, hook, UC_HOOK_INSN) {
|
||||
@@ -2360,6 +2367,11 @@ void helper_sysenter(CPUX86State *env, int next_eip_addend)
|
||||
if (!HOOK_BOUND_CHECK(hook, env->eip))
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_SYSENTER) {
|
||||
uintptr_t pc = GETPC();
|
||||
if (!synced && !uc->skip_sync_pc_on_exit && pc) {
|
||||
cpu_restore_state(uc->cpu, pc, false);
|
||||
synced = true;
|
||||
}
|
||||
JIT_CALLBACK_GUARD(((uc_cb_insn_syscall_t)hook->callback)(env->uc, hook->user_data));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user