From: Marc-Aurel Zent mzent@codeweavers.com
--- dlls/kernelbase/kernelbase.h | 10 ++++++++++ dlls/kernelbase/sync.c | 10 ++-------- 2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/dlls/kernelbase/kernelbase.h b/dlls/kernelbase/kernelbase.h index 2209939a8a2..dad8b3e7d2c 100644 --- a/dlls/kernelbase/kernelbase.h +++ b/dlls/kernelbase/kernelbase.h @@ -50,6 +50,16 @@ static inline BOOL set_ntstatus( NTSTATUS status ) return !status; }
+static inline DWORD set_ntwaitstatus( NTSTATUS status ) +{ + if (NT_ERROR(status)) + { + SetLastError( RtlNtStatusToDosError( status )); + return WAIT_FAILED; + } + return (DWORD)status; +} + /* make the kernel32 names available */ #define HeapAlloc(heap, flags, size) RtlAllocateHeap(heap, flags, size) #define HeapReAlloc(heap, flags, ptr, size) RtlReAllocateHeap(heap, flags, ptr, size) diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c index 40aec41e5c8..c4153be25d1 100644 --- a/dlls/kernelbase/sync.c +++ b/dlls/kernelbase/sync.c @@ -436,14 +436,8 @@ DWORD WINAPI DECLSPEC_HOTPATCH WaitForMultipleObjectsEx( DWORD count, const HAND } for (i = 0; i < count; i++) hloc[i] = normalize_std_handle( handles[i] );
- status = NtWaitForMultipleObjects( count, hloc, wait_all ? WaitAll : WaitAny, alertable, - get_nt_timeout( &time, timeout ) ); - if (HIWORD(status)) /* is it an error code? */ - { - SetLastError( RtlNtStatusToDosError(status) ); - status = WAIT_FAILED; - } - return status; + return set_ntwaitstatus( NtWaitForMultipleObjects( count, hloc, wait_all ? WaitAll : WaitAny, alertable, + get_nt_timeout( &time, timeout ) ) ); }