Only execute exceptions in single-instruction steps, to work around buggy instruction implementation: TODO: Replace EmuX86 with something better entirely

This commit is contained in:
Luke Usher 2018-11-16 08:12:05 +00:00
parent 53732ffb2f
commit c6e7360157
1 changed files with 9 additions and 6 deletions

View File

@ -2942,8 +2942,11 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
}
// Execute op-codes until we hit an unhandled instruction, or an error occurs
while (true)
//for (int x=0;x<3;x++)
//while (true)
// TODO: Find where the weird memory addresses come from when using the above case
// There is obviously something wrong with one or more of our instruction implementations
// For now, we only execute one instruction at a time...
for (int x=0;x<1;x++)
{
if (!EmuX86_DecodeOpcode((uint8_t*)e->ContextRecord->Eip, info)) {
EmuLog(LOG_LEVEL::WARNING, "Error decoding opcode at 0x%08X", e->ContextRecord->Eip);
@ -3294,10 +3297,10 @@ bool EmuX86_DecodeException(LPEXCEPTION_POINTERS e)
if (EmuX86_Opcode_XOR(e, info)) break;
goto opcode_error;
default:
EmuLog(LOG_LEVEL::WARNING, "Unhandled instruction : %s (%u)", Distorm_OpcodeString(info.opcode), info.opcode);
// Fail if the first hit instruction couldn't be emulated,
// but let host CPU execute following (unhandled) instructions :
return (StartingEip != e->ContextRecord->Eip);
EmuLog(LOG_LEVEL::WARNING, "Unhandled instruction : %s (%u)", Distorm_OpcodeString(info.opcode), info.opcode);
// HACK: If we hit an unhandled instruction, log and skip it
e->ContextRecord->Eip += info.size;
return true;
} // switch info.opcode
e->ContextRecord->Eip += info.size;