https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9c4397afdfa7947694c2eaa48ce0291386f24a08

commit 9c4397afdfa7947694c2eaa48ce0291386f24a08
Author:     Julio Carchi <[email protected]>
AuthorDate: Fri Nov 19 18:45:35 2021 -0500
Commit:     GitHub <[email protected]>
CommitDate: Sat Nov 20 00:45:35 2021 +0100

    [USER32] GetQueueStatus() should not return 0 when passing QS_ALLINPUT flag 
that includes QS_RAWINPUT (#4115)
    
    GTK applications call GetQueueStatus(QS_ALLINPUT), where QS_ALLINPUT
    specifies the QS_RAWINPUT flag as well, when these are compiled for
    Windows XP+, and they expect the call to succeed on this platform.
    
    On one side, ReactOS does not currently support this flag at all, but
    since it claims to be XP/2003-compatible, applications may implicitly
    expect the flag to be supported by GetQueueStatus() and the function
    *NOT* failing when this flag is set.
    (Later GTK apps don't care and just call GetQueueStatus(QS_ALLINPUT)
    that includes QS_RAWINPUT, and therefore would fail as well on e.g.
    Windows 2000...)
    
    Otherwise, an observable effect is that some versions of 
libgdk-win32-2.0.0.dll
    enter into an infinite loop when calling GetQueueStatus(QS_ALLINPUT),
    since this call always failed on ReactOS.
    
    On the other side, however, we should honour our winetests that handle
    the presence of the QS_RAWINPUT flag and behave differently accordingly.
    But since we do not support QS_RAWINPUT yet, we should keep their old
    behaviour where QS_RAWINPUT is unused.
    
    Thus, in order to accomodate both sides, we don't fail the GetQueueStatus()
    call, but just set the ERROR_INVALID_FLAGS last error and continue it.
    
    
    This fixes CORE-15686, CORE-17551 and probably CORE-11850.
    Fixes also all user32:TrackMouseEvent tests.
    
    Co-authored-by: Hermès BÉLUSCA - MAÏTO <[email protected]>
---
 win32ss/user/user32/windows/message.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/win32ss/user/user32/windows/message.c 
b/win32ss/user/user32/windows/message.c
index 607ae7dda9b..1c745cb4584 100644
--- a/win32ss/user/user32/windows/message.c
+++ b/win32ss/user/user32/windows/message.c
@@ -2899,12 +2899,21 @@ DWORD
 WINAPI
 RealGetQueueStatus(UINT flags)
 {
-   #define QS_TEMPALLINPUT 255 // ATM, do not support QS_RAWINPUT
-   if (flags & ~(QS_SMRESULT|QS_ALLPOSTMESSAGE|QS_TEMPALLINPUT))
+   if (flags & ~(QS_ALLINPUT|QS_ALLPOSTMESSAGE|QS_SMRESULT))
    {
       SetLastError( ERROR_INVALID_FLAGS );
       return 0;
    }
+   /** ATM, we do not support QS_RAWINPUT, but we need to support apps that 
pass
+    ** this flag along, while also working around QS_RAWINPUT checks in 
winetests.
+    ** Just set the last error to ERROR_INVALID_FLAGS but do not fail the call.
+    **/
+   if (flags & QS_RAWINPUT)
+   {
+      SetLastError(ERROR_INVALID_FLAGS);
+      flags &= ~QS_RAWINPUT;
+   }
+   /**/
    return NtUserxGetQueueStatus(flags);
 }
 

Reply via email to