ReactOS 0.4.17-dev-1421-g4623072
input.c File Reference
#include <user32.h>
#include <cjkcode.h>
#include <strsafe.h>
Include dependency graph for input.c:

Go to the source code of this file.

Classes

struct  tagIMEHOTKEYENTRY
 

Macros

#define KLF_INITTIME   0x80000000
 
#define KLF_FORCE   0x200
 
#define KBDLAYOUTS_KEY   L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
 
#define KBDLAYOUT_KEY   L"System\\CurrentControlSet\\Control\\Keyboard Layout"
 
#define ATTR_MASK   0x00FF0000
 
#define LANGID_ENGLISH_US   MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
 
#define IFN_KbdLayerDescriptor   MAKEINTRESOURCEA(1)
 
#define IFN_KbdNlsLayerDescriptor   MAKEINTRESOURCEA(2)
 
#define IFN_KbdLayerRealDllFileNT4   MAKEINTRESOURCEA(3)
 
#define IFN_KbdLayerRealDllFile   MAKEINTRESOURCEA(5)
 
#define IFN_KbdLayerMultiDescriptor   MAKEINTRESOURCEA(6)
 
#define FE_JAPANESE   (1 << 0)
 
#define FE_CHINESE_TRADITIONAL   (1 << 1)
 
#define FE_CHINESE_SIMPLIFIED   (1 << 2)
 
#define FE_KOREAN   (1 << 3)
 
#define MOD_ALL_MODS   (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN)
 

Typedefs

typedef PVOID(WINAPI * PFN_KbdLayerDescriptor) (void)
 
typedef PVOID(WINAPI * PFN_KbdNlsLayerDescriptor) (void)
 
typedef BOOL(WINAPI * PFN_KbdLayerRealDllFileNT4) (PWSTR)
 
typedef BOOL(WINAPI * PFN_KbdLayerRealDllFile) (ULONG, PWSTR, PCLIENTKEYBOARDTYPE, PVOID)
 
typedef BOOL(WINAPI * PFN_KbdLayerMultiDescriptor) (PKBDTABLE_MULTI)
 
typedef struct tagIMEHOTKEYENTRY IMEHOTKEYENTRY
 
typedef struct tagIMEHOTKEYENTRY * PIMEHOTKEYENTRY
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
static BOOL IntIsConsoleSession (void)
 
VOID FASTCALL IntSetFeKeyboardFlags (LANGID LangID, PBYTE pbFlags)
 
DWORD FASTCALL CliReadRegistryValue (HANDLE hKey, LPCWSTR pszName)
 
BOOL APIENTRY CliImmSetHotKeyWorker (DWORD dwHotKeyId, UINT uModifiers, UINT uVirtualKey, HKL hKL, DWORD dwAction)
 
VOID IntLoadPreloadKeyboardLayouts (VOID)
 
BOOL APIENTRY CliSaveImeHotKey (DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKL, BOOL bDelete)
 
BOOL WINAPI CliImmSetHotKey (_In_ DWORD dwID, _In_ UINT uModifiers, _In_ UINT uVirtualKey, _In_opt_ _When_((dwAction==SETIMEHOTKEY_ADD) &&!(IME_HOTKEY_DSWITCH_FIRST<=dwHotKeyId &&dwHotKeyId<=IME_HOTKEY_DSWITCH_LAST), _Null_) HKL hKL)
 
BOOL FASTCALL CliSetSingleHotKey (LPCWSTR pszSubKey, HANDLE hKey)
 
BOOL FASTCALL CliGetImeHotKeysFromRegistry (VOID)
 
VOID APIENTRY CliGetPreloadKeyboardLayouts (PBYTE pbFlags)
 
VOID APIENTRY CliSetDefaultImeHotKeys (PIMEHOTKEYENTRY pEntries, UINT nCount, BOOL bCheck)
 
VOID APIENTRY CliImmInitializeHotKeys (DWORD dwAction, HKL hKL)
 
BOOL WINAPI DragDetect (HWND hWnd, POINT pt)
 
BOOL WINAPI EnableWindow (HWND hWnd, BOOL bEnable)
 
SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState (int vKey)
 
HKL WINAPI GetKeyboardLayout (DWORD idThread)
 
UINT WINAPI GetKBCodePage (VOID)
 
int WINAPI GetKeyNameTextA (LONG lParam, LPSTR lpString, int nSize)
 
int WINAPI GetKeyNameTextW (LONG lParam, LPWSTR lpString, int nSize)
 
SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState (int nVirtKey)
 
BOOL WINAPI GetKeyboardLayoutNameA (LPSTR pwszKLID)
 
BOOL WINAPI GetKeyboardLayoutNameW (LPWSTR pwszKLID)
 
int WINAPI GetKeyboardType (int nTypeFlag)
 
BOOL WINAPI GetLastInputInfo (PLASTINPUTINFO plii)
 
HKL WINAPI LoadKeyboardLayoutA (LPCSTR pszKLID, UINT Flags)
 
static BOOL IsValidKLID (_In_ LPCWSTR pwszKLID)
 
static BOOL IntIsValidLayoutFileName (PCWSTR pszFileName)
 
BOOL GetSystemLibraryPath (PWSTR pszPath, SIZE_T cchPath, PCWSTR pszFileName)
 
static HMODULE LoadSysLibraryW (PCWSTR pszFileName)
 
static VOID IntCloseAuxFiles (_Inout_opt_ PKBDTABLE_MULTI_EX pMulti)
 Closes the aux file handles that IntLoadKeyboardLayoutTablesAndFile stored in pMulti. Skips NULL and INVALID_HANDLE_VALUE (a failed aux file), and resets the table count.
 
static HANDLE IntLoadKeyboardLayoutTablesAndFile (_In_ PCWSTR pszLayoutFile, _In_opt_ PCWSTR pszKLID, _Inout_ PUINT puFlags, _Out_ PULONG poffTable, _Out_opt_ PKBDTABLE_MULTI_EX pMulti)
 Returns a handle to the layout file, or NULL on failure. On success, the handles in pMulti (if any) stay open for the caller; on failure, this function has closed them.
 
static VOID IntLoadMultiTables (_In_ HMODULE hModule, _Inout_ PUINT puFlags, _Inout_ PKBDTABLE_MULTI_EX pMulti)
 Loads the multi-table (if any). Each aux table file is loaded by a recursive call, and its file handle and offset are stored in pMulti. The caller owns the handles: see IntCloseAuxFiles.
 
static VOID IntFollowRealDll (_Inout_ HMODULE *phModule, _Outptr_ PCWSTR *ppszFile, _Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR pszRealFile, _In_opt_ PCWSTR pszKLID)
 If the layout DLL redirects to a "real" DLL, loads that one instead and releases the original. On return, *phModule and *ppszFile name the DLL that is actually used.
 
static PFN_KbdLayerDescriptor IntPrepareLayoutModule (_Inout_ HMODULE *phModule, _In_ _Outptr_ PCWSTR *ppszFile, _Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR pszRealFile, _In_opt_ PCWSTR pszKLID, _Inout_ PUINT puFlags, _Inout_opt_ PKBDTABLE_MULTI_EX pMulti)
 Prepares a freshly loaded layout DLL: loads the multi-table, follows the "real" DLL, and gets KbdLayerDescriptor. Returns NULL on failure. The caller owns *phModule either way (it can be replaced by the real DLL). The layout DLL code can crash, so everything is under SEH.
 
static BOOL IntGetTableOffsets (_In_ HMODULE hModule, _In_ PFN_KbdLayerDescriptor pfnMain, _Out_ PULONG poffTable)
 Gets the 16-bit offsets of the tables, as NtUserLoadKeyboardLayoutEx expects them: LOWORD is the main table and HIWORD is the NLS table (0 if none).
 
static BOOL IntGetKeyboardDllName (_Out_writes_z_(cchDllName) PWSTR pszDllName, _In_ SIZE_T cchDllName, _Inout_updates_z_(cchKLID) PWSTR pszKLID, _In_ SIZE_T cchKLID, _In_ LANGID wLangID, _Inout_ PUINT puFlags, _Out_ PULONG pdwKL)
 
static HANDLE IntLoadKeyboardLayoutFile (_Inout_updates_z_(cchKLID) PWSTR pszKLID, _In_ SIZE_T cchKLID, _In_ DWORD wLangID, _Inout_ PUINT pFlags, _Out_ PULONG pOffTable, _Out_ PULONG pdwNewKL, _Out_opt_ PKBDTABLE_MULTI_EX pMulti)
 Opens and loads keyboard layout file(s).
 
static HKL IntLoadKeyboardLayout (_In_opt_ HKL hklUnload, _In_ PCWSTR pwszKLID, _In_ LANGID wLangID, _In_ UINT Flags, _In_ BOOL bForce)
 
HKL WINAPI LoadKeyboardLayoutW (LPCWSTR pwszKLID, UINT Flags)
 
HKL WINAPI LoadKeyboardLayoutEx (_In_ HKL hklUnload, _In_ PCWSTR pwszKLID, _In_ UINT Flags)
 
BOOL WINAPI UnloadKeyboardLayout (HKL hKL)
 
UINT WINAPI MapVirtualKeyA (UINT uCode, UINT uMapType)
 
UINT WINAPI MapVirtualKeyExA (UINT uCode, UINT uMapType, HKL dwhkl)
 
UINT WINAPI MapVirtualKeyExW (UINT uCode, UINT uMapType, HKL dwhkl)
 
UINT WINAPI MapVirtualKeyW (UINT uCode, UINT uMapType)
 
DWORD WINAPI OemKeyScan (WORD wOemChar)
 
BOOL WINAPI SetDoubleClickTime (UINT uInterval)
 
BOOL WINAPI SwapMouseButton (BOOL fSwap)
 
int WINAPI ToAscii (UINT uVirtKey, UINT uScanCode, CONST BYTE *lpKeyState, LPWORD lpChar, UINT uFlags)
 
int WINAPI ToAsciiEx (UINT uVirtKey, UINT uScanCode, CONST BYTE *lpKeyState, LPWORD lpChar, UINT uFlags, HKL dwhkl)
 
int WINAPI ToUnicode (UINT wVirtKey, UINT wScanCode, CONST BYTE *lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags)
 
int WINAPI ToUnicodeEx (UINT wVirtKey, UINT wScanCode, CONST BYTE *lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, HKL dwhkl)
 
SHORT WINAPI VkKeyScanA (CHAR ch)
 
SHORT WINAPI VkKeyScanExA (CHAR ch, HKL dwhkl)
 
SHORT WINAPI VkKeyScanExW (WCHAR ch, HKL dwhkl)
 
