Skip to content

Commit 81984e6

Browse files
committed
Global (Windows): prefers NtWaitForSingleObject
1 parent f46e97f commit 81984e6

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/common/impl/io_windows.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
455455

456456
while (true)
457457
{
458-
if (WaitForSingleObjectEx(hInput, FF_IO_TERM_RESP_WAIT_MS, TRUE) != WAIT_OBJECT_0)
458+
if (NtWaitForSingleObject(hInput, TRUE, &(LARGE_INTEGER) { .QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000 }) != STATUS_WAIT_0)
459459
{
460460
SetConsoleMode(hInput, inputMode);
461-
return "WaitForSingleObject() failed or timeout";
461+
return "NtWaitForSingleObject() failed or timeout";
462462
}
463463

464464
// Ignore all unexpected input events

src/common/impl/processing_windows.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer)
179179
default:
180180
CancelIo(hChildPipeRead);
181181
TerminateProcess(hProcess, 1);
182-
return "WaitForSingleObject(hReadEvent) failed";
182+
return "NtWaitForSingleObject(hReadEvent) failed";
183183
}
184184
}
185185

src/common/thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
static inline void ffThreadDetach(FFThreadType thread) { NtClose(thread); }
2222
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout)
2323
{
24-
if (WaitForSingleObject(thread, timeout == 0 ? (DWORD) -1 : timeout) != 0 /*WAIT_OBJECT_0*/)
24+
if (NtWaitForSingleObject(thread, TRUE, timeout == 0 ? NULL : &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 }) != STATUS_WAIT_0)
2525
{
2626
TerminateThread(thread, (DWORD) -1);
2727
NtClose(thread);

src/detection/gamepad/gamepad_windows.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "common/mallocHelper.h"
44
#include "common/windows/unicode.h"
55

6-
#include <winternl.h>
76
#include <windows.h>
87
#include <hidsdi.h>
98

@@ -159,7 +158,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */)
159158
OVERLAPPED overlapped = { };
160159
DWORD nBytes;
161160
if (ReadFile(hHidFile, reportBuffer, caps.InputReportByteLength, &nBytes, &overlapped) ||
162-
(WaitForSingleObject(hHidFile, FF_IO_TERM_RESP_WAIT_MS) == WAIT_OBJECT_0 && GetOverlappedResult(hHidFile, &overlapped, &nBytes, FALSE)))
161+
GetOverlappedResultEx(hHidFile, &overlapped, &nBytes, FF_IO_TERM_RESP_WAIT_MS, TRUE))
163162
{
164163
if (rdi.hid.dwVendorId == 0x054C)
165164
{

0 commit comments

Comments
 (0)