From 6f8dca661476336ffc015b0d78a2fad730529487 Mon Sep 17 00:00:00 2001 From: redthing1 Date: Mon, 5 Jan 2026 18:41:32 -0800 Subject: [PATCH] object syscalls: implement NtWaitForMultipleObjects32 --- src/windows-emulator/syscalls/object.cpp | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/windows-emulator/syscalls/object.cpp b/src/windows-emulator/syscalls/object.cpp index afd1a53a..da88c55c 100644 --- a/src/windows-emulator/syscalls/object.cpp +++ b/src/windows-emulator/syscalls/object.cpp @@ -304,6 +304,44 @@ namespace syscalls return STATUS_SUCCESS; } + NTSTATUS handle_NtWaitForMultipleObjects32(const syscall_context& c, const ULONG count, const emulator_object handles, + const WAIT_TYPE wait_type, const BOOLEAN alertable, + const emulator_object timeout) + { + if (wait_type != WaitAny && wait_type != WaitAll) + { + c.win_emu.log.error("Wait type not supported!\n"); + c.emu.stop(); + return STATUS_NOT_SUPPORTED; + } + + auto& t = c.win_emu.current_thread(); + t.await_objects.clear(); + t.await_any = wait_type == WaitAny; + + for (ULONG i = 0; i < count; ++i) + { + const auto raw_handle = handles.read(i); + const auto h = make_handle(static_cast(raw_handle)); + + if (!is_awaitable_object_type(h)) + { + c.win_emu.log.warn("Unsupported handle type for NtWaitForMultipleObjects32: %d!\n", h.value.type); + return STATUS_INVALID_HANDLE; + } + + t.await_objects.push_back(h); + } + + if (timeout.value() && !t.await_time.has_value()) + { + t.await_time = utils::convert_delay_interval_to_time_point(c.win_emu.clock(), timeout.read()); + } + + c.win_emu.yield_thread(alertable); + return STATUS_SUCCESS; + } + NTSTATUS handle_NtWaitForSingleObject(const syscall_context& c, const handle h, const BOOLEAN alertable, const emulator_object timeout) {