Jacek Caban : win32u: Move normalize_std_handle call to NtUserMsgWaitForMultipleObjectsEx.

Alexandre Julliard julliard at winehq.org
Tue May 3 15:39:24 CDT 2022


Module: wine
Branch: master
Commit: 365bc308bed3391fe3cc9c6ac8fc34c7a484d9d3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=365bc308bed3391fe3cc9c6ac8fc34c7a484d9d3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May  3 12:43:13 2022 +0200

win32u: Move normalize_std_handle call to NtUserMsgWaitForMultipleObjectsEx.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/win32u/driver.c  | 22 +---------------------
 dlls/win32u/message.c | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c
index 175fde1fa40..ebc512bb4ee 100644
--- a/dlls/win32u/driver.c
+++ b/dlls/win32u/driver.c
@@ -792,35 +792,15 @@ static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout
     return time;
 }
 
-static HANDLE normalize_std_handle( HANDLE handle )
-{
-    if (handle == (HANDLE)STD_INPUT_HANDLE)
-        return NtCurrentTeb()->Peb->ProcessParameters->hStdInput;
-    if (handle == (HANDLE)STD_OUTPUT_HANDLE)
-        return NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;
-    if (handle == (HANDLE)STD_ERROR_HANDLE)
-        return NtCurrentTeb()->Peb->ProcessParameters->hStdError;
-
-    return handle;
-}
-
 static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
                                                   DWORD mask, DWORD flags )
 {
     NTSTATUS status;
-    HANDLE hloc[MAXIMUM_WAIT_OBJECTS];
     LARGE_INTEGER time;
-    unsigned int i;
 
     if (!count && !timeout) return WAIT_TIMEOUT;
-    if (count > MAXIMUM_WAIT_OBJECTS)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return WAIT_FAILED;
-    }
-    for (i = 0; i < count; i++) hloc[i] = normalize_std_handle( handles[i] );
 
-    status = NtWaitForMultipleObjects( count, hloc, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE),
+    status = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE),
                                        get_nt_timeout( &time, timeout ) );
     if (HIWORD(status))  /* is it an error code? */
     {
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c
index d43dca723d2..67990e7b1f4 100644
--- a/dlls/win32u/message.c
+++ b/dlls/win32u/message.c
@@ -1963,6 +1963,18 @@ static DWORD wait_objects( DWORD count, const HANDLE *handles, DWORD timeout,
     return ret;
 }
 
+static HANDLE normalize_std_handle( HANDLE handle )
+{
+    if (handle == (HANDLE)STD_INPUT_HANDLE)
+        return NtCurrentTeb()->Peb->ProcessParameters->hStdInput;
+    if (handle == (HANDLE)STD_OUTPUT_HANDLE)
+        return NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;
+    if (handle == (HANDLE)STD_ERROR_HANDLE)
+        return NtCurrentTeb()->Peb->ProcessParameters->hStdError;
+
+    return handle;
+}
+
 /***********************************************************************
  *           NtUserMsgWaitForMultipleObjectsEx   (win32u.@)
  */
@@ -1979,7 +1991,7 @@ DWORD WINAPI NtUserMsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handl
     }
 
     /* add the queue to the handle list */
-    for (i = 0; i < count; i++) wait_handles[i] = handles[i];
+    for (i = 0; i < count; i++) wait_handles[i] = normalize_std_handle( handles[i] );
     wait_handles[count] = get_server_queue_handle();
 
     return wait_objects( count+1, wait_handles, timeout,




More information about the wine-cvs mailing list