98 *ppIndicatorTrans = pRet;
182 WARN(
"NtDeviceIoControlFile() failed, ignored\n");
206 ERR(
"NtDeviceIoControlFile() failed, ignored\n");
208 TRACE(
"Keyboard type %u, subtype %u and number of func keys %u\n",
310 TRACE(
"Current Mod Bits: %lx\n", dwModBits);
330 PVK_TO_WCHARS10 pVkToVch;
331 DWORD i, dwModBits, dwVkModBits, dwModNumber = 0;
336 dwModBits = pKeyState ?
IntGetModBits(pKbdTbl, pKeyState) : 0;
340 TRACE(
"TryToTranslate: %04x %x\n", wVirtKey, dwModBits);
344 dwModBits &= ~KBDALT;
355 pVkToVch = (PVK_TO_WCHARS10)(pVkToVchTbl->
pVkToWchars);
356 while (pVkToVch->VirtualKey)
358 if (wVirtKey == (pVkToVch->VirtualKey & 0xFF))
360 dwVkModBits = dwModBits;
363 if ((pVkToVch->Attributes & wCaplokAttr) &&
383 wch = pVkToVch->wch[dwModNumber];
389 *pwcTranslatedChar = wch;
391 TRACE(
"%lu %04x: dwModNumber %08x Char %04x\n",
392 i, wVirtKey, dwModNumber, wch);
397 pVkToVch = (PVK_TO_WCHARS10)(((
BYTE *)pVkToVch) + pVkToVchTbl->
cbSize);
398 if (pVkToVch->VirtualKey != 0xFF)
400 WARN(
"Found dead key with no trailer in the table.\n");
401 WARN(
"VK: %04x, ADDR: %p\n", wVirtKey, pVkToVch);
404 *pwcTranslatedChar = pVkToVch->wch[dwModNumber];
408 pVkToVch = (PVK_TO_WCHARS10)(((
BYTE *)pVkToVch) + pVkToVchTbl->
cbSize);
414 if (wVirtKey >=
'A' && wVirtKey <=
'Z' &&
418 *pwcTranslatedChar = (wVirtKey -
'A') + 1;
442 WCHAR wchTranslatedChar;
443 BOOL bDead, bLigature;
444 static WCHAR wchDead = 0;
461 WARN(
"Not handling ligature (yet)\n" );
469 WCHAR wchFirst, wchSecond;
470 TRACE(
"Previous dead char: %lc (%x)\n", wchDead, wchDead);
478 if (wchFirst == wchDead && wchSecond == wchTranslatedChar)
490 if (wchDead == 0x8000)
492 ERR(
"GCC is inventing bits, ignoring fake dead key\n");
498 TRACE(
"Final char: %lc (%x)\n", wchTranslatedChar, wchTranslatedChar);
506 pwszBuff[iRet++] = wchDead;
512 pwszBuff[iRet++] = wchTranslatedChar;
515 wchDead = bDead ? wchTranslatedChar : 0;
517 return bDead ? -iRet : iRet;
571 if ((wScanCode & 0xFF00) == 0xE000)
581 else if ((wScanCode & 0xFF00) == 0xE100)
591 else if (wScanCode < pKbdTbl->bMaxVSCtoVK)
597 return wVk != 0xFF ? wVk : 0;
610 BOOL bDead, bLigature;
638 TRACE(
"Enter NtUserGetAsyncKeyState\n");
640 if (
Key >= 0x100 ||
Key < 0)
643 ERR(
"Invalid parameter Key\n");
657 TRACE(
"Leave NtUserGetAsyncKeyState, ret=%u\n", wRet);
696 KbdHookData.
flags = 0;
742 ERR(
"Invalid window\n");
749 ERR(
"UserGetDCEx failed!\n");
759 ERR(
"NtGdiCreateCompatibleBitmap failed!\n");
766 ERR(
"NtGdiCreateCompatibleDC failed!\n");
771 NtGdiBitBlt(
hdcMem, 0, 0,
cx,
cy,
hdc, 0, 0,
SRCCOPY, 0, 0);
808 pKL = (bNext ? pKL->pklNext : pKL->pklPrev);
812 }
while (pKL != pFirstKL);
824 PWND pWnd = pFocusQueue->spwndFocus;
831 pWnd = pFocusQueue->spwndActive;
835 pti = pWnd->
head.pti;
838 if (nKeyState == INPUTLANGCHANGE_FORWARD)
840 else if (nKeyState == INPUTLANGCHANGE_BACKWARD)
844 wParam |= INPUTLANGCHANGE_SYSCHARSET;
861 *pKeyState = INPUTLANGCHANGE_FORWARD;
863 *pKeyState = INPUTLANGCHANGE_BACKWARD;
865 *pKeyState = INPUTLANGCHANGE_FORWARD;
867 *pKeyState = INPUTLANGCHANGE_BACKWARD;
890 WORD wSimpleVk = 0, wFixedVk, wVk2;
934 ERR(
"Kbd msg dropped by WH_KEYBOARD_LL hook\n");
941 TRACE(
"HotKey Processed\n");
945 wFixedVk =
IntFixVk(wSimpleVk, bExt);
951 TRACE(
"ProcessKeyEvent Q 0x%p Active pWnd 0x%p Focus pWnd 0x%p\n",
958 (wSimpleVk ==
VK_MENU && bMenuDownRecently) ||
964 bMenuDownRecently =
FALSE;
971 bMenuDownRecently =
TRUE;
990 if (bIsSimpleDown && !bWasSimpleDown &&
995 TRACE(
"Alt-Tab/Esc Pressed wParam %x\n",wVk);
1045 else if (pFocusQueue && bPostMsg)
1056 if (Wnd) pti = Wnd->
head.pti;
1060 Msg.wParam = wFixedVk & 0xFF;
1072 ERR(
"Set last input\n");
1102 TRACE(
"Posting keyboard msg %u wParam 0x%x lParam 0x%x\n",
Msg.message,
Msg.wParam,
Msg.lParam);
1103 if (!Wnd) {
ERR(
"Window is NULL\n");}
1112 WORD wScanCode, wVk;
1133 ERR(
"No keyboard layout!\n");
1140 wScanCode = pKbdInput->
wScan;
1142 if (pKbdInput->
dwFlags & KEYEVENTF_UNICODE)
1151 if (pKbdInput->
dwFlags & KEYEVENTF_SCANCODE)
1154 wVk =
IntVscToVk(wScanCode | (bExt ? 0xE000 : 0), pKbdTbl);
1160 wVk = pKbdInput->
wVk;
1168 if (pKbdInput->
time)
1194 WORD wScanCode, wVk;
1200 wScanCode = pKbdInputData->
MakeCode & 0x7F;
1202 wScanCode |= 0xE000;
1204 wScanCode |= 0xE100;
1225 TRACE(
"UserProcessKeyboardInput: %x (break: %u) -> %x\n",
1239 KbdInput.
wVk = wVk & 0xFF;
1240 KbdInput.
wScan = wScanCode & 0x7F;
1281 WCHAR wch[3] = { 0 };
1323 NewMsg.pt =
gpsi->ptCursor;
1324 NewMsg.hwnd = lpMsg->
hwnd;
1327 TRACE(
"Enter IntTranslateKbdMessage msg %s, vk %x\n",
1330 if (lpMsg->
wParam == VK_PACKET)
1343 sizeof(wch) /
sizeof(wch[0]),
1357 NewMsg.lParam = lpMsg->
lParam;
1360 for (
i = 0;
i <
cch; ++
i)
1362 TRACE(
"Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[
i], wch[
i], NewMsg.lParam);
1363 NewMsg.wParam = wch[
i];
1369 TRACE(
"Leave IntTranslateKbdMessage ret %d, cch %d, msg %x, wch %x\n",
1370 bResult,
cch, NewMsg.message, NewMsg.wParam);
1425 ERR(
"Wrong type value: %u\n",
Type);
1444 TRACE(
"Enter NtUserMapVirtualKeyEx\n");
1468 TRACE(
"Leave NtUserMapVirtualKeyEx, ret=%u\n",
ret);
1482 PBYTE pKeyStateUnsafe,
1489 BYTE afKeyState[256 * 2 / 8] = {0};
1495 TRACE(
"Enter NtUserSetKeyboardState\n");
1498 if (wScanCode &
SC_KEY_UP || wVirtKey >= 0x100)
1500 ERR(
"Invalid parameter\n");
1508 for (
i = 0;
i < 256; ++
i)
1518 ERR(
"Cannot copy key state\n");
1527 ERR(
"ExAllocatePoolWithTag(%u) failed\n",
sizeof(
WCHAR) * cchBuff);
1560 ERR(
"No keyboard layout ?!\n");
1573 TRACE(
"Leave NtUserSetKeyboardState, ret=%i\n", iRet);
1594 WCHAR KeyNameBuf[2];
1596 TRACE(
"Enter NtUserGetKeyNameText\n");
1604 if (!pKbdTbl || cchSize < 1)
1606 ERR(
"Invalid parameter\n");
1626 for (
i = 0; pKeyNames[
i].
pwsz;
i++)
1628 if (pKeyNames[
i].vsc == wScanCode)
1630 pKeyName = pKeyNames[
i].
pwsz;
1644 pKeyName = KeyNameBuf;
1650 cchKeyName =
wcslen(pKeyName);
1651 if (cchKeyName > (cchSize - 1UL))
1652 cchKeyName = cchSize - 1UL;
1674 TRACE(
"Leave NtUserGetKeyNameText, ret=%lu\n", dwRet);
1696 ERR(
"Unknown type!\n");
1716 PVK_TO_WCHARS10 pVkToWch;
1718 DWORD i, dwModBits = 0, dwModNumber = 0, Ret = (
DWORD)-1;
1720 TRACE(
"NtUserVkKeyScanEx() wch %u, KbdLayout 0x%p\n", wch, dwhkl);
1744 pVkToWch = (PVK_TO_WCHARS10)(pVkToWchTbl->
pVkToWchars);
1747 while (pVkToWch->VirtualKey)
1749 for (dwModNumber = 0; dwModNumber < pVkToWchTbl->
nModifications; dwModNumber++)
1751 if (pVkToWch->wch[dwModNumber] == wch)
1754 TRACE(
"i %lu wC %04x: dwModBits %08x dwModNumber %08x MaxModBits %08x\n",
1756 Ret = (dwModBits << 8) | (pVkToWch->VirtualKey & 0xFF);
1760 pVkToWch = (PVK_TO_WCHARS10)(((
BYTE *)pVkToWch) + pVkToWchTbl->
cbSize);
#define DBG_DEFAULT_CHANNEL(ch)
BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL)
#define NT_SUCCESS(StatCode)
#define ERROR_INVALID_PARAMETER
static void cleanup(void)
#define EngGetTickCount32()
#define ExAllocatePoolWithTag(hernya, size, tag)
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define EXCEPTION_EXECUTE_HANDLER
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UserHMGetHandle(obj)
#define MmCopyToCaller(x, y, z)
#define ExFreePoolWithTag(_P, _T)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
static DWORD DWORD void LPSTR DWORD cch
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
#define KEYBOARD_CAPS_LOCK_ON
#define IOCTL_KEYBOARD_QUERY_INDICATORS
#define IOCTL_KEYBOARD_SET_INDICATORS
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
struct _KEYBOARD_INDICATOR_TRANSLATION KEYBOARD_INDICATOR_TRANSLATION
#define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION
#define KEYBOARD_SCROLL_LOCK_ON
#define KEYBOARD_NUM_LOCK_ON
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
NTSYSAPI NTSTATUS NTAPI ZwDeviceIoControlFile(IN HANDLE DeviceHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, OUT PVOID OutputBuffer, IN ULONG OutputBufferSize)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
#define STATUS_INVALID_HANDLE
#define STATUS_NOT_SUPPORTED
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
PPROCESSINFO gppiInputProvider
VOID FASTCALL UserLeave(VOID)
VOID FASTCALL UserEnterShared(VOID)
VOID FASTCALL UserEnterExclusive(VOID)
struct _THREADINFO * PTHREADINFO
_Out_opt_ int _Out_opt_ int * cy
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
#define STATUS_BUFFER_TOO_SMALL
VSC_LPWSTR * pKeyNamesExt
PMODIFIERS pCharModifiers
PVK_TO_WCHAR_TABLE pVkToWcharTable
KEYBOARD_ID KeyboardIdentifier
USHORT NumberOfFunctionKeys
INDICATOR_LIST IndicatorList[1]
USHORT NumberOfIndicatorKeys
struct _CLIENTINFO * pClientInfo
struct tagKL * KeyboardLayout
struct _USER_MESSAGE_QUEUE * MessageQueue
PVK_TO_WCHARS1 pVkToWchars
struct _KBDTABLES * pKbdTbl
TW_UINT32 TW_UINT16 TW_UINT16 MSG
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INSUFFICIENT_RESOURCES
PWND FASTCALL UserGetWindowObject(HWND hWnd)
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
BOOL NTAPI UserEmptyClipboard(VOID)
BOOL NTAPI UserCloseClipboard(VOID)
BOOL NTAPI UserOpenClipboard(HWND hWnd)
HANDLE NTAPI UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
HWND FASTCALL IntGetDesktopWindow(VOID)
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
static KEYBOARD_INDICATOR_PARAMETERS gIndicators
KEYBOARD_ATTRIBUTES gKeyboardInfo
static DWORD IntGetModBits(PKBDTABLES pKbdTbl, PBYTE pKeyState)
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
static NTSTATUS APIENTRY IntKeyboardUpdateLeds(HANDLE hKeyboardDevice, WORD wVk, WORD wScanCode)
VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKbdInputData)
DWORD APIENTRY NtUserVkKeyScanEx(WCHAR wch, HKL dwhkl, BOOL bUsehKL)
INT gLayoutToggleKeyState
int APIENTRY NtUserToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyStateUnsafe, LPWSTR pwszBuffUnsafe, INT cchBuff, UINT wFlags, HKL dwhkl)
BYTE gafAsyncKeyState[256 *2/8]
BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
static WORD IntFixVk(WORD wVk, BOOL bExt)
static VOID SnapWindow(HWND hWnd)
static BOOL IntTranslateChar(WORD wVirtKey, PBYTE pKeyState, PBOOL pbDead, PBOOL pbLigature, PWCHAR pwcTranslatedChar, PKBDTABLES pKbdTbl)
DWORD gdwLanguageToggleKey
static int APIENTRY IntToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
static WCHAR FASTCALL IntVkToChar(WORD wVk, PKBDTABLES pKbdTbl)
static BOOL IntCheckLanguageToggle(_In_ PUSER_MESSAGE_QUEUE pFocusQueue, _In_ BOOL bIsDown, _In_ WORD wVk, _Inout_ PINT pKeyState)
DWORD APIENTRY NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize)
static LRESULT co_CallLowLevelKeyboardHook(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
static PKL FASTCALL IntGetNextKL(_In_ PKL pKL, _In_ BOOL bNext, _In_ BOOL bSameLang)
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans
static UINT IntMapVirtualKeyEx(UINT uCode, UINT Type, PKBDTABLES pKbdTbl)
VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice)
NTSTATUS APIENTRY IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice, PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
static BYTE gafAsyncKeyStateRecentDown[256/8]
DWORD FASTCALL UserGetKeyboardType(DWORD dwTypeFlag)
static VOID NTAPI UpdateAsyncKeyState(WORD wVk, BOOL bIsDown)
SHORT APIENTRY NtUserGetAsyncKeyState(INT Key)
INT gLanguageToggleKeyState
NTSTATUS NTAPI InitKeyboardImpl(VOID)
BOOL NTAPI ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
static WORD FASTCALL IntVkToVsc(WORD wVk, PKBDTABLES pKbdTbl)
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
static VOID IntLanguageToggle(_In_ PUSER_MESSAGE_QUEUE pFocusQueue, _In_ BOOL bSameLang, _In_ INT nKeyState)
static WORD IntSimplifyVk(WORD wVk)
static WORD IntTranslateNumpadKey(WORD wVk)
UINT APIENTRY NtUserMapVirtualKeyEx(UINT uCode, UINT uType, DWORD keyboardId, HKL dwhkl)
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
_In_ DWORD _Out_ _In_ WORD wFlags
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
#define MAPVK_VSC_TO_VK_EX
#define KEYEVENTF_EXTENDEDKEY
#define MAPVK_VK_TO_VSC_EX