SHORT WINAPI VkKeyScanW (WCHAR ch)
 
VOID WINAPI keybd_event (BYTE bVk, BYTE bScan, DWORD dwFlags, ULONG_PTR dwExtraInfo)
 
VOID WINAPI mouse_event (DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG_PTR dwExtraInfo)
 

Variables

IMEHOTKEYENTRY DefaultHotKeyTableJ []
 
IMEHOTKEYENTRY DefaultHotKeyTableT []
 
IMEHOTKEYENTRY DefaultHotKeyTableC []
 

Macro Definition Documentation

◆ ATTR_MASK

#define ATTR_MASK   0x00FF0000

Definition at line 39 of file input.c.

◆ FE_CHINESE_SIMPLIFIED

#define FE_CHINESE_SIMPLIFIED   (1 << 2)

Definition at line 92 of file input.c.

◆ FE_CHINESE_TRADITIONAL

#define FE_CHINESE_TRADITIONAL   (1 << 1)

Definition at line 91 of file input.c.

◆ FE_JAPANESE

#define FE_JAPANESE   (1 << 0)

Definition at line 90 of file input.c.

◆ FE_KOREAN

#define FE_KOREAN   (1 << 3)

Definition at line 93 of file input.c.

◆ IFN_KbdLayerDescriptor

#define IFN_KbdLayerDescriptor   MAKEINTRESOURCEA(1)

Definition at line 43 of file input.c.

◆ IFN_KbdLayerMultiDescriptor

#define IFN_KbdLayerMultiDescriptor   MAKEINTRESOURCEA(6)

Definition at line 47 of file input.c.

◆ IFN_KbdLayerRealDllFile

#define IFN_KbdLayerRealDllFile   MAKEINTRESOURCEA(5)

Definition at line 46 of file input.c.

◆ IFN_KbdLayerRealDllFileNT4

#define IFN_KbdLayerRealDllFileNT4   MAKEINTRESOURCEA(3)

Definition at line 45 of file input.c.

◆ IFN_KbdNlsLayerDescriptor

#define IFN_KbdNlsLayerDescriptor   MAKEINTRESOURCEA(2)

Definition at line 44 of file input.c.

◆ KBDLAYOUT_KEY

Definition at line 38 of file input.c.

◆ KBDLAYOUTS_KEY

Definition at line 37 of file input.c.

◆ KLF_FORCE

#define KLF_FORCE   0x200

Definition at line 35 of file input.c.

◆ KLF_INITTIME

#define KLF_INITTIME   0x80000000

Definition at line 34 of file input.c.

◆ LANGID_ENGLISH_US

#define LANGID_ENGLISH_US   MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)

Definition at line 40 of file input.c.

◆ MOD_ALL_MODS

#define MOD_ALL_MODS   (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN)

Typedef Documentation

◆ IMEHOTKEYENTRY

◆ PFN_KbdLayerDescriptor

typedef PVOID(WINAPI * PFN_KbdLayerDescriptor) (void)

Definition at line 50 of file input.c.

◆ PFN_KbdLayerMultiDescriptor

typedef BOOL(WINAPI * PFN_KbdLayerMultiDescriptor) (PKBDTABLE_MULTI)

Definition at line 54 of file input.c.

◆ PFN_KbdLayerRealDllFile

typedef BOOL(WINAPI * PFN_KbdLayerRealDllFile) (ULONG, PWSTR, PCLIENTKEYBOARDTYPE, PVOID)

Definition at line 53 of file input.c.

◆ PFN_KbdLayerRealDllFileNT4

typedef BOOL(WINAPI * PFN_KbdLayerRealDllFileNT4) (PWSTR)

Definition at line 52 of file input.c.

◆ PFN_KbdNlsLayerDescriptor

typedef PVOID(WINAPI * PFN_KbdNlsLayerDescriptor) (void)

Definition at line 51 of file input.c.

◆ PIMEHOTKEYENTRY

Function Documentation

◆ CliGetImeHotKeysFromRegistry()

BOOL FASTCALL CliGetImeHotKeysFromRegistry ( VOID  )

Definition at line 345 of file input.c.

346{
347 HKEY hKey;
348 LONG error;
349 BOOL ret = FALSE;
350 DWORD dwIndex, cchKeyName;
351 WCHAR szKeyName[16];
352
354 L"Control Panel\\Input Method\\Hot Keys",
355 0,
356 KEY_READ,
357 &hKey);
358 if (error != ERROR_SUCCESS)
359 return ret;
360
361 for (dwIndex = 0; dwIndex < 1000; ++dwIndex)
362 {
363 cchKeyName = _countof(szKeyName);
364 error = RegEnumKeyExW(hKey, dwIndex, szKeyName, &cchKeyName, NULL, NULL, NULL, NULL);
365 if (error != ERROR_SUCCESS)
366 break;
367
368 szKeyName[_countof(szKeyName) - 1] = 0; /* Avoid stack overrun */
369
370 if (CliSetSingleHotKey(szKeyName, hKey))
371 ret = TRUE;
372 }
373
375 return ret;
376}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_READ
Definition: nt_native.h:1026
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define _countof(array)
Definition: sndvol32.h:70
BOOL FASTCALL CliSetSingleHotKey(LPCWSTR pszSubKey, HANDLE hKey)
Definition: input.c:320
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CliImmInitializeHotKeys().

◆ CliGetPreloadKeyboardLayouts()

VOID APIENTRY CliGetPreloadKeyboardLayouts ( PBYTE  pbFlags)

Definition at line 378 of file input.c.

379{
380 WCHAR szValueName[33], szValue[16];
381 UNICODE_STRING ustrValue;
382 DWORD dwKL, cbValue, dwType;
383 UINT iNumber;
384 HKEY hKey;
385 LONG error;
386
387 error = RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, KEY_READ, &hKey);
388 if (error != ERROR_SUCCESS)
389 return;
390
391 for (iNumber = 1; iNumber < 1000; ++iNumber)
392 {
393 _ultow(iNumber, szValueName, 10);
394
395 cbValue = sizeof(szValue);
396 error = RegQueryValueExW(hKey, szValueName, NULL, &dwType, (LPBYTE)szValue, &cbValue);
397 if (error != ERROR_SUCCESS)
398 break;
399
400 if (dwType != REG_SZ)
401 continue;
402
403 szValue[_countof(szValue) - 1] = 0; /* Avoid stack overrun */
404
405 RtlInitUnicodeString(&ustrValue, szValue);
406 RtlUnicodeStringToInteger(&ustrValue, 16, &dwKL);
407
408 IntSetFeKeyboardFlags(LOWORD(dwKL), pbFlags);
409 }
410
412}
#define REG_SZ
Definition: layer.c:22
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
_ACRTIMP wchar_t *__cdecl _ultow(__msvcrt_ulong, wchar_t *, int)
Definition: string.c:2204
unsigned int UINT
Definition: sysinfo.c:13
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
#define LOWORD(l)
Definition: pedump.c:82
unsigned char * LPBYTE
Definition: typedefs.h:53
VOID FASTCALL IntSetFeKeyboardFlags(LANGID LangID, PBYTE pbFlags)
Definition: input.c:96

Referenced by CliImmInitializeHotKeys().

◆ CliImmInitializeHotKeys()

VOID APIENTRY CliImmInitializeHotKeys ( DWORD  dwAction,
HKL  hKL 
)

Definition at line 433 of file input.c.

434{
435 UINT nCount;
436 LPHKL pList;
437 UINT iIndex;
439 BYTE bFlags = 0;
440 BOOL bCheck;
441
443
445
446 if (dwAction == SETIMEHOTKEY_INITIALIZE)
447 {
450
452 }
453 else
454 {
456 if (!nCount)
457 return;
458
459 pList = RtlAllocateHeap(RtlGetProcessHeap(), 0, nCount * sizeof(HKL));
460 if (!pList)
461 return;
462
464
465 for (iIndex = 0; iIndex < nCount; ++iIndex)
466 {
467 LangID = LOWORD(pList[iIndex]);
469 }
470
471 RtlFreeHeap(RtlGetProcessHeap(), 0, pList);
472 }
473
474 if (bFlags & FE_JAPANESE)
476
477 if (bFlags & FE_CHINESE_TRADITIONAL)
479
480 if (bFlags & FE_CHINESE_SIMPLIFIED)
482}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
FxChildList * pList
HKL FAR * LPHKL
Definition: imm.h:24
UINT NTAPI NtUserGetKeyboardLayoutList(ULONG nItems, HKL *pHklBuff)
Definition: kbdlayout.c:2010
BOOL NTAPI NtUserSetImeHotKey(_In_ DWORD dwHotKeyId, _In_ UINT uModifiers, _In_ UINT uVirtualKey, _In_opt_ HKL hKL, _In_ DWORD dwAction)
Definition: ime.c:478
USHORT LANGID
Definition: mui.h:9
UINT_PTR HKL
Definition: msctf.idl:125
#define LANGIDFROMLCID(l)
Definition: nls.h:18
@ SETIMEHOTKEY_INITIALIZE
Definition: undocuser.h:424
_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
Definition: wdfusb.h:1083
#define FE_JAPANESE
Definition: input.c:90
VOID APIENTRY CliGetPreloadKeyboardLayouts(PBYTE pbFlags)
Definition: input.c:378
IMEHOTKEYENTRY DefaultHotKeyTableT[]
Definition: input.c:76
IMEHOTKEYENTRY DefaultHotKeyTableC[]
Definition: input.c:83
#define FE_CHINESE_SIMPLIFIED
Definition: input.c:92
#define FE_CHINESE_TRADITIONAL
Definition: input.c:91
BOOL FASTCALL CliGetImeHotKeysFromRegistry(VOID)
Definition: input.c:345
IMEHOTKEYENTRY DefaultHotKeyTableJ[]
Definition: input.c:70
VOID APIENTRY CliSetDefaultImeHotKeys(PIMEHOTKEYENTRY pEntries, UINT nCount, BOOL bCheck)
Definition: input.c:414
unsigned char BYTE
Definition: xxhash.c:193

Referenced by IntLoadKeyboardLayout(), UnloadKeyboardLayout(), and UpdatePerUserSystemParameters().

◆ CliImmSetHotKey()

BOOL WINAPI CliImmSetHotKey ( _In_ DWORD  dwID,
_In_ UINT  uModifiers,
_In_ UINT  uVirtualKey,
_In_opt_ _When_((dwAction==SETIMEHOTKEY_ADD) &&!(IME_HOTKEY_DSWITCH_FIRST<=dwHotKeyId &&dwHotKeyId<=IME_HOTKEY_DSWITCH_LAST), _Null_) HKL  hKL 
)

