From 85180a51f07946872308ee3e4d18d9daaaed983b Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Tue, 4 Feb 2025 20:43:43 +0100 Subject: [PATCH] Prevent destroying active thread --- src/windows-emulator/syscalls.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index e97e51fb..7df12fd7 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -430,6 +430,16 @@ namespace return STATUS_SUCCESS; } + if (h.value.type == handle_types::thread) + { + const auto t = c.proc.threads.get(h); + if (t == c.proc.active_thread && t->ref_count == 1) + { + // TODO: Better handle ref counting + return STATUS_SUCCESS; + } + } + auto* handle_store = get_handle_store(c.proc, h); if (handle_store && handle_store->erase(h)) {