[PATCH 1/2] user32: Force bits in GetKeyState() and GetKeyboardState() to zero.

Markus Engel markus_wine at familie-engel.online
Sun May 17 07:19:03 CDT 2020


Only the highest and lowest bits in the return values of these functions
have a meaning, the others are undefined. Some programs expect these
undefined bits to be zero, though, so make sure they are not set.

This is a slightly adjusted version of the patch by Raditz12 that is
attached to the bug report.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30814
Signed-off-by: Markus Engel <markus_wine at familie-engel.online>
---
 dlls/user32/input.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index b7cdbd84ef..89ef4924ad 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -555,7 +555,9 @@ 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 = (reply->state & 0x80) << 8 | (reply->state & 0x01);
     }
     SERVER_END_REQ;
     TRACE("key (0x%x) -> %x\n", vkey, retval);
@@ -569,6 +571,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 +582,9 @@ 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;
-- 
2.26.2




More information about the wine-devel mailing list