Skip to content

Commit

Permalink
Make rdtsc predictable
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Oct 27, 2024
1 parent 2f92b7c commit 8ecf47a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/windows-emulator/windows_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8ecf47a

Please sign in to comment.