Make rdtsc predictable

This commit is contained in:
momo5502
2024-10-27 09:46:21 +01:00
parent 2f92b7c641
commit 8ecf47a1e4

View File

@@ -796,6 +796,14 @@ void windows_emulator::setup_hooks()
return instruction_hook_continuation::skip_instruction;
});
this->emu().hook_instruction(x64_hookable_instructions::rdtsc, [&]
{
const auto instructions = this->process().executed_instructions;
this->emu().reg(x64_register::rax, instructions & 0xFFFFFFFF);
this->emu().reg(x64_register::rdx, (instructions >> 32) & 0xFFFFFFFF);
return instruction_hook_continuation::skip_instruction;
});
this->emu().hook_instruction(x64_hookable_instructions::invalid, [&]
{
const auto ip = this->emu().read_instruction_pointer();