Author: jimtabor
Date: Fri May 22 05:35:48 2009
New Revision: 41040
URL:
http://svn.reactos.org/svn/reactos?rev=41040&view=rev
Log:
- Fix NtUserVkKeyScanEx to support current thread keyboard layout or use the one provided
by handle. See bug report 4269 and the related bug report 4272.
Modified:
trunk/reactos/dll/win32/user32/windows/input.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
Modified: trunk/reactos/dll/win32/user32/windows/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/i…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] Fri May 22 05:35:48 2009
@@ -492,7 +492,7 @@
VkKeyScanExW(WCHAR ch,
HKL dwhkl)
{
- return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, 0);
+ return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, TRUE);
}
@@ -502,7 +502,7 @@
SHORT WINAPI
VkKeyScanW(WCHAR ch)
{
- return VkKeyScanExW(ch, GetKeyboardLayout(0));
+ return (SHORT) NtUserVkKeyScanEx(ch, 0, FALSE);
}
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Fri May 22 05:35:48 2009
@@ -2697,7 +2697,7 @@
NtUserVkKeyScanEx(
WCHAR wChar,
HKL KeyboardLayout,
- DWORD Unknown2);
+ BOOL bUsehHK);
DWORD
NTAPI
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Fri May 22
05:35:48 2009
@@ -1000,22 +1000,31 @@
APIENTRY
NtUserVkKeyScanEx(
WCHAR wChar,
- HKL KeyboardLayout,
- DWORD Unknown2)
-{
-/* FIXME: currently, this routine doesnt seem to need any locking */
+ HKL hKeyboardLayout,
+ BOOL UsehKL ) // TRUE from KeyboardLayout, FALSE from pkbl =
(THREADINFO)->KeyboardLayout
+{
PKBDTABLES KeyLayout;
PVK_TO_WCHAR_TABLE vtwTbl;
PVK_TO_WCHARS10 vkPtr;
size_t size_this_entry;
int nMod;
- DWORD CapsMod = 0, CapsState = 0;
-
- DPRINT("NtUserVkKeyScanEx() wChar %d, KbdLayout 0x%p\n", wChar,
KeyboardLayout);
-
- if(!KeyboardLayout)
- return -1;
- KeyLayout = UserHklToKbl(KeyboardLayout)->KBTables;
+ PKBL pkbl = NULL;
+ DWORD CapsMod = 0, CapsState = 0, Ret = -1;
+
+ DPRINT("NtUserVkKeyScanEx() wChar %d, KbdLayout 0x%p\n", wChar,
hKeyboardLayout);
+ UserEnterShared();
+
+ if (UsehKL)
+ {
+ if ( !hKeyboardLayout || !(pkbl = UserHklToKbl(hKeyboardLayout)))
+ goto Exit;
+ }
+ else // From VkKeyScanAW it is FALSE so KeyboardLayout is white noise.
+ {
+ pkbl = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->KeyboardLayout;
+ }
+
+ KeyLayout = pkbl->KBTables;
for (nMod = 0; KeyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
{
@@ -1038,13 +1047,16 @@
CapsMod = KeyLayout->pCharModifiers->ModNumber[CapsState];
DPRINT("nMod %d wC %04x: CapsMod %08x CapsState %08x MaxModBits
%08x\n",
nMod, wChar, CapsMod, CapsState,
KeyLayout->pCharModifiers->wMaxModBits);
- return ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
+ Ret = ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
+ goto Exit;
}
}
vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
}
}
- return -1;
+Exit:
+ UserLeave();
+ return Ret;
}