Adding INSN hook checks for x86 (#833)

* adding INSN hook checking for x86

* tabs to spaces

* need to return bool not uc_err

* fixed conditional after switching to bool
This commit is contained in:
bulaza
2017-05-13 13:16:17 -04:00
committed by Nguyen Anh Quynh
parent 4b50ca5cec
commit 4b9efdc986
3 changed files with 25 additions and 1 deletions

View File

@@ -171,7 +171,7 @@ static int x86_msr_read(struct uc_struct *uc, uc_x86_msr *msr)
helper_rdmsr(env);
msr->value = ((uint32_t)env->regs[R_EAX]) |
((uint64_t)((uint32_t)env->regs[R_EDX]) << 32);
((uint64_t)((uint32_t)env->regs[R_EDX]) << 32);
env->regs[R_EAX] = eax;
env->regs[R_ECX] = ecx;
@@ -1335,6 +1335,17 @@ static bool x86_stop_interrupt(int intno)
void pc_machine_init(struct uc_struct *uc);
static bool x86_insn_hook_validate(uint32_t insn_enum)
{
//for x86 we can only hook IN, OUT, and SYSCALL
if (insn_enum != UC_X86_INS_IN
&& insn_enum != UC_X86_INS_OUT
&& insn_enum != UC_X86_INS_SYSCALL) {
return false;
}
return true;
}
DEFAULT_VISIBILITY
void x86_uc_init(struct uc_struct* uc)
{
@@ -1350,6 +1361,7 @@ void x86_uc_init(struct uc_struct* uc)
uc->release = x86_release;
uc->set_pc = x86_set_pc;
uc->stop_interrupt = x86_stop_interrupt;
uc->insn_hook_validate = x86_insn_hook_validate;
uc_common_init(uc);
}