Global (Windows): prefers NtWaitForSingleObject

This commit is contained in:
李通洲
2026-03-14 23:08:25 +08:00
parent f46e97fc62
commit 81984e6e97
4 changed files with 5 additions and 6 deletions
+2 -2
View File
@@ -455,10 +455,10 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
while (true)
{
if (WaitForSingleObjectEx(hInput, FF_IO_TERM_RESP_WAIT_MS, TRUE) != WAIT_OBJECT_0)
if (NtWaitForSingleObject(hInput, TRUE, &(LARGE_INTEGER) { .QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000 }) != STATUS_WAIT_0)
{
SetConsoleMode(hInput, inputMode);
return "WaitForSingleObject() failed or timeout";
return "NtWaitForSingleObject() failed or timeout";
}
// Ignore all unexpected input events
+1 -1
View File
@@ -179,7 +179,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer)
default:
CancelIo(hChildPipeRead);
TerminateProcess(hProcess, 1);
return "WaitForSingleObject(hReadEvent) failed";
return "NtWaitForSingleObject(hReadEvent) failed";
}
}
+1 -1
View File
@@ -21,7 +21,7 @@
static inline void ffThreadDetach(FFThreadType thread) { NtClose(thread); }
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout)
{
if (WaitForSingleObject(thread, timeout == 0 ? (DWORD) -1 : timeout) != 0 /*WAIT_OBJECT_0*/)
if (NtWaitForSingleObject(thread, TRUE, timeout == 0 ? NULL : &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 }) != STATUS_WAIT_0)
{
TerminateThread(thread, (DWORD) -1);
NtClose(thread);
+1 -2
View File
@@ -3,7 +3,6 @@
#include "common/mallocHelper.h"
#include "common/windows/unicode.h"
#include <winternl.h>
#include <windows.h>
#include <hidsdi.h>
@@ -159,7 +158,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
OVERLAPPED overlapped = { };
DWORD nBytes;
if (ReadFile(hHidFile, reportBuffer, caps.InputReportByteLength, &nBytes, &overlapped) ||
(WaitForSingleObject(hHidFile, FF_IO_TERM_RESP_WAIT_MS) == WAIT_OBJECT_0 && GetOverlappedResult(hHidFile, &overlapped, &nBytes, FALSE)))
GetOverlappedResultEx(hHidFile, &overlapped, &nBytes, FF_IO_TERM_RESP_WAIT_MS, TRUE))
{
if (rdi.hid.dwVendorId == 0x054C)
{