[PATCH 1/2] win32u: Do not enumerate the "Keyboard Layouts" key in NtUserGetKeyboardLayoutList().

Zebediah Figura zfigura at codeweavers.com
Tue Apr 12 20:33:04 CDT 2022


From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>

This function returns only those keyboards currently configured by the user,
whereas the "Keyboard Layouts" key contains all keyboards that can be
configured.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/win32u/input.c | 44 +++-----------------------------------------
 1 file changed, 3 insertions(+), 41 deletions(-)

diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
index addff0e5fb3..70b4d7e4fb5 100644
--- a/dlls/win32u/input.c
+++ b/dlls/win32u/input.c
@@ -929,54 +929,16 @@ HKL WINAPI NtUserActivateKeyboardLayout( HKL layout, UINT flags )
  */
 UINT WINAPI NtUserGetKeyboardLayoutList( INT size, HKL *layouts )
 {
-    char buffer[4096];
-    KEY_NODE_INFORMATION *key_info = (KEY_NODE_INFORMATION *)buffer;
-    KEY_VALUE_PARTIAL_INFORMATION *value_info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
-    DWORD count, tmp, i = 0;
-    HKEY hkey, subkey;
-    HKL layout;
+    DWORD count;
 
     TRACE_(keyboard)( "size %d, layouts %p.\n", size, layouts );
 
     if ((count = user_driver->pGetKeyboardLayoutList( size, layouts )) != ~0) return count;
 
-    layout = get_locale_kbd_layout();
-    count = 0;
-
-    count++;
     if (size && layouts)
-    {
-        layouts[count - 1] = layout;
-        if (count == size) return count;
-    }
+        layouts[0] = get_locale_kbd_layout();
 
-    if ((hkey = reg_open_key( NULL, keyboard_layouts_keyW, sizeof(keyboard_layouts_keyW) )))
-    {
-        while (!NtEnumerateKey( hkey, i++, KeyNodeInformation, key_info,
-                                sizeof(buffer) - sizeof(WCHAR), &tmp ))
-        {
-            if (!(subkey = reg_open_key( hkey, key_info->Name, key_info->NameLength ))) continue;
-            key_info->Name[key_info->NameLength / sizeof(WCHAR)] = 0;
-            tmp = wcstoul( key_info->Name, NULL, 16 );
-            if (query_reg_ascii_value( subkey, "Layout Id", value_info, sizeof(buffer) ) &&
-                value_info->Type == REG_SZ)
-                tmp = MAKELONG( LOWORD( tmp ),
-                                0xf000 | (wcstoul( (const WCHAR *)value_info->Data, NULL, 16 ) & 0xfff) );
-            NtClose( subkey );
-
-            if (layout == UlongToHandle( tmp )) continue;
-
-            count++;
-            if (size && layouts)
-            {
-                layouts[count - 1] = UlongToHandle( tmp );
-                if (count == size) break;
-            }
-        }
-        NtClose( hkey );
-    }
-
-    return count;
+    return 1;
 }
 
 /****************************************************************************
-- 
2.34.1




More information about the wine-devel mailing list