From 5160bacd1e84269b4c164010bb69709603746f74 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 24 Jan 2025 11:58:35 +0100 Subject: [PATCH] Correctly handle existing objects --- src/windows-emulator/syscalls.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index 69448eff..c4c5d4e5 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -477,10 +477,12 @@ namespace if (!name.empty()) { - for (const auto& mutant : c.proc.mutants | std::views::values) + for (auto& entry : c.proc.mutants) { - if (mutant.name == name) + if (entry.second.name == name) { + ++entry.second.ref_count; + mutant_handle.write(c.proc.mutants.make_handle(entry.first)); return STATUS_OBJECT_NAME_EXISTS; } } @@ -518,10 +520,12 @@ namespace if (!name.empty()) { - for (const auto& event : c.proc.events | std::views::values) + for (auto& entry : c.proc.events) { - if (event.name == name) + if (entry.second.name == name) { + ++entry.second.ref_count; + event_handle.write(c.proc.events.make_handle(entry.first)); return STATUS_OBJECT_NAME_EXISTS; } } @@ -3037,10 +3041,12 @@ namespace if (!s.name.empty()) { - for (const auto& semaphore : c.proc.semaphores | std::views::values) + for (auto& entry : c.proc.semaphores) { - if (semaphore.name == s.name) + if (entry.second.name == s.name) { + ++entry.second.ref_count; + semaphore_handle.write(c.proc.semaphores.make_handle(entry.first)); return STATUS_OBJECT_NAME_EXISTS; } }