Author: jimtabor Date: Mon Aug 4 23:05:28 2008 New Revision: 35117
URL: http://svn.reactos.org/svn/reactos?rev=35117&view=rev Log: - Patch by Yuriy Sidorov <jura at cp-lab.com> , NtUserToUnicodeEx should return zero if key in lpKeyState array is not pressed.
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Mon Aug 4 23:05:28 2008 @@ -711,25 +711,32 @@ DPRINT1( "Couldn't copy key state from caller.\n" ); RETURN(0); } - OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING); - if( !OutPwszBuff ) - { - DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff); - RETURN(0); - } - RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff ); - - ret = ToUnicodeInner( wVirtKey, - wScanCode, - KeyStateBuf, - OutPwszBuff, - cchBuff, - wFlags, - PsGetCurrentThreadWin32Thread() ? - PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables : 0 ); - - MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff); - ExFreePool(OutPwszBuff); + + /* Virtual code is correct and key is pressed currently? */ + if (wVirtKey < 0x100 && KeyStateBuf[wVirtKey] & KS_DOWN_BIT) + { + OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING); + if( !OutPwszBuff ) + { + DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff); + RETURN(0); + } + RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff ); + + ret = ToUnicodeInner( wVirtKey, + wScanCode, + KeyStateBuf, + OutPwszBuff, + cchBuff, + wFlags, + PsGetCurrentThreadWin32Thread() ? + PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables : 0 ); + + MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff); + ExFreePool(OutPwszBuff); + } + else + ret = 0;
RETURN(ret);