From 8ecf47a1e407e3fd5e0423948bdeeb46aad3ff0a Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 27 Oct 2024 09:46:21 +0100 Subject: [PATCH] Make rdtsc predictable --- src/windows-emulator/windows_emulator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 4c52eb3..bd30130 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -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();