From: Kamil Hornicek Date: Sun, 5 Feb 2017 15:42:23 +0000 (+0000) Subject: [KBSWITCH] X-Git-Tag: ReactOS-0.4.4-CLT2017~374 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=73bb103c3c2d03bb5962b32c59f0f9ef4d85945f [KBSWITCH] - Don't fall through to the default label. CID 515166 [NTUSER] - Fix a copypasta. [USER32] - Fix computing of HKL for layouts with Layout id. - Don't call NtUserLoadKeyboardLayoutEx with bogus keyboard layout id. - Ideally LoadKeyboardLayout should return the default system layout on failure - to be continued. svn path=/trunk/; revision=73708 --- diff --git a/reactos/base/applications/kbswitch/kbswitch.c b/reactos/base/applications/kbswitch/kbswitch.c index 60f60021eab..d06cd5f9a21 100644 --- a/reactos/base/applications/kbswitch/kbswitch.c +++ b/reactos/base/applications/kbswitch/kbswitch.c @@ -492,6 +492,8 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) if (!ShellExecuteEx(&shInputDll)) MessageBox(hwnd, _T("Can't start input.dll"), NULL, MB_OK | MB_ICONERROR); + + return 0; } default: diff --git a/reactos/win32ss/user/ntuser/kbdlayout.c b/reactos/win32ss/user/ntuser/kbdlayout.c index bda95cc592d..e123438866d 100644 --- a/reactos/win32ss/user/ntuser/kbdlayout.c +++ b/reactos/win32ss/user/ntuser/kbdlayout.c @@ -722,7 +722,7 @@ NtUserActivateKeyboardLayout( { /* Get previous keyboard layout starting with current */ if (pti->KeyboardLayout) - pKl = pti->KeyboardLayout->pklNext; + pKl = pti->KeyboardLayout->pklPrev; } else pKl = UserHklToKbl(hKl); diff --git a/reactos/win32ss/user/user32/windows/input.c b/reactos/win32ss/user/user32/windows/input.c index 582f00aac9d..5372e0ce7d5 100644 --- a/reactos/win32ss/user/user32/windows/input.c +++ b/reactos/win32ss/user/user32/windows/input.c @@ -281,7 +281,7 @@ LoadKeyboardLayoutW(LPCWSTR pwszKLID, HKEY hKey; /* LOWORD of dwhkl is Locale Identifier */ - dwhkl = wcstol(pwszKLID, NULL, 16); + dwhkl = LOWORD(wcstoul(pwszKLID, NULL, 16)); if (Flags & KLF_SUBSTITUTE_OK) { @@ -305,7 +305,7 @@ LoadKeyboardLayoutW(LPCWSTR pwszKLID, StringCbCatW(wszRegKey, sizeof(wszRegKey), pwszKLID); /* Open layout registry key for read */ - if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegKey, 0, + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { dwSize = sizeof(wszLayoutId); @@ -324,10 +324,13 @@ LoadKeyboardLayoutW(LPCWSTR pwszKLID, RegCloseKey(hKey); } else - ERR("RegOpenKeyExW failed!\n"); + { + ERR("Could not find keyboard layout %S.\n", pwszKLID); + return NULL; + } /* If Layout Id is not given HIWORD == LOWORD (for dwhkl) */ - if (!HIWORD(dwhkl)) + if (!HIWORD(dwhkl)) dwhkl |= dwhkl << 16; ZeroMemory(&ustrKbdName, sizeof(ustrKbdName));