Markus Engel : user32: Force undefined bits in GetKeyState() and GetKeyboardState() to zero.

Alexandre Julliard julliard at winehq.org
Fri Aug 7 10:42:29 CDT 2020


Module: wine
Branch: stable
Commit: 6d695ef5e994314dc4f4e349928fde7154e701f3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6d695ef5e994314dc4f4e349928fde7154e701f3

Author: Markus Engel <markus_wine at familie-engel.online>
Date:   Mon May 18 18:35:58 2020 +0200

user32: Force undefined bits in GetKeyState() and GetKeyboardState() to zero.

Only the highest and lowest bits in the return values of these functions
have a meaning, the others are undefined. While the other bits are
always cleared in Windows, wine stores information there. Some programs
expect these undefined bits to be zero, though, so make sure they are
not set.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30814
Signed-off-by: Markus Engel <markus_wine at familie-engel.online>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit d9855df17f905da97b4bd92227427c4f899babf1)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/user32/input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 0325e2ce3d..ac90c12c60 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -555,7 +555,7 @@ SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState(INT vkey)
     {
         req->tid = GetCurrentThreadId();
         req->key = vkey;
-        if (!wine_server_call( req )) retval = (signed char)reply->state;
+        if (!wine_server_call( req )) retval = (signed char)(reply->state & 0x81);
     }
     SERVER_END_REQ;
     TRACE("key (0x%x) -> %x\n", vkey, retval);
@@ -569,6 +569,7 @@ SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState(INT vkey)
 BOOL WINAPI DECLSPEC_HOTPATCH GetKeyboardState( LPBYTE state )
 {
     BOOL ret;
+    UINT i;
 
     TRACE("(%p)\n", state);
 
@@ -579,6 +580,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetKeyboardState( LPBYTE state )
         req->key = -1;
         wine_server_set_reply( req, state, 256 );
         ret = !wine_server_call_err( req );
+        for (i = 0; i < 256; i++) state[i] &= 0x81;
     }
     SERVER_END_REQ;
     return ret;




More information about the wine-cvs mailing list