@implemented

Note
Same as imm32!ImmSetHotKey.

Definition at line 290 of file input.c.

297{
298 BOOL ret;
299
300 if (uVirtualKey == 0) // Delete?
301 {
302 ret = CliSaveImeHotKey(dwID, uModifiers, uVirtualKey, hKL, TRUE);
303 if (ret)
304 CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_DELETE);
305 return ret;
306 }
307
308 // Add
309 ret = CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_ADD);
310 if (ret)
311 {
312 ret = CliSaveImeHotKey(dwID, uModifiers, uVirtualKey, hKL, FALSE);
313 if (!ret) // Failure?
314 CliImmSetHotKeyWorker(dwID, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_DELETE);
315 }
316
317 return ret;
318}
@ SETIMEHOTKEY_ADD
Definition: undocuser.h:423
@ SETIMEHOTKEY_DELETE
Definition: undocuser.h:422
BOOL APIENTRY CliImmSetHotKeyWorker(DWORD dwHotKeyId, UINT uModifiers, UINT uVirtualKey, HKL hKL, DWORD dwAction)
Definition: input.c:137
BOOL APIENTRY CliSaveImeHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKL, BOOL bDelete)
Definition: input.c:234

◆ CliImmSetHotKeyWorker()

BOOL APIENTRY CliImmSetHotKeyWorker ( DWORD  dwHotKeyId,
UINT  uModifiers,
UINT  uVirtualKey,
HKL  hKL,
DWORD  dwAction 
)

Definition at line 137 of file input.c.

138{
139 if (dwAction == SETIMEHOTKEY_ADD)
140 {
141 if (IME_HOTKEY_DSWITCH_FIRST <= dwHotKeyId && dwHotKeyId <= IME_HOTKEY_DSWITCH_LAST)
142 {
143 if (!hKL)
144 goto Failure;
145 }
146 else
147 {
148 if (hKL)
149 goto Failure;
150
151 if (IME_KHOTKEY_SHAPE_TOGGLE <= dwHotKeyId &&
153 {
154 // The Korean cannot set the IME hotkeys
155 goto Failure;
156 }
157 }
158
159#define MOD_ALL_MODS (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN)
160 if ((uModifiers & MOD_ALL_MODS) && !(uModifiers & (MOD_LEFT | MOD_RIGHT)))
161 goto Failure;
162#undef MOD_ALL_MODS
163 }
164
165 return NtUserSetImeHotKey(dwHotKeyId, uModifiers, uVirtualKey, hKL, dwAction);
166
167Failure:
169 return FALSE;
170}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define MOD_LEFT
Definition: imm.h:188
#define IME_THOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:207
#define IME_KHOTKEY_SHAPE_TOGGLE
Definition: imm.h:203
#define IME_HOTKEY_DSWITCH_LAST
Definition: imm.h:213
#define IME_HOTKEY_DSWITCH_FIRST
Definition: imm.h:212
#define MOD_RIGHT
Definition: imm.h:189
#define MOD_ALL_MODS

Referenced by CliImmSetHotKey(), CliSetDefaultImeHotKeys(), and CliSetSingleHotKey().

◆ CliReadRegistryValue()

DWORD FASTCALL CliReadRegistryValue ( HANDLE  hKey,
LPCWSTR  pszName 
)

Definition at line 123 of file input.c.

124{
125 DWORD dwValue, cbValue;
126 LONG error;
127
128 cbValue = sizeof(dwValue);
129 error = RegQueryValueExW(hKey, pszName, NULL, NULL, (LPBYTE)&dwValue, &cbValue);
130 if (error != ERROR_SUCCESS || cbValue < sizeof(DWORD))
131 return 0;
132
133 return dwValue;
134}

Referenced by CliSetSingleHotKey().

◆ CliSaveImeHotKey()

BOOL APIENTRY CliSaveImeHotKey ( DWORD  dwID,
UINT  uModifiers,
UINT  uVirtualKey,
HKL  hKL,
BOOL  bDelete 
)

Definition at line 234 of file input.c.

235{
237 LONG error;
238 HKEY hKey;
239 BOOL ret = FALSE, bRevertOnFailure = FALSE;
240
242 L"Control Panel\\Input Method\\Hot Keys\\%08lX", dwID);
243
244 if (bDelete)
245 {
247 return (error == ERROR_SUCCESS);
248 }
249
251 if (error == ERROR_SUCCESS)
252 {
253 bRevertOnFailure = TRUE;
254
255 // Set "Virtual Key"
256 error = RegSetValueExW(hKey, L"Virtual Key", 0, REG_BINARY,
257 (LPBYTE)&uVirtualKey, sizeof(uVirtualKey));
258 if (error == ERROR_SUCCESS)
259 {
260 // Set "Key Modifiers"
261 error = RegSetValueExW(hKey, L"Key Modifiers", 0, REG_BINARY,
262 (LPBYTE)&uModifiers, sizeof(uModifiers));
263 if (error == ERROR_SUCCESS)
264 {
265 // Set "Target IME"
266 error = RegSetValueExW(hKey, L"Target IME", 0, REG_BINARY,
267 (LPBYTE)&hKL, sizeof(hKL));
268 if (error == ERROR_SUCCESS)
269 {
270 // Success!
271 ret = TRUE;
272 bRevertOnFailure = FALSE;
273 }
274 }
275 }
277 }
278
279 if (bRevertOnFailure)
280 CliSaveImeHotKey(dwID, uVirtualKey, uModifiers, hKL, TRUE);
281
282 return ret;
283}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define MAX_PATH
Definition: compat.h:34
#define REG_BINARY
Definition: nt_native.h:1499
#define KEY_WRITE
Definition: nt_native.h:1034
static const WCHAR szName[]
Definition: powrprof.c:45
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by CliImmSetHotKey(), and CliSaveImeHotKey().

◆ CliSetDefaultImeHotKeys()

VOID APIENTRY CliSetDefaultImeHotKeys ( PIMEHOTKEYENTRY  pEntries,
UINT  nCount,
BOOL  bCheck 
)

Definition at line 414 of file input.c.

415{
416 UINT uVirtualKey, uModifiers;
417 HKL hKL;
418
419 while (nCount-- > 0)
420 {
421 if (!bCheck || !NtUserGetImeHotKey(pEntries->dwHotKeyId, &uModifiers, &uVirtualKey, &hKL))
422 {
424 pEntries->uModifiers,
425 pEntries->uVirtualKey,
426 pEntries->hKL,
428 }
429 ++pEntries;
430 }
431}
BOOL NTAPI NtUserGetImeHotKey(_In_ DWORD dwHotKeyId, _Out_ PUINT lpuModifiers, _Out_ PUINT lpuVirtualKey, _Out_opt_ LPHKL lphKL)
Definition: ime.c:429
UINT uVirtualKey
Definition: input.c:64
DWORD dwHotKeyId
Definition: input.c:63
UINT uModifiers
Definition: input.c:65

Referenced by CliImmInitializeHotKeys().

◆ CliSetSingleHotKey()

BOOL FASTCALL CliSetSingleHotKey ( LPCWSTR  pszSubKey,
HANDLE  hKey 
)

Definition at line 320 of file input.c.

321{
322 LONG error;
323 HKEY hSubKey;
324 DWORD dwHotKeyId = 0;
325 UINT uModifiers = 0, uVirtualKey = 0;
326 HKL hKL = NULL;
327 UNICODE_STRING ustrName;
328
329 error = RegOpenKeyExW(hKey, pszSubKey, 0, KEY_READ, &hSubKey);
330 if (error != ERROR_SUCCESS)
331 return FALSE;
332
334 RtlUnicodeStringToInteger(&ustrName, 16, &dwHotKeyId);
335
336 uModifiers = CliReadRegistryValue(hSubKey, L"Key Modifiers");
337 hKL = (HKL)(ULONG_PTR)CliReadRegistryValue(hSubKey, L"Target IME");
338 uVirtualKey = CliReadRegistryValue(hSubKey, L"Virtual Key");
339
340 RegCloseKey(hSubKey);
341
342 return CliImmSetHotKeyWorker(dwHotKeyId, uModifiers, uVirtualKey, hKL, SETIMEHOTKEY_ADD);
343}
_In_opt_ LPCSTR pszSubKey
Definition: shlwapi.h:783
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD FASTCALL CliReadRegistryValue(HANDLE hKey, LPCWSTR pszName)
Definition: input.c:123

Referenced by CliGetImeHotKeysFromRegistry().

◆ DragDetect()

BOOL WINAPI DragDetect ( HWND  hWnd,
POINT  pt 
)

Definition at line 489 of file input.c.

492{
493 return NtUserDragDetect(hWnd, pt);
494#if 0
495 MSG msg;
496 RECT rect;
497 POINT tmp;
500
501 rect.left = pt.x - dx;
502 rect.right = pt.x + dx;
503 rect.top = pt.y - dy;
504 rect.bottom = pt.y + dy;
505
507
508 for (;;)
509 {
510 while (
513 )
514 {
515 if (msg.message == WM_LBUTTONUP)
516 {
518 return FALSE;
519 }
520 if (msg.message == WM_MOUSEMOVE)
521 {
522 tmp.x = LOWORD(msg.lParam);
523 tmp.y = HIWORD(msg.lParam);
524 if (!PtInRect(&rect, tmp))
525 {
527 return TRUE;
528 }
529 }
530 if (msg.message == WM_KEYDOWN)
531 {
532 if (msg.wParam == VK_ESCAPE)
533 {
535 return TRUE;
536 }
537 }
538 }
539 WaitMessage();
540 }
541 return 0;
542#endif
543}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
RECT rect
Definition: combotst.c:67
#define pt(x, y)
Definition: drawing.c:79
BOOL NTAPI NtUserDragDetect(HWND hWnd, POINT pt)
Definition: message.c:2207
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WM_MOUSEFIRST
Definition: winuser.h:1802
#define SM_CXDRAG
Definition: winuser.h:1039
#define WM_MOUSELAST
Definition: winuser.h:1829
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define WM_KEYFIRST
Definition: winuser.h:1742
#define WM_MOUSEMOVE
Definition: winuser.h:1803
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI WaitMessage(void)
Definition: ntwrapper.h:350
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define WM_KEYDOWN
Definition: winuser.h:1743
#define SM_CYDRAG
Definition: winuser.h:1040
#define WM_KEYLAST
Definition: winuser.h:1756
#define VK_ESCAPE
Definition: winuser.h:2250
int WINAPI GetSystemMetrics(_In_ int)
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247

