From cff2feee7565267ce9f0db831e86bd561d3630ed Mon Sep 17 00:00:00 2001 From: Soham Nandy Date: Fri, 2 May 2025 07:20:36 +0530 Subject: [PATCH] Add rdtscp instruction with stub `IA32_TSC_AUX` values --- src/windows-emulator/windows_emulator.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 483d5268..8b4b3181 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -498,6 +498,18 @@ void windows_emulator::setup_hooks() return instruction_hook_continuation::skip_instruction; }); + this->emu().hook_instruction(x86_hookable_instructions::rdtscp, [&] { + const auto ticks = this->clock_->timestamp_counter(); + this->emu().reg(x86_register::rax, ticks & 0xFFFFFFFF); + this->emu().reg(x86_register::rdx, (ticks >> 32) & 0xFFFFFFFF); + + // Return the IA32_TSC_AUX value in RCX (low 32 bits) + auto tsc_aux = 0; // Need to replace this with proper CPUID later + this->emu().reg(x86_register::rcx, tsc_aux); + + return instruction_hook_continuation::skip_instruction; + }); + this->emu().hook_instruction(x86_hookable_instructions::rdtsc, [&] { const auto ticks = this->clock_->timestamp_counter(); this->emu().reg(x86_register::rax, ticks & 0xFFFFFFFF);