From 257d9f6d02b5855354a2d81b7b6e65515d4f93a5 Mon Sep 17 00:00:00 2001 From: Red Date: Fri, 22 Aug 2025 00:32:05 +0200 Subject: [PATCH] Fix exception when NtTerminateThread is called on the active thread. --- src/windows-emulator/windows_emulator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 091e7ddd..7352e915 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -52,6 +52,7 @@ namespace void perform_context_switch_work(windows_emulator& win_emu) { auto& threads = win_emu.process.threads; + auto*& active = win_emu.process.active_thread; for (auto it = threads.begin(); it != threads.end();) { @@ -61,6 +62,11 @@ namespace continue; } + if (active == &it->second) + { + active = nullptr; + } + const auto [new_it, deleted] = threads.erase(it); if (!deleted) {