◆ EnableWindow()

BOOL WINAPI EnableWindow ( HWND  hWnd,
BOOL  bEnable 
)

Definition at line 549 of file input.c.

550{
552}
EXTINLINE BOOL NtUserxEnableWindow(HWND hWnd, BOOL bEnable)
Definition: ntwrapper.h:681
_In_ BOOL bEnable
Definition: winddi.h:3426

◆ GetAsyncKeyState()

SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState ( int  vKey)

Definition at line 560 of file input.c.

561{
562 if (vKey < 0 || vKey > 256)
563 return 0;
564 return (SHORT)NtUserGetAsyncKeyState((DWORD)vKey);
565}
SHORT NTAPI NtUserGetAsyncKeyState(INT Key)
Definition: keyboard.c:675
short SHORT
Definition: pedump.c:59

◆ GetKBCodePage()

UINT WINAPI GetKBCodePage ( VOID  )

Definition at line 582 of file input.c.

583{
584 return GetOEMCP();
585}
UINT WINAPI GetOEMCP(void)
Definition: locale.c:2062

◆ GetKeyboardLayout()

HKL WINAPI GetKeyboardLayout ( DWORD  idThread)

Definition at line 572 of file input.c.

573{
574 return NtUserxGetKeyboardLayout(idThread);
575}
EXTINLINE HKL NtUserxGetKeyboardLayout(DWORD idThread)
Definition: ntwrapper.h:626

◆ GetKeyboardLayoutNameA()

BOOL WINAPI GetKeyboardLayoutNameA ( LPSTR  pwszKLID)

Definition at line 642 of file input.c.

643{
645
647 return FALSE;
648
649 if (!WideCharToMultiByte(CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL))
650 return FALSE;
651
652 return TRUE;
653}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI GetKeyboardLayoutNameW(_Out_writes_(KL_NAMELENGTH) LPWSTR)
#define KL_NAMELENGTH
Definition: winuser.h:122

◆ GetKeyboardLayoutNameW()

BOOL WINAPI GetKeyboardLayoutNameW ( LPWSTR  pwszKLID)

Definition at line 659 of file input.c.

660{
662
664 pwszKLID,
665 KL_NAMELENGTH * sizeof(WCHAR));
666
668}
RtlInitEmptyUnicodeString(SymbolicLinkName, NULL, 0)
LPWSTR Name
Definition: desk.c:124
BOOL NTAPI NtUserGetKeyboardLayoutName(_Inout_ PUNICODE_STRING pustrName)
Definition: kbdlayout.c:2064

◆ GetKeyboardType()

int WINAPI GetKeyboardType ( int  nTypeFlag)

Definition at line 674 of file input.c.

675{
676 return NtUserxGetKeyboardType(nTypeFlag);
677}
EXTINLINE INT NtUserxGetKeyboardType(INT nTypeFlag)
Definition: ntwrapper.h:631

◆ GetKeyNameTextA()

int WINAPI GetKeyNameTextA ( LONG  lParam,
LPSTR  lpString,
int  nSize 
)

Definition at line 592 of file input.c.

595{
596 LPWSTR pwszBuf;
597 UINT cchBuf = 0;
598 int iRet = 0;
599 BOOL defChar = FALSE;
600
601 pwszBuf = HeapAlloc(GetProcessHeap(), 0, nSize * sizeof(WCHAR));
602 if (!pwszBuf)
603 return 0;
604
606
607 iRet = WideCharToMultiByte(CP_ACP, 0,
608 pwszBuf, cchBuf,
609 lpString, nSize, ".", &defChar); // FIXME: do we need defChar?
610 lpString[iRet] = 0;
611 HeapFree(GetProcessHeap(), 0, pwszBuf);
612
613 return iRet;
614}
LPARAM lParam
Definition: combotst.c:139
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD NTAPI NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int nSize)
Definition: keyboard.c:1896
_In_ UINT cchBuf
Definition: shlwapi.h:378
uint16_t * LPWSTR
Definition: typedefs.h:56
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:1809

◆ GetKeyNameTextW()

int WINAPI GetKeyNameTextW ( LONG  lParam,
LPWSTR  lpString,
int  nSize 
)

Definition at line 620 of file input.c.

623{
624 return NtUserGetKeyNameText(lParam, lpString, nSize);
625}

◆ GetKeyState()

SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState ( int  nVirtKey)

Definition at line 633 of file input.c.

634{
635 return (SHORT)NtUserGetKeyState((DWORD)nVirtKey);
636}
SHORT NTAPI NtUserGetKeyState(INT VirtKey)
Definition: msgqueue.c:2573

◆ GetLastInputInfo()

BOOL WINAPI GetLastInputInfo ( PLASTINPUTINFO  plii)

Definition at line 683 of file input.c.

684{
685 TRACE("%p\n", plii);
686
687 if (plii->cbSize != sizeof (*plii))
688 {
690 return FALSE;
691 }
692
693 plii->dwTime = gpsi->dwLastRITEventTickCount;
694 return TRUE;
695}
PSERVERINFO gpsi
Definition: imm.c:18
#define TRACE(s)
Definition: solgame.cpp:4
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ GetSystemLibraryPath()

BOOL GetSystemLibraryPath ( PWSTR  pszPath,
SIZE_T  cchPath,
PCWSTR  pszFileName 
)

Definition at line 728 of file input.c.

729{
730 WCHAR szSysDir[MAX_PATH];
731 UINT cch = GetSystemDirectoryW(szSysDir, _countof(szSysDir));
732 if (!cch || cch >= _countof(szSysDir))
733 return FALSE;
734 return SUCCEEDED(StringCchPrintfW(pszPath, cchPath, L"%s\\%s", szSysDir, pszFileName));
735}
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2331
#define SUCCEEDED(hr)
Definition: intsafe.h:50
_In_ UINT _In_ UINT cch
Definition: shellapi.h:428
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44

Referenced by LoadSysLibraryW().

◆ IntCloseAuxFiles()

static VOID IntCloseAuxFiles ( _Inout_opt_ PKBDTABLE_MULTI_EX  pMulti)
static

Closes the aux file handles that IntLoadKeyboardLayoutTablesAndFile stored in pMulti. Skips NULL and INVALID_HANDLE_VALUE (a failed aux file), and resets the table count.

Definition at line 751 of file input.c.

753{
754 UINT iTable;
755
756 if (!pMulti)
757 return;
758
759 for (iTable = 0; iTable < pMulti->Multi.nTables && iTable < KBDTABLE_MULTI_MAX; ++iTable)
760 {
761 HANDLE hAuxFile = pMulti->AuxEntries[iTable].hFile;
762 if (hAuxFile)
763 CloseHandle(hAuxFile);
764 pMulti->AuxEntries[iTable].hFile = NULL;
765 }
766
767 pMulti->Multi.nTables = 0;
768}
#define CloseHandle
Definition: compat.h:739
#define KBDTABLE_MULTI_MAX
Definition: kbd.h:199

Referenced by IntLoadKeyboardLayoutTablesAndFile().

◆ IntFollowRealDll()

static VOID IntFollowRealDll ( _Inout_ HMODULE *  phModule,
_Outptr_ PCWSTR *  ppszFile,
_Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR  pszRealFile,
_In_opt_ PCWSTR  pszKLID 
)
static

If the layout DLL redirects to a "real" DLL, loads that one instead and releases the original. On return, *phModule and *ppszFile name the DLL that is actually used.

Definition at line 822 of file input.c.

827{
830 HMODULE hRealModule;
831 ULONG ulKLID;
832 WCHAR szReturned[MAX_PATH];
833
836 if (!pfnReal && !pfnRealNT4)
837 return;
838
839 ulKLID = pszKLID ? wcstoul(pszKLID, NULL, 16) : 0;
840 pszRealFile[0] = UNICODE_NULL;
841 szReturned[0] = UNICODE_NULL;
842
843 /* FIXME: Specify PCLIENTKEYBOARDTYPE parameter for pfnReal */
844 /* FIXME: Implement ntuser's UserInitKeyboard and use GetKeyboardType */
845 if (!(pfnReal && pfnReal(ulKLID, szReturned, NULL, NULL)) &&
846 !(pfnRealNT4 && pfnRealNT4(szReturned)))
847 {
848 return;
849 }
850 szReturned[MAX_PATH - 1] = UNICODE_NULL; /* Avoid buffer overrun */
851
852 if (!IntIsValidLayoutFileName(szReturned) ||
853 FAILED(StringCchCopyW(pszRealFile, MAX_LAYOUT_FILENAME, szReturned)))
854 {
855 WARN("Invalid real DLL name: %s\n", debugstr_w(szReturned));
856 return;
857 }
858
859 hRealModule = LoadSysLibraryW(pszRealFile);
860 if (!hRealModule)
861 {
862 WARN("LoadSysLibraryW(%s) failed\n", debugstr_w(pszRealFile));
863 return;
864 }
865
866 FreeLibrary(*phModule);
867 *phModule = hRealModule;
868 *ppszFile = pszRealFile;
869}
#define WARN(fmt,...)
Definition: precomp.h:61
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
#define MAX_LAYOUT_FILENAME
Definition: ntuser.h:118
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
#define UNICODE_NULL
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL(WINAPI * PFN_KbdLayerRealDllFileNT4)(PWSTR)
Definition: input.c:52
static BOOL IntIsValidLayoutFileName(PCWSTR pszFileName)
Definition: input.c:720
static HMODULE LoadSysLibraryW(PCWSTR pszFileName)
Definition: input.c:737
BOOL(WINAPI * PFN_KbdLayerRealDllFile)(ULONG, PWSTR, PCLIENTKEYBOARDTYPE, PVOID)
Definition: input.c:53
#define IFN_KbdLayerRealDllFile
Definition: input.c:46
#define IFN_KbdLayerRealDllFileNT4
Definition: input.c:45

Referenced by IntPrepareLayoutModule().

◆ IntGetKeyboardDllName()

static BOOL IntGetKeyboardDllName ( _Out_writes_z_(cchDllName) PWSTR  pszDllName,
_In_ SIZE_T  cchDllName,
_Inout_updates_z_(cchKLID) PWSTR  pszKLID,
_In_ SIZE_T  cchKLID,
_In_ LANGID  wLangID,
_Inout_ PUINT  puFlags,
_Out_ PULONG  pdwKL 
)
static

Definition at line 1051 of file input.c.

1059{
1060 HKEY hKey;
1061 DWORD error, cbData, dwType, dwAttributes, dwKL;
1062 PCWSTR pszSource = NULL;
1063 WCHAR szKLID[KL_NAMELENGTH], szKeyPath[MAX_PATH], szSubstitute[KL_NAMELENGTH];
1064 WCHAR szLayoutFile[MAX_PATH], szLayoutId[16];
1065 HRESULT hr;
1066
1067 if (FAILED(StringCbCopyW(szKLID, sizeof(szKLID), pszKLID)) || !IsValidKLID(szKLID))
1068 return FALSE;
1069
1070 if (!wLangID)
1071 wLangID = (LANGID)wcstoul(pszKLID, NULL, 16);
1072
1073 /* Substitute pszKLID */
1074 if (*puFlags & KLF_SUBSTITUTE_OK)
1075 {
1076#if 1
1077 if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Substitutes", 0,
1079 {
1080 ZeroMemory(szSubstitute, sizeof(szSubstitute));
1081 cbData = sizeof(szSubstitute);
1082 error = RegQueryValueExW(hKey, pszKLID, NULL, &dwType,
1083 (PBYTE)szSubstitute, &cbData);
1085 if (error == ERROR_SUCCESS && dwType == REG_SZ)
1086 {
1087 szSubstitute[_countof(szSubstitute) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1088 if (!IsValidKLID(szSubstitute) ||
1089 FAILED(StringCchCopyW(pszKLID, cchKLID, szSubstitute)))
1090 {
1091 ERR("IsValidKLID(%s) failed\n", debugstr_w(szSubstitute));
1092 return FALSE;
1093 }
1094 }
1095 }
1096#else
1097 /* FIXME: Prepare keyboardlayout.ini and redirection */
1098 GetPrivateProfileStringW(L"Substitutes", pszKLID, pszKLID,
1099 szSubstitute, (DWORD)_countof(szSubstitute),
1100 L"keyboardlayout.ini");
1101 szSubstitute[_countof(szSubstitute) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1102 if (!IsValidKLID(szSubstitute) || FAILED(StringCchCopyW(pszKLID, cchKLID, szSubstitute)))
1103 return FALSE;
1104#endif
1105 }
1106
1107 /* Open 'Keyboard Layouts' registry key */
1108 dwKL = wcstoul(pszKLID, NULL, 16);
1109 hr = StringCbPrintfW(szKeyPath, sizeof(szKeyPath), KBDLAYOUTS_KEY L"\\%s", pszKLID);
1110 if (FAILED(hr))
1111 return FALSE;
1112
1114 if (error == ERROR_SUCCESS)
1115 {
1116 /* "Layout File" */
1117 cbData = sizeof(szLayoutFile);
1118 error = RegQueryValueExW(hKey, L"Layout File", NULL, &dwType, (PBYTE)szLayoutFile, &cbData);
1119 if (error == ERROR_SUCCESS && dwType == REG_SZ)
1120 {
1121 szLayoutFile[_countof(szLayoutFile) - 1] = UNICODE_NULL;
1122 pszSource = szLayoutFile;
1123 }
1124
1125 /* "Attributes" */
1126 cbData = sizeof(dwAttributes);
1127 error = RegQueryValueExW(hKey, L"Attributes", NULL, &dwType, (PBYTE)&dwAttributes, &cbData);
1128 if (error == ERROR_SUCCESS && dwType == REG_DWORD && cbData == sizeof(dwAttributes))
1129 *puFlags |= (dwAttributes & ATTR_MASK);
1130
1131 if (IS_IME_HKL(UlongToHandle(dwKL))) /* IME? */
1132 {
1133 dwKL = HIWORD(dwKL);
1134 }
1135 else if (HIWORD(dwKL))
1136 {
1137 /* "Layout ID" */
1138 cbData = sizeof(szLayoutId);
1139 error = RegQueryValueExW(hKey, L"Layout ID", NULL, &dwType, (PBYTE)szLayoutId, &cbData);
1140 if (error == ERROR_SUCCESS && dwType == REG_SZ)
1141 {
1142 szLayoutId[_countof(szLayoutId) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1143 dwKL = (wcstoul(szLayoutId, NULL, 16) & 0xFFF) | 0xF000;
1144 }
1145 else
1146 {
1147 dwKL = 0xFFFE; /* Invalid value */
1148 }
1149 }
1150
1152 }
1153 else
1154 {
1155 WARN("pszKLID %s not found!\n", debugstr_w(pszKLID));
1156
1157 /* Fallback to 'Keyboard Layout' */
1159 if (error == ERROR_SUCCESS)
1160 {
1161 cbData = sizeof(szLayoutFile);
1162 error = RegQueryValueExW(hKey, pszKLID, NULL, &dwType, (PBYTE)szLayoutFile, &cbData);
1163 if (error == ERROR_SUCCESS && dwType == REG_SZ)
1164 {
1165 szLayoutFile[_countof(szLayoutFile) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1166 pszSource = szLayoutFile;
1167 }
1169 }
1170 }
1171
1172 *pdwKL = MAKELONG(wLangID, (WORD)dwKL);
1173
1174 if (!pszSource) /* Layout not found in registry? */
1175 {
1176 WARN("Layout %s not found in registry\n", debugstr_w(pszKLID));
1177
1179 {
1180 pszSource = L"kbdus.dll";
1182 }
1183 else if (PRIMARYLANGID(wLangID) == LANG_JAPANESE)
1184 {
1185 pszSource = L"kbdjpn.dll";
1187 }
1188 else if (PRIMARYLANGID(wLangID) == LANG_KOREAN)
1189 {
1190 pszSource = L"kbdkor.dll";
1192 }
1193 else
1194 {
1195 pszSource = L"kbdus.dll";
1196 *pdwKL = MAKELONG(wLangID, wLangID);
1197 }
1198 }
1199
1200 return IntIsValidLayoutFileName(pszSource) &&
1201 SUCCEEDED(StringCchCopyW(pszDllName, cchDllName, pszSource));
1202}
#define ERR(fmt,...)
Definition: precomp.h:57
#define UlongToHandle(ul)
Definition: basetsd.h:91
#define LANGID_KOREAN
Definition: cjkcode.h:53
#define LANGID_JAPANESE
Definition: cjkcode.h:52
HRESULT hr
Definition: delayimp.cpp:582
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
unsigned short WORD
Definition: ntddk_ex.h:93
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:21
#define ZeroMemory
Definition: minwinbase.h:31
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
BYTE * PBYTE
Definition: pedump.c:66
#define KLF_SUBSTITUTE_OK
Definition: winuser.h:112
#define REG_DWORD
Definition: sdbapi.c:615
#define LANG_JAPANESE
Definition: nls.h:76
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_KOREAN
Definition: nls.h:84
char * pszDllName
Definition: spec2def.c:74
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
PCBYTE PBYTE SIZE_T cbData
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define MAKELONG(a, b)
Definition: typedefs.h:249
DWORD dwAttributes
Definition: vdmdbg.h:34
#define ATTR_MASK
Definition: input.c:39
static BOOL IntIsConsoleSession(void)
Definition: input.c:56
#define KBDLAYOUT_KEY
Definition: input.c:38
static BOOL IsValidKLID(_In_ LPCWSTR pwszKLID)
Definition: input.c:715
#define LANGID_ENGLISH_US
Definition: input.c:40
#define KBDLAYOUTS_KEY
Definition: input.c:37
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by IntLoadKeyboardLayoutFile().

◆ IntGetTableOffsets()

static BOOL IntGetTableOffsets ( _In_ HMODULE  hModule,
_In_ PFN_KbdLayerDescriptor  pfnMain,
_Out_ PULONG  poffTable 
)
static

Gets the 16-bit offsets of the tables, as NtUserLoadKeyboardLayoutEx expects them: LOWORD is the main table and HIWORD is the NLS table (0 if none).

Definition at line 916 of file input.c.

920{
922 INT_PTR MainOffset, NlsOffset = 0;
923
925 {
926 /* Get the main table offset */
927 MainOffset = (PBYTE)pfnMain() - (PBYTE)hModule;
928 if (MainOffset <= 0 || MainOffset > MAXWORD)
929 {
930 ERR("Invalid MainOffset: %p\n", (PVOID)MainOffset);
931 _SEH2_YIELD(return FALSE);
932 }
933
934 /* Get the NLS table offset */
936 if (pfnNls)
937 {
938 NlsOffset = (PBYTE)pfnNls() - (PBYTE)hModule;
939 if (NlsOffset <= 0 || NlsOffset > MAXWORD)
940 {
941 ERR("Invalid NlsOffset: %p\n", (PVOID)NlsOffset);
942 _SEH2_YIELD(return FALSE);
943 }
944 }
945
946 *poffTable = MAKELONG(MainOffset, NlsOffset);
947 _SEH2_YIELD(return TRUE);
948 }
950 {
951 ERR("Exception caught! Status: 0x%x\n", _SEH2_GetExceptionCode());
952 }
953 _SEH2_END;
954
955 return FALSE;
956}
HMODULE hModule
Definition: animate.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define MAXWORD
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
int32_t INT_PTR
Definition: typedefs.h:64
#define IFN_KbdNlsLayerDescriptor
Definition: input.c:44
PVOID(WINAPI * PFN_KbdNlsLayerDescriptor)(void)
Definition: input.c:51

Referenced by IntLoadKeyboardLayoutTablesAndFile().

◆ IntIsConsoleSession()

static BOOL IntIsConsoleSession ( void  )
static

Definition at line 56 of file input.c.

57{
58 return FALSE; /* FIXME */
59}

Referenced by IntGetKeyboardDllName(), and IntPrepareLayoutModule().

◆ IntIsValidLayoutFileName()

static BOOL IntIsValidLayoutFileName ( PCWSTR  pszFileName)
inlinestatic

Definition at line 720 of file input.c.

721{
722 if (!*pszFileName)
723 return FALSE;
724 SIZE_T cch = wcscspn(pszFileName, L"\\/:");
725 return (cch < MAX_LAYOUT_FILENAME && !pszFileName[cch]);
726}
_ACRTIMP size_t __cdecl wcscspn(const wchar_t *, const wchar_t *)
Definition: wcs.c:503
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by IntFollowRealDll(), IntGetKeyboardDllName(), and IntLoadKeyboardLayoutTablesAndFile().

◆ IntLoadKeyboardLayout()

static HKL IntLoadKeyboardLayout ( _In_opt_ HKL  hklUnload,
_In_ PCWSTR  pwszKLID,
_In_ LANGID  wLangID,
_In_ UINT  Flags,
_In_ BOOL  bForce 
)
static

Definition at line 1236 of file input.c.

1242{
1243 HANDLE hFile;
1244 WCHAR szKLID[KL_NAMELENGTH];
1245 KBDTABLE_MULTI_EX multi;
1246 DWORD offTable = 0, dwNewKL = 0, iTable;
1247 HKL hNewKL = NULL;
1248 UNICODE_STRING ustrKLID;
1249
1250 if (FAILED(StringCbCopyW(szKLID, sizeof(szKLID), pwszKLID)))
1251 return NULL;
1252
1253 /* Load keyboard layout file(s) */
1254 hFile = IntLoadKeyboardLayoutFile(szKLID, _countof(szKLID), wLangID,
1255 &Flags, &offTable, &dwNewKL, &multi);
1256 if (!hFile)
1257 {
1258 if (!bForce && !(Flags & KLF_FORCE))
1259 {
1260 ERR("Failed to IntLoadKeyboardLayoutFile\n");
1261 return NULL; /* Failure */
1262 }
1263
1264 /* Fallback to English */
1265 Flags &= ~KLF_SUBSTITUTE_OK;
1266 multi.Multi.nTables = 0;
1267 if (wcscmp(szKLID, L"00000409") != 0) /* Not English? Then retry with English */
1268 {
1269 StringCbCopyW(szKLID, sizeof(szKLID), L"00000409");
1270 hFile = IntLoadKeyboardLayoutFile(szKLID, _countof(szKLID), wLangID,
1271 &Flags, &offTable, &dwNewKL, NULL);
1272 }
1273 }
1274
1275 RtlInitUnicodeString(&ustrKLID, szKLID);
1276 hNewKL = NtUserLoadKeyboardLayoutEx(hFile, offTable, &multi, hklUnload,
1277 &ustrKLID, dwNewKL, Flags);
1278
1279 /* Close file handles, we own them: win32k duplicated them for its own purposes */
1280 if (hFile)
1282 for (iTable = 0; iTable < multi.Multi.nTables && iTable < KBDTABLE_MULTI_MAX; ++iTable)
1283 {
1284 HANDLE hAuxFile = multi.AuxEntries[iTable].hFile;
1285 if (hAuxFile)
1286 CloseHandle(hAuxFile);
1287 }
1288
1289 if (hNewKL)
1290 {
1291 /* Initialize the IME hot keys */
1293 }
1294
1295 return hNewKL;
1296}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
HKL NTAPI NtUserLoadKeyboardLayoutEx(_In_ HANDLE hFile, _In_ ULONG offTable, _In_opt_ PKBDTABLE_MULTI_EX pMulti, _In_opt_ HKL hOldKL, _In_ PUNICODE_STRING puszKLID, _In_ ULONG dwNewKL, _In_ UINT Flags)
Definition: kbdlayout.c:2129
_In_ HANDLE hFile
Definition: mswsock.h:90
HANDLE hFile
Definition: ntuser.h:114
KBDTABLE_MULTI_AUX_ENTRY AuxEntries[KBDTABLE_MULTI_MAX]
Definition: ntuser.h:124
KBDTABLE_MULTI Multi
Definition: ntuser.h:122
UINT nTables
Definition: kbd.h:203
VOID APIENTRY CliImmInitializeHotKeys(DWORD dwAction, HKL hKL)
Definition: input.c:433
#define KLF_FORCE
Definition: input.c:35
static HANDLE IntLoadKeyboardLayoutFile(_Inout_updates_z_(cchKLID) PWSTR pszKLID, _In_ SIZE_T cchKLID, _In_ DWORD wLangID, _Inout_ PUINT pFlags, _Out_ PULONG pOffTable, _Out_ PULONG pdwNewKL, _Out_opt_ PKBDTABLE_MULTI_EX pMulti)
Opens and loads keyboard layout file(s).
Definition: input.c:1208

Referenced by LoadKeyboardLayoutEx(), and LoadKeyboardLayoutW().

◆ IntLoadKeyboardLayoutFile()

static HANDLE IntLoadKeyboardLayoutFile ( _Inout_updates_z_(cchKLID) PWSTR  pszKLID,
_In_ SIZE_T  cchKLID,
_In_ DWORD  wLangID,
_Inout_ PUINT  pFlags,
_Out_ PULONG  pOffTable,
_Out_ PULONG  pdwNewKL,
_Out_opt_ PKBDTABLE_MULTI_EX  pMulti 
)
static

Opens and loads keyboard layout file(s).

Definition at line 1208 of file input.c.

1216{
1218
1219 if (pMulti)
1220 ZeroMemory(pMulti, sizeof(*pMulti));
1221
1223 cchKLID, wLangID, pFlags, pdwNewKL))
1224 {
1225 ERR("Failed in IntGetKeyboardDllName\n");
1226 return NULL;
1227 }
1228
1229 return IntLoadKeyboardLayoutTablesAndFile(szDllName, pszKLID, pFlags, pOffTable, pMulti);
1230}
static const WCHAR szDllName[]
Definition: system.c:43
static BOOL IntGetKeyboardDllName(_Out_writes_z_(cchDllName) PWSTR pszDllName, _In_ SIZE_T cchDllName, _Inout_updates_z_(cchKLID) PWSTR pszKLID, _In_ SIZE_T cchKLID, _In_ LANGID wLangID, _Inout_ PUINT puFlags, _Out_ PULONG pdwKL)
Definition: input.c:1051
static HANDLE IntLoadKeyboardLayoutTablesAndFile(_In_ PCWSTR pszLayoutFile, _In_opt_ PCWSTR pszKLID, _Inout_ PUINT puFlags, _Out_ PULONG poffTable, _Out_opt_ PKBDTABLE_MULTI_EX pMulti)
Returns a handle to the layout file, or NULL on failure. On success, the handles in pMulti (if any) s...
Definition: input.c:964

Referenced by IntLoadKeyboardLayout().

◆ IntLoadKeyboardLayoutTablesAndFile()

static HANDLE IntLoadKeyboardLayoutTablesAndFile ( _In_ PCWSTR  pszLayoutFile,
_In_opt_ PCWSTR  pszKLID,
_Inout_ PUINT  puFlags,
_Out_ PULONG  poffTable,
_Out_opt_ PKBDTABLE_MULTI_EX  pMulti 
)
static

Returns a handle to the layout file, or NULL on failure. On success, the handles in pMulti (if any) stay open for the caller; on failure, this function has closed them.

Definition at line 964 of file input.c.

970{
972 PCWSTR pszCurrentFile;
974 WCHAR szRealFile[MAX_LAYOUT_FILENAME], szFull[MAX_PATH];
975 DWORD cchFull;
977
978 TRACE("Loading layout file %s\n", debugstr_w(pszLayoutFile));
979 if (!IntIsValidLayoutFileName(pszLayoutFile))
980 {
981 ERR("Invalid layout filename: %s\n", debugstr_w(pszLayoutFile));
982 return NULL;
983 }
984
985 for (;;)
986 {
987 pszCurrentFile = pszLayoutFile;
988
989 /* Load the layout file */
990 hModule = LoadSysLibraryW(pszLayoutFile);
991 if (!hModule)
992 {
993 ERR("LoadSysLibraryW(%s) failed\n", debugstr_w(pszLayoutFile));
994 return NULL;
995 }
996
997 pfnMain = IntPrepareLayoutModule(&hModule, &pszCurrentFile, szRealFile,
998 pszKLID, puFlags, pMulti);
999 if (pfnMain)
1000 break; /* Success */
1001
1002 /* Otherwise, it's a failure. We leave this module either way (pszCurrentFile
1003 * does not point into it), so release it here; a retry loads a fresh one. */
1005 IntCloseAuxFiles(pMulti);
1006
1007 if ((*puFlags & KLF_INITTIME) && _wcsicmp(pszCurrentFile, L"kbdus.dll") != 0)
1008 {
1009 pszLayoutFile = L"kbdus.dll";
1010 continue; /* Retry with "kbdus.dll" */
1011 }
1012
1013 ERR("Invalid layout file: %s\n", debugstr_w(pszLayoutFile));
1014 return NULL; /* Failure */
1015 }
1016
1017 /* From here on, every failure goes to Failure */
1018 if (!IntGetTableOffsets(hModule, pfnMain, poffTable))
1019 goto Failure;
1020
1021 if (pMulti)
1022 StringCbCopyW(pMulti->szRealDllName, sizeof(pMulti->szRealDllName), pszCurrentFile);
1023
1024 TRACE("FileName:%s, *poffTable:0x%08X\n", debugstr_w(pszCurrentFile), *poffTable);
1025
1026 /* Get the full pathname of hModule */
1027 cchFull = GetModuleFileNameW(hModule, szFull, _countof(szFull));
1028 if (!cchFull || cchFull >= _countof(szFull))
1029 {
1030 ERR("GetModuleFileNameW failed\n");
1031 goto Failure;
1032 }
1033
1035 hModule = NULL;
1036
1039 return hFile; /* Success */
1040
1041 ERR("CreateFileW failed: %s\n", debugstr_w(szFull));
1042
1043Failure:
1044 if (hModule)
1046 IntCloseAuxFiles(pMulti);
1047 return NULL;
1048}
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
static BOOL IntGetTableOffsets(_In_ HMODULE hModule, _In_ PFN_KbdLayerDescriptor pfnMain, _Out_ PULONG poffTable)
Gets the 16-bit offsets of the tables, as NtUserLoadKeyboardLayoutEx expects them: LOWORD is the main...
Definition: input.c:916
static VOID IntCloseAuxFiles(_Inout_opt_ PKBDTABLE_MULTI_EX pMulti)
Closes the aux file handles that IntLoadKeyboardLayoutTablesAndFile stored in pMulti....
Definition: input.c:751
static PFN_KbdLayerDescriptor IntPrepareLayoutModule(_Inout_ HMODULE *phModule, _In_ _Outptr_ PCWSTR *ppszFile, _Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR pszRealFile, _In_opt_ PCWSTR pszKLID, _Inout_ PUINT puFlags, _Inout_opt_ PKBDTABLE_MULTI_EX pMulti)
Prepares a freshly loaded layout DLL: loads the multi-table, follows the "real" DLL,...
Definition: input.c:878
PVOID(WINAPI * PFN_KbdLayerDescriptor)(void)
Definition: input.c:50
#define KLF_INITTIME
Definition: input.c:34

Referenced by IntLoadKeyboardLayoutFile(), and IntLoadMultiTables().

◆ IntLoadMultiTables()

static VOID IntLoadMultiTables ( _In_ HMODULE  hModule,
_Inout_ PUINT  puFlags,
_Inout_ PKBDTABLE_MULTI_EX  pMulti 
)
static

Loads the multi-table (if any). Each aux table file is loaded by a recursive call, and its file handle and offset are stored in pMulti. The caller owns the handles: see IntCloseAuxFiles.

Definition at line 784 of file input.c.

788{
790 UINT iTable;
791
793 if (!pfnMulti || !pfnMulti(&pMulti->Multi))
794 return;
795
796 if (pMulti->Multi.nTables > KBDTABLE_MULTI_MAX)
797 pMulti->Multi.nTables = 0;
798
799 for (iTable = 0; iTable < pMulti->Multi.nTables; iTable++)
800 {
801 PKBDTABLE_DESC pDesc = &pMulti->Multi.aKbdTables[iTable];
802 ULONG offTable = 0;
803 HANDLE hAuxFile;
804
805 /* Avoid buffer overrun */
806 pDesc->wszDllName[_countof(pDesc->wszDllName) - 1] = UNICODE_NULL;
807
809 puFlags, &offTable, NULL);
810 pMulti->AuxEntries[iTable].hFile = hAuxFile; /* NULL if failed */
811 if (hAuxFile)
812 pMulti->AuxEntries[iTable].offTable = offTable;
813 }
814}
WCHAR wszDllName[32]
Definition: kbd.h:194
BOOL(WINAPI * PFN_KbdLayerMultiDescriptor)(PKBDTABLE_MULTI)
Definition: input.c:54
#define IFN_KbdLayerMultiDescriptor
Definition: input.c:47

Referenced by IntPrepareLayoutModule().

◆ IntLoadPreloadKeyboardLayouts()

VOID IntLoadPreloadKeyboardLayouts ( VOID  )

Definition at line 172 of file input.c.

173{
174 UINT nNumber, uFlags;
175 DWORD cbValue, dwType;
176 WCHAR szNumber[32], szValue[KL_NAMELENGTH];
177 HKEY hPreloadKey;
178 BOOL bOK = FALSE;
179 HKL hKL, hDefaultKL = NULL;
180
182 L"Keyboard Layout\\Preload",
183 &hPreloadKey) != ERROR_SUCCESS)
184 {
185 return;
186 }
187
188 for (nNumber = 1; nNumber <= 1000; ++nNumber)
189 {
190 _ultow(nNumber, szNumber, 10);
191
192 cbValue = sizeof(szValue);
193 if (RegQueryValueExW(hPreloadKey,
194 szNumber,
195 NULL,
196 &dwType,
197 (LPBYTE)szValue,
198 &cbValue) != ERROR_SUCCESS)
199 {
200 break;
201 }
202
203 if (dwType != REG_SZ)
204 continue;
205
206 if (nNumber == 1) /* The first entry is for default keyboard layout */
207 uFlags = KLF_SUBSTITUTE_OK | KLF_ACTIVATE | KLF_RESET;
208 else
210
211 hKL = LoadKeyboardLayoutW(szValue, uFlags);
212 if (hKL)
213 {
214 bOK = TRUE;
215 if (nNumber == 1) /* The first entry */
216 hDefaultKL = hKL;
217 }
218 }
219
220 RegCloseKey(hPreloadKey);
221
222 if (hDefaultKL)
223 SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &hDefaultKL, 0);
224
225 if (!bOK)
226 {
227 /* Fallback to English (US) */
228 LoadKeyboardLayoutW(L"00000409", KLF_SUBSTITUTE_OK | KLF_ACTIVATE | KLF_RESET);
229 }
230}
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
UINT uFlags
Definition: api.c:59
#define KLF_REPLACELANG
Definition: winuser.h:115
#define KLF_ACTIVATE
Definition: winuser.h:111
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define KLF_NOTELLSHELL
Definition: winuser.h:116
HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
Definition: input.c:1302

Referenced by UpdatePerUserSystemParameters().

◆ IntPrepareLayoutModule()

static PFN_KbdLayerDescriptor IntPrepareLayoutModule ( _Inout_ HMODULE *  phModule,
_In_ _Outptr_ PCWSTR *  ppszFile,
_Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR  pszRealFile,
_In_opt_ PCWSTR  pszKLID,
_Inout_ PUINT  puFlags,
_Inout_opt_ PKBDTABLE_MULTI_EX  pMulti 
)
static

Prepares a freshly loaded layout DLL: loads the multi-table, follows the "real" DLL, and gets KbdLayerDescriptor. Returns NULL on failure. The caller owns *phModule either way (it can be replaced by the real DLL). The layout DLL code can crash, so everything is under SEH.

Definition at line 878 of file input.c.

885{
887
889 {
890 if (_wcsicmp(*ppszFile, L"kbdus.dll") != 0) /* Not English US? */
891 {
892 if (pMulti && IntIsConsoleSession())
893 IntLoadMultiTables(*phModule, puFlags, pMulti);
894
895 IntFollowRealDll(phModule, ppszFile, pszRealFile, pszKLID);
896 }
897
898 /* Retrieve the KbdLayerDescriptor procedure */
900 }
902 {
903 ERR("Exception caught! Status: 0x%lx\n", _SEH2_GetExceptionCode());
904 }
905 _SEH2_END;
906
907 return pfnMain;
908}
#define IFN_KbdLayerDescriptor
Definition: input.c:43
static VOID IntFollowRealDll(_Inout_ HMODULE *phModule, _Outptr_ PCWSTR *ppszFile, _Out_writes_z_(MAX_LAYOUT_FILENAME) PWSTR pszRealFile, _In_opt_ PCWSTR pszKLID)
If the layout DLL redirects to a "real" DLL, loads that one instead and releases the original....
Definition: input.c:822
static VOID IntLoadMultiTables(_In_ HMODULE hModule, _Inout_ PUINT puFlags, _Inout_ PKBDTABLE_MULTI_EX pMulti)
Loads the multi-table (if any). Each aux table file is loaded by a recursive call,...
Definition: input.c:784

Referenced by IntLoadKeyboardLayoutTablesAndFile().

◆ IntSetFeKeyboardFlags()

VOID FASTCALL IntSetFeKeyboardFlags ( LANGID  LangID,
PBYTE  pbFlags 
)

Definition at line 96 of file input.c.

97{
98 switch (LangID)
99 {
101 *pbFlags |= FE_JAPANESE;
102 break;
103
106 *pbFlags |= FE_CHINESE_TRADITIONAL;
107 break;
108
111 *pbFlags |= FE_CHINESE_SIMPLIFIED;
112 break;
113
115 *pbFlags |= FE_KOREAN;
116 break;
117
118 default:
119 break;
120 }
121}
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_CHINESE_SINGAPORE
Definition: nls.h:211
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define SUBLANG_CHINESE_SIMPLIFIED
Definition: nls.h:209
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define SUBLANG_CHINESE_HONGKONG
Definition: nls.h:210
#define LANG_CHINESE
Definition: nls.h:42
#define SUBLANG_KOREAN
Definition: nls.h:280
#define FE_KOREAN
Definition: input.c:93

Referenced by CliGetPreloadKeyboardLayouts(), and CliImmInitializeHotKeys().

◆ IsValidKLID()

static BOOL IsValidKLID ( _In_ LPCWSTR  pwszKLID)
inlinestatic

Definition at line 715 of file input.c.

716{
717 return pwszKLID && (wcsspn(pwszKLID, L"0123456789ABCDEFabcdef") == (KL_NAMELENGTH - 1));
718}
_ACRTIMP size_t __cdecl wcsspn(const wchar_t *, const wchar_t *)
Definition: wcs.c:513

Referenced by IntGetKeyboardDllName().

◆ keybd_event()

VOID WINAPI keybd_event ( BYTE  bVk,
BYTE  bScan,
DWORD  dwFlags,
ULONG_PTR  dwExtraInfo 
)

Definition at line 1562 of file input.c.

1567{
1568 INPUT Input;
1569
1570 Input.type = INPUT_KEYBOARD;
1571 Input.ki.wVk = bVk;
1572 Input.ki.wScan = bScan;
1573 Input.ki.dwFlags = dwFlags;
1574 Input.ki.time = 0;
1575 Input.ki.dwExtraInfo = dwExtraInfo;
1576
1577 NtUserSendInput(1, &Input, sizeof(INPUT));
1578}
UINT NTAPI NtUserSendInput(UINT nInputs, LPINPUT pInput, INT cbSize)
Definition: input.c:972
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
_In_ ULONG _In_ WDFMEMORY Input
Definition: portacpi.cpp:109
#define INPUT_KEYBOARD
Definition: winable.h:10
BOOL bScan
Definition: wlanconf.c:22

◆ LoadKeyboardLayoutA()

HKL WINAPI LoadKeyboardLayoutA ( LPCSTR  pszKLID,
UINT  Flags 
)

Definition at line 701 of file input.c.

703{
704 WCHAR wszKLID[16];
705
706 if (!MultiByteToWideChar(CP_ACP, 0, pszKLID, -1,
707 wszKLID, sizeof(wszKLID)/sizeof(wszKLID[0])))
708 {
709 return FALSE;
710 }
711
712 return LoadKeyboardLayoutW(wszKLID, Flags);
713}
#define MultiByteToWideChar
Definition: compat.h:110

◆ LoadKeyboardLayoutEx()

HKL WINAPI LoadKeyboardLayoutEx ( _In_ HKL  hklUnload,
_In_ PCWSTR  pwszKLID,
_In_ UINT  Flags 
)

Definition at line 1313 of file input.c.

1317{
1318 TRACE("(%p, %s, 0x%X)", hklUnload, debugstr_w(pwszKLID), Flags);
1319
1320 if (!hklUnload)
1321 {
1322 ERR("hklUnload was NULL\n");
1323 return NULL;
1324 }
1325
1326 return IntLoadKeyboardLayout(hklUnload, pwszKLID, 0, Flags, FALSE);
1327}
static HKL IntLoadKeyboardLayout(_In_opt_ HKL hklUnload, _In_ PCWSTR pwszKLID, _In_ LANGID wLangID, _In_ UINT Flags, _In_ BOOL bForce)
Definition: input.c:1236

Referenced by init_function_pointers().

◆ LoadKeyboardLayoutW()

HKL WINAPI LoadKeyboardLayoutW ( LPCWSTR  pwszKLID,
UINT  Flags 
)

Definition at line 1302 of file input.c.

1304{
1305 TRACE("(%s, 0x%X)\n", debugstr_w(pwszKLID), Flags);
1306 return IntLoadKeyboardLayout(NULL, pwszKLID, 0, Flags, FALSE);
1307}

◆ LoadSysLibraryW()

static HMODULE LoadSysLibraryW ( PCWSTR  pszFileName)
static

Definition at line 737 of file input.c.

738{
741 return NULL;
742 return LoadLibraryW(szPath);
743}
#define LoadLibraryW(x)
Definition: compat.h:747
LPCWSTR szPath
Definition: env.c:37
BOOL GetSystemLibraryPath(PWSTR pszPath, SIZE_T cchPath, PCWSTR pszFileName)
Definition: input.c:728

Referenced by IntFollowRealDll(), and IntLoadKeyboardLayoutTablesAndFile().

◆ MapVirtualKeyA()

UINT WINAPI MapVirtualKeyA ( UINT  uCode,
UINT  uMapType 
)

Definition at line 1345 of file input.c.

1347{
1348 return MapVirtualKeyExA(uCode, uMapType, GetKeyboardLayout(0));
1349}
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
UINT WINAPI MapVirtualKeyExA(_In_ UINT, _In_ UINT, _In_opt_ HKL)

◆ MapVirtualKeyExA()

UINT WINAPI MapVirtualKeyExA ( UINT  uCode,
UINT  uMapType,
HKL  dwhkl 
)

Definition at line 1355 of file input.c.

1358{
1359 return MapVirtualKeyExW(uCode, uMapType, dwhkl);
1360}
UINT WINAPI MapVirtualKeyExW(_In_ UINT, _In_ UINT, _In_opt_ HKL)

◆ MapVirtualKeyExW()

UINT WINAPI MapVirtualKeyExW ( UINT  uCode,
UINT  uMapType,
HKL  dwhkl 
)

Definition at line 1367 of file input.c.

1370{
1371 return NtUserMapVirtualKeyEx(uCode, uMapType, 0, dwhkl);
1372}
UINT NTAPI NtUserMapVirtualKeyEx(UINT keyCode, UINT transType, DWORD keyboardId, HKL dwhkl)
Definition: keyboard.c:1751

◆ MapVirtualKeyW()

UINT WINAPI MapVirtualKeyW ( UINT  uCode,
UINT  uMapType 
)

Definition at line 1379 of file input.c.

1381{
1382 return MapVirtualKeyExW(uCode, uMapType, GetKeyboardLayout(0));
1383}

◆ mouse_event()

VOID WINAPI mouse_event ( DWORD  dwFlags,
DWORD  dx,
DWORD  dy,
DWORD  dwData,
ULONG_PTR  dwExtraInfo 
)

Definition at line 1586 of file input.c.

1592{
1593 INPUT Input;
1594
1595 Input.type = INPUT_MOUSE;
1596 Input.mi.dx = dx;
1597 Input.mi.dy = dy;
1598 Input.mi.mouseData = dwData;
1599 Input.mi.dwFlags = dwFlags;
1600 Input.mi.time = 0;
1601 Input.mi.dwExtraInfo = dwExtraInfo;
1602
1603 NtUserSendInput(1, &Input, sizeof(INPUT));
1604}
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
#define INPUT_MOUSE
Definition: winable.h:9

◆ OemKeyScan()

DWORD WINAPI OemKeyScan ( WORD  wOemChar)

Definition at line 1390 of file input.c.

1391{
1392 WCHAR p;
1393 SHORT Vk;
1394 UINT Scan;
1395
1396 MultiByteToWideChar(CP_OEMCP, 0, (PCSTR)&wOemChar, 1, &p, 1);
1397 Vk = VkKeyScanW(p);
1398 Scan = MapVirtualKeyW((Vk & 0x00ff), 0);
1399 if (!Scan) return -1;
1400 /*
1401 Page 450-1, MS W2k SuperBible by SAMS. Return, low word has the
1402 scan code and high word has the shift state.
1403 */
1404 return ((Vk & 0xff00) << 8) | Scan;
1405}
GLfloat GLfloat p
Definition: glext.h:8902
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
SHORT WINAPI VkKeyScanW(_In_ WCHAR)
const char * PCSTR
Definition: typedefs.h:52
#define CP_OEMCP
Definition: winnls.h:259

◆ SetDoubleClickTime()

BOOL WINAPI SetDoubleClickTime ( UINT  uInterval)

Definition at line 1412 of file input.c.

1413{
1415 uInterval,
1416 NULL,
1417 0);
1418}
BOOL NTAPI NtUserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2208
#define SPI_SETDOUBLECLICKTIME
Definition: winuser.h:1392

◆ SwapMouseButton()

BOOL WINAPI SwapMouseButton ( BOOL  fSwap)

Definition at line 1426 of file input.c.

1428{
1429 return NtUserxSwapMouseButton(fSwap);
1430}
EXTINLINE BOOL NtUserxSwapMouseButton(BOOL fSwap)
Definition: ntwrapper.h:596

◆ ToAscii()

int WINAPI ToAscii ( UINT  uVirtKey,
UINT  uScanCode,
CONST BYTE *  lpKeyState,
LPWORD  lpChar,
UINT  uFlags 
)

Definition at line 1437 of file input.c.

1442{
1443 return ToAsciiEx(uVirtKey, uScanCode, lpKeyState, lpChar, uFlags, 0);
1444}
int WINAPI ToAsciiEx(_In_ UINT, _In_ UINT, _In_reads_opt_(256) CONST BYTE *, _Out_ LPWORD, _In_ UINT, _In_opt_ HKL)

◆ ToAsciiEx()

int WINAPI ToAsciiEx ( UINT  uVirtKey,
UINT  uScanCode,
CONST BYTE *  lpKeyState,
LPWORD  lpChar,
UINT  uFlags,
HKL  dwhkl 
)

Definition at line 1451 of file input.c.

1457{
1458 WCHAR UniChars[2];
1459 int Ret, CharCount;
1460
1461 Ret = ToUnicodeEx(uVirtKey, uScanCode, lpKeyState, UniChars, 2, uFlags, dwhkl);
1462 CharCount = (Ret < 0 ? 1 : Ret);
1463 WideCharToMultiByte(CP_ACP, 0, UniChars, CharCount, (LPSTR)lpChar, 2, NULL, NULL);
1464
1465 return Ret;
1466}
int WINAPI ToUnicodeEx(_In_ UINT wVirtKey, _In_ UINT wScanCode, _In_reads_bytes_(256) CONST BYTE *lpKeyState, _Out_writes_(cchBuff) LPWSTR pwszBuff, _In_ int cchBuff, _In_ UINT wFlags, _In_opt_ HKL dwhkl)
char * LPSTR
Definition: typedefs.h:51

◆ ToUnicode()

int WINAPI ToUnicode ( UINT  wVirtKey,
UINT  wScanCode,
CONST BYTE *  lpKeyState,
LPWSTR  pwszBuff,
int  cchBuff,
UINT  wFlags 
)

Definition at line 1473 of file input.c.

1479{
1480 return ToUnicodeEx(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff,
1481 wFlags, 0);
1482}
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337

◆ ToUnicodeEx()

int WINAPI ToUnicodeEx ( UINT  wVirtKey,
UINT  wScanCode,
CONST BYTE *  lpKeyState,
LPWSTR  pwszBuff,
int  cchBuff,
UINT  wFlags,
HKL  dwhkl 
)

Definition at line 1489 of file input.c.

1496{
1497 return NtUserToUnicodeEx(wVirtKey, wScanCode, (PBYTE)lpKeyState, pwszBuff, cchBuff,
1498 wFlags, dwhkl);
1499}
INT NTAPI NtUserToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, HKL dwhkl)

◆ UnloadKeyboardLayout()

BOOL WINAPI UnloadKeyboardLayout ( HKL  hKL)

Definition at line 1332 of file input.c.

1333{
1335 return FALSE;
1336
1338 return TRUE;
1339}
BOOL NTAPI NtUserUnloadKeyboardLayout(HKL hKl)
Definition: kbdlayout.c:2255

◆ VkKeyScanA()

SHORT WINAPI VkKeyScanA ( CHAR  ch)

Definition at line 1507 of file input.c.

1508{
1509 WCHAR wChar;
1510
1511 if (IsDBCSLeadByte(ch))
1512 return -1;
1513
1514 MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1);
1515 return VkKeyScanW(wChar);
1516}
BOOL WINAPI IsDBCSLeadByte(BYTE testchar)
Definition: locale.c:2126
unsigned char ch[4][2]
Definition: console.c:118

◆ VkKeyScanExA()

SHORT WINAPI VkKeyScanExA ( CHAR  ch,
HKL  dwhkl 
)

Definition at line 1523 of file input.c.

1525{
1526 WCHAR wChar;
1527
1528 if (IsDBCSLeadByte(ch))
1529 return -1;
1530
1531 MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1);
1532 return VkKeyScanExW(wChar, dwhkl);
1533}
SHORT WINAPI VkKeyScanExW(WCHAR ch, HKL dwhkl)
Definition: input.c:1540

◆ VkKeyScanExW()

SHORT WINAPI VkKeyScanExW ( WCHAR  ch,
HKL  dwhkl 
)

Definition at line 1540 of file input.c.

1542{
1543 return (SHORT)NtUserVkKeyScanEx(ch, dwhkl, TRUE);
1544}
DWORD NTAPI NtUserVkKeyScanEx(WCHAR wChar, HKL KeyboardLayout, BOOL bUsehHK)
Definition: keyboard.c:2021

Referenced by VkKeyScanExA().

◆ VkKeyScanW()

SHORT WINAPI VkKeyScanW ( WCHAR  ch)

Definition at line 1551 of file input.c.

1552{
1553 return (SHORT)NtUserVkKeyScanEx(ch, 0, FALSE);
1554}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )

Variable Documentation

◆ DefaultHotKeyTableC

IMEHOTKEYENTRY DefaultHotKeyTableC[]
Initial value:
=
{
}
#define IME_CHOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:195
#define MOD_SHIFT
Definition: imm.h:186
#define MOD_CONTROL
Definition: imm.h:185
#define IME_CHOTKEY_SHAPE_TOGGLE
Definition: imm.h:196
#define VK_SPACE
Definition: winuser.h:2255

Definition at line 83 of file input.c.

Referenced by CliImmInitializeHotKeys().

◆ DefaultHotKeyTableJ

IMEHOTKEYENTRY DefaultHotKeyTableJ[]
Initial value:
=
{
}
#define IME_JHOTKEY_CLOSE_OPEN
Definition: imm.h:200
#define MOD_IGNORE_ALL_MODIFIER
Definition: imm.h:192
#define VK_KANJI
Definition: winuser.h:2249

Definition at line 70 of file input.c.

Referenced by CliImmInitializeHotKeys().

◆ DefaultHotKeyTableT

IMEHOTKEYENTRY DefaultHotKeyTableT[]
Initial value:

Definition at line 76 of file input.c.

Referenced by CliImmInitializeHotKeys().