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

Go to the source code of this file.

Macros

#define LAST_RIT_EVENT_UPDATE_INTERVAL   1000UL
 
#define CLAMP(v, lo, hi)   ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v))
 

Functions

 DBG_DEFAULT_CHANNEL (UserInput)
 
static VOID NTAPI RITReadApc (_In_ PVOID ApcContext, _In_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG Reserved)
 
static DWORD FASTCALL IntLastInputTick (BOOL bUpdate)
 
VOID FASTCALL DoTheScreenSaver (VOID)
 
static PINPUT_DEVICE_INFO CreateInputDevice (_In_ UCHAR DeviceType, _In_ PUNICODE_STRING DeviceName)
 
static NTSTATUS NTAPI OpenInputDevice (_In_ PINPUT_DEVICE_INFO DeviceInfo)
 
static VOID CloseInputDevice (_In_ PINPUT_DEVICE_INFO DeviceInfo)
 
static VOID StartReadInputDevice (_In_ PINPUT_DEVICE_INFO DeviceInfo)
 
static VOID ProcessDeviceChanges (VOID)
 
static VOID ProcessKeyboardUpdates (VOID)
 
VOID NTAPI RawInputThreadMain (VOID)
 
NTSTATUS NTAPI InitInputImpl (VOID)
 
BOOL FASTCALL IntBlockInput (PTHREADINFO pti, BOOL BlockIt)
 
BOOL APIENTRY NtUserBlockInput (BOOL BlockIt)
 
BOOL FASTCALL IsRemoveAttachThread (PTHREADINFO pti)
 
NTSTATUS FASTCALL UserAttachThreadInput (PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
 
BOOL APIENTRY NtUserAttachThreadInput (IN DWORD idAttach, IN DWORD idAttachTo, IN BOOL fAttach)
 
UINT APIENTRY NtUserSendInput (UINT nInputs, LPINPUT pInput, INT cbSize)
 

Variables

PTHREADINFO ptiRawInput
 
PKTIMER MasterTimer = NULL
 
PATTACHINFO gpai = NULL
 
INT paiCount = 0
 
LONG gKeyboardFlags
 
PKEVENT gKeyboardUpdatesEvent
 
PINPUT_DEVICE_INFO gpInputDeviceInfo = NULL
 
PERESOURCE gpDeviceInfoListMutex = NULL
 
static DWORD gNumberOfKeyboards = 0
 
static DWORD LastInputTick = 0
 
static PKEVENT gDeviceListChangedEvent
 

Macro Definition Documentation

◆ CLAMP

#define CLAMP (   v,
  lo,
  hi 
)    ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v))

◆ LAST_RIT_EVENT_UPDATE_INTERVAL

#define LAST_RIT_EVENT_UPDATE_INTERVAL   1000UL

Definition at line 17 of file input.c.

Function Documentation

◆ CloseInputDevice()

static VOID CloseInputDevice ( _In_ PINPUT_DEVICE_INFO  DeviceInfo)
static

Definition at line 217 of file input.c.

219{
220 ASSERT(DeviceInfo->Handle);
221 (void)ZwCancelIoFile(DeviceInfo->Handle, &DeviceInfo->Iosb);
223}
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwCancelIoFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3411

Referenced by RawInputThreadMain().

◆ CreateInputDevice()

static PINPUT_DEVICE_INFO CreateInputDevice ( _In_ UCHAR  DeviceType,
_In_ PUNICODE_STRING  DeviceName 
)
static

Definition at line 116 of file input.c.

119{
121
123 if (!DeviceInfo)
124 {
125 ERR("Failed to allocate memory for INPUT_DEVICE_INFO\n");
126 return NULL;
127 }
128
130 DeviceInfo->DeviceType = DeviceType;
131 DeviceInfo->DeviceName.Buffer = (PWCH)(DeviceInfo + 1);
132 DeviceInfo->DeviceName.MaximumLength = DeviceName->Length + sizeof(UNICODE_NULL);
134
136 DeviceInfo->pNextDeviceInfo = gpInputDeviceInfo;
139
141 return DeviceInfo;
142}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define PagedPool
Definition: env_spec_w32.h:308
DeviceType
Definition: mmdrv.h:42
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
WCHAR * PWCH
Definition: ntbasedef.h:422
#define UNICODE_NULL
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
static PKEVENT gDeviceListChangedEvent
Definition: input.c:40
PINPUT_DEVICE_INFO gpInputDeviceInfo
Definition: input.c:35
FORCEINLINE VOID ReleaseDeviceInfoListMutex(VOID)
Definition: input.h:158
FORCEINLINE VOID AcquireDeviceInfoListMutex(VOID)
Definition: input.h:150
#define USERTAG_PNP
Definition: tags.h:264
#define EVENT_INCREMENT
Definition: iotypes.h:597

Referenced by RawInputThreadMain().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserInput  )

◆ DoTheScreenSaver()

VOID FASTCALL DoTheScreenSaver ( VOID  )

Definition at line 75 of file input.c.

76{
77 DWORD Test, TO;
78
79 if (gspv.iScrSaverTimeout > 0) // Zero means Off.
80 {
83 TO = 1000 * gspv.iScrSaverTimeout;
84 if (Test > TO)
85 {
86 TRACE("Screensaver Message Start! Tick %lu Timeout %d \n", Test, gspv.iScrSaverTimeout);
87
88 if (ppiScrnSaver) // We are or we are not the screensaver, prevent reentry...
89 {
90 if (!(ppiScrnSaver->W32PF_flags & W32PF_IDLESCREENSAVER))
91 {
92 ppiScrnSaver->W32PF_flags |= W32PF_IDLESCREENSAVER;
93 ERR("Screensaver is Idle\n");
94 }
95 }
96 else
97 {
99 if (ForegroundQueue && ForegroundQueue->spwndActive)
100 UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_START_SCREENSAVE, 1); // lParam 1 == Secure
101 else
103 }
104 }
105 }
106}
#define EngGetTickCount32()
Definition: eng.h:43
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND hwndSAS
Definition: winsta.c:24
#define TRACE(s)
Definition: solgame.cpp:4
INT iScrSaverTimeout
Definition: sysparams.h:110
#define WM_LOGONNOTIFY
Definition: undocuser.h:39
#define LN_START_SCREENSAVE
Definition: undocuser.h:122
#define W32PF_IDLESCREENSAVER
Definition: win32.h:27
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1335
static DWORD LastInputTick
Definition: input.c:39
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1397
SPIVALUES gspv
Definition: sysparams.c:17

Referenced by HungAppSysTimerProc().

◆ InitInputImpl()

NTSTATUS NTAPI InitInputImpl ( VOID  )

Definition at line 625 of file input.c.

626{
628 if (!MasterTimer)
629 {
630 ERR("Failed to allocate memory\n");
631 ASSERT(FALSE);
632 return STATUS_UNSUCCESSFUL;
633 }
635
636 return STATUS_SUCCESS;
637}
#define NonPagedPool
Definition: env_spec_w32.h:307
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PKTIMER MasterTimer
Definition: input.c:30
#define USERTAG_SYSTEM
Definition: tags.h:282

Referenced by DriverEntry().

◆ IntBlockInput()

BOOL FASTCALL IntBlockInput ( PTHREADINFO  pti,
BOOL  BlockIt 
)

Definition at line 640 of file input.c.

641{
642 PTHREADINFO OldBlock;
643 ASSERT(pti);
644
645 if(!pti->rpdesk || ((pti->TIF_flags & TIF_INCLEANUP) && BlockIt))
646 {
647 /*
648 * Fail blocking if exiting the thread
649 */
650
651 return FALSE;
652 }
653
654 /*
655 * FIXME: Check access rights of the window station
656 * e.g. services running in the service window station cannot block input
657 */
658 if(!ThreadHasInputAccess(pti) ||
660 {
662 return FALSE;
663 }
664
665 ASSERT(pti->rpdesk);
666 OldBlock = pti->rpdesk->BlockInputThread;
667 if(OldBlock)
668 {
669 if(OldBlock != pti)
670 {
672 return FALSE;
673 }
674 pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
675 return OldBlock == NULL;
676 }
677
678 pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
679 return OldBlock == NULL;
680}
#define IntIsActiveDesktop(Desktop)
Definition: desktop.h:174
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define TIF_INCLEANUP
Definition: ntuser.h:290
FLONG TIF_flags
Definition: win32.h:96
struct _DESKTOP * rpdesk
Definition: win32.h:93
#define ThreadHasInputAccess(W32Thread)
Definition: input.h:93
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21

Referenced by ExitThreadCallback(), and NtUserBlockInput().

◆ IntLastInputTick()

static DWORD FASTCALL IntLastInputTick ( BOOL  bUpdate)
static

Definition at line 50 of file input.c.

51{
52 if (bUpdate)
53 {
55 if (gpsi)
56 {
57 gpsi->dwLastRITEventTickCount = LastInputTick;
58 if (gpsi->dwLastRITEventTickCount - gpsi->dwLastSystemRITEventTickCountUpdate >
60 {
61 SharedUserData->LastSystemRITEventTickCount = LastInputTick;
62 gpsi->dwLastSystemRITEventTickCountUpdate = LastInputTick;
63 }
64 }
65 }
66 return LastInputTick;
67}
PSERVERINFO gpsi
Definition: imm.c:18
#define SharedUserData
#define LAST_RIT_EVENT_UPDATE_INTERVAL
Definition: input.c:17

Referenced by RITReadApc().

◆ IsRemoveAttachThread()

BOOL FASTCALL IsRemoveAttachThread ( PTHREADINFO  pti)

Definition at line 702 of file input.c.

703{
705 PATTACHINFO pai;
706 BOOL Ret = TRUE;
707 PTHREADINFO ptiFrom = NULL, ptiTo = NULL;
708
709 do
710 {
711 if (!gpai) return TRUE;
712
713 pai = gpai; // Bottom of the list.
714
715 do
716 {
717 if (pai->pti2 == pti)
718 {
719 ptiFrom = pai->pti1;
720 ptiTo = pti;
721 break;
722 }
723 if (pai->pti1 == pti)
724 {
725 ptiFrom = pti;
726 ptiTo = pai->pti2;
727 break;
728 }
729 pai = pai->paiNext;
730
731 } while (pai);
732
733 if (!pai && !ptiFrom && !ptiTo) break;
734
735 Status = UserAttachThreadInput(ptiFrom, ptiTo, FALSE);
736 if (!NT_SUCCESS(Status)) Ret = FALSE;
737
738 } while (Ret);
739
740 return Ret;
741}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:24
PTHREADINFO pti2
Definition: input.h:36
struct _ATTACHINFO * paiNext
Definition: input.h:34
PTHREADINFO pti1
Definition: input.h:35
PATTACHINFO gpai
Definition: input.c:31
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:744

Referenced by ExitThreadCallback().

◆ NtUserAttachThreadInput()

BOOL APIENTRY NtUserAttachThreadInput ( IN DWORD  idAttach,
IN DWORD  idAttachTo,
IN BOOL  fAttach 
)

Definition at line 929 of file input.c.

933{
935 PTHREADINFO pti, ptiTo;
936 BOOL Ret = FALSE;
937
939 TRACE("Enter NtUserAttachThreadInput %s\n",(fAttach ? "TRUE" : "FALSE" ));
940
941 pti = IntTID2PTI(UlongToHandle(idAttach));
942 ptiTo = IntTID2PTI(UlongToHandle(idAttachTo));
943
944 if ( !pti || !ptiTo )
945 {
946 TRACE("AttachThreadInput pti or ptiTo NULL.\n");
948 goto Exit;
949 }
950
951 Status = UserAttachThreadInput( pti, ptiTo, fAttach);
952 if (!NT_SUCCESS(Status))
953 {
954 TRACE("AttachThreadInput Error Status 0x%x. \n",Status);
956 }
957 else Ret = TRUE;
958
959Exit:
960 TRACE("Leave NtUserAttachThreadInput, ret=%d\n",Ret);
961 UserLeave();
962 return Ret;
963}
#define UlongToHandle(ul)
Definition: basetsd.h:91
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
static void Exit(void)
Definition: sock.c:1330
PTHREADINFO FASTCALL IntTID2PTI(HANDLE id)
Definition: misc.c:41
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

◆ NtUserBlockInput()

BOOL APIENTRY NtUserBlockInput ( BOOL  BlockIt)

Definition at line 684 of file input.c.

686{
687 BOOL ret;
688
689 TRACE("Enter NtUserBlockInput\n");
691
693
694 UserLeave();
695 TRACE("Leave NtUserBlockInput, ret=%i\n", ret);
696
697 return ret;
698}
return ret
Definition: mutex.c:147
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:829
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:640

Referenced by BlockInput().

◆ NtUserSendInput()

UINT APIENTRY NtUserSendInput ( UINT  nInputs,
LPINPUT  pInput,
INT  cbSize 
)

Definition at line 972 of file input.c.

976{
977 PTHREADINFO pti;
978 UINT uRet = 0;
979
980 TRACE("Enter NtUserSendInput\n");
982
984 ASSERT(pti);
985
986 if (!pti->rpdesk)
987 {
988 goto cleanup;
989 }
990
991 if (!nInputs || !pInput || cbSize != sizeof(INPUT))
992 {
994 goto cleanup;
995 }
996
997 /*
998 * FIXME: Check access rights of the window station
999 * e.g. services running in the service window station cannot block input
1000 */
1001 if (!ThreadHasInputAccess(pti) ||
1003 {
1005 goto cleanup;
1006 }
1007
1008 while (nInputs--)
1009 {
1010 INPUT SafeInput;
1012
1013 Status = MmCopyFromCaller(&SafeInput, pInput++, sizeof(INPUT));
1014 if (!NT_SUCCESS(Status))
1015 {
1017 goto cleanup;
1018 }
1019
1020 switch (SafeInput.type)
1021 {
1022 case INPUT_MOUSE:
1023 if (UserSendMouseInput(&SafeInput.mi, TRUE))
1024 uRet++;
1025 break;
1026 case INPUT_KEYBOARD:
1027 if (UserSendKeyboardInput(&SafeInput.ki, TRUE))
1028 uRet++;
1029 break;
1030 case INPUT_HARDWARE:
1031 FIXME("INPUT_HARDWARE not supported!\n");
1032 break;
1033 default:
1034 ERR("SendInput(): Invalid input type: 0x%x\n", SafeInput.type);
1035 break;
1036 }
1037 }
1038
1039cleanup:
1040 TRACE("Leave NtUserSendInput, ret=%u\n", uRet);
1041 UserLeave();
1042 return uRet;
1043}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void cleanup(void)
Definition: main.c:1335
unsigned int UINT
Definition: sysinfo.c:13
#define MmCopyFromCaller
Definition: polytest.cpp:29
KEYBDINPUT ki
Definition: winable.h:62
DWORD type
Definition: winable.h:59
MOUSEINPUT mi
Definition: winable.h:61
UINT32 cbSize
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30
BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
Definition: keyboard.c:1358
BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected)
Definition: mouse.c:235
#define INPUT_HARDWARE
Definition: winable.h:11
#define INPUT_KEYBOARD
Definition: winable.h:10
#define INPUT_MOUSE
Definition: winable.h:9

Referenced by keybd_event(), mouse_event(), and SendInput().

◆ OpenInputDevice()

static NTSTATUS NTAPI OpenInputDevice ( _In_ PINPUT_DEVICE_INFO  DeviceInfo)
static

Definition at line 151 of file input.c.

153{
157
159 &DeviceInfo->DeviceName,
161 NULL,
162 NULL);
163
164 Status = ZwOpenFile(&DeviceInfo->Handle,
167 &Iosb,
168 0,
169 0);
170 if (!NT_SUCCESS(Status))
171 {
172 ERR("ZwOpenFile('%wZ') failed with status 0x%08x\n", &DeviceInfo->DeviceName, Status);
173 return Status;
174 }
175
176 if (DeviceInfo->DeviceType == RIM_TYPEKEYBOARD)
177 {
179 NULL,
180 NULL,
181 NULL,
182 &DeviceInfo->Iosb,
184 NULL, 0,
185 &DeviceInfo->Keyboard.Attributes,
186 sizeof(DeviceInfo->Keyboard.Attributes));
187 if (!NT_SUCCESS(Status))
188 {
189 ERR("ZwDeviceIoControlFile('%wZ', IOCTL_KEYBOARD_QUERY_ATTRIBUTES) failed with status 0x%08x\n", &DeviceInfo->DeviceName, Status);
190 }
194 }
195 else if (DeviceInfo->DeviceType == RIM_TYPEMOUSE)
196 {
198 NULL,
199 NULL,
200 NULL,
201 &DeviceInfo->Iosb,
203 NULL, 0,
204 &DeviceInfo->Mouse.Attributes,
205 sizeof(DeviceInfo->Mouse.Attributes));
206 if (!NT_SUCCESS(Status))
207 {
208 ERR("ZwDeviceIoControlFile('%wZ', IOCTL_MOUSE_QUERY_ATTRIBUTES) failed with status 0x%08x\n", &DeviceInfo->DeviceName, Status);
209 }
210 }
211
212 return STATUS_SUCCESS;
213}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
return Iosb
Definition: create.c:4403
#define InterlockedOr
Definition: interlocked.h:239
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
Definition: ntddkbd.h:32
#define IOCTL_MOUSE_QUERY_ATTRIBUTES
Definition: ntddmou.h:32
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)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
LONG gKeyboardFlags
Definition: input.c:33
PKEVENT gKeyboardUpdatesEvent
Definition: input.c:34
VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice)
Definition: keyboard.c:243
#define KBD_UPDATE_TYPEMATIC
Definition: input.h:140
#define KBD_UPDATE_LEDS
Definition: input.h:139
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by ProcessDeviceChanges().

◆ ProcessDeviceChanges()

static VOID ProcessDeviceChanges ( VOID  )
static

Definition at line 305 of file input.c.

307{
310 DWORD PreviousNumberOfKeyboards = gNumberOfKeyboards;
311 DWORD NumberOfKeyboards = 0;
312 DWORD NumberOfMice = 0;
313 DWORD MaxNumberOfButtons = 0;
314 BOOL HasMouseWheel = FALSE;
315#if (_WIN32_WINNT >= 0x0600)
316 BOOL HasHorizontalMouseWheel = FALSE;
317#endif
318 DWORD MaxFunctionKeys = 0;
319
321 for (DeviceInfo = gpInputDeviceInfo; DeviceInfo; DeviceInfo = DeviceInfo->pNextDeviceInfo)
322 {
323 if (!DeviceInfo->Handle)
324 {
326 if (NT_SUCCESS(Status))
327 {
328 if (DeviceInfo->DeviceType == RIM_TYPEKEYBOARD)
329 {
330 TRACE("Keyboard connected!\n");
331 }
332 else if (DeviceInfo->DeviceType == RIM_TYPEMOUSE)
333 {
334 TRACE("Mouse connected!\n");
335 }
337 }
338 }
339
340 if (DeviceInfo->DeviceType == RIM_TYPEKEYBOARD)
341 {
342 NumberOfKeyboards++;
343
344 if (DeviceInfo->Keyboard.Attributes.KeyboardIdentifier.Type == 4 /* Enhanced 101- or 102-key keyboard */ ||
345 DeviceInfo->Keyboard.Attributes.KeyboardIdentifier.Type == 7 /* Japanese keyboard */ ||
346 DeviceInfo->Keyboard.Attributes.KeyboardIdentifier.Type == 8 /* Korean keyboard */)
347 {
348 DWORD FunctionKeys = DeviceInfo->Keyboard.Attributes.NumberOfFunctionKeys;
349 /* Keep current keyboard description */
350 gKeyboardInfo = DeviceInfo->Keyboard.Attributes;
351 if (FunctionKeys > MaxFunctionKeys)
352 MaxFunctionKeys = FunctionKeys;
353 }
354 }
355 else if (DeviceInfo->DeviceType == RIM_TYPEMOUSE)
356 {
357 DWORD MouseIdentifier = DeviceInfo->Mouse.Attributes.MouseIdentifier & ~HORIZONTAL_WHEEL_PRESENT;
358 DWORD NumberOfButtons = DeviceInfo->Mouse.Attributes.NumberOfButtons;
359
360 NumberOfMice++;
361 if (NumberOfButtons > MaxNumberOfButtons)
362 MaxNumberOfButtons = NumberOfButtons;
363 HasMouseWheel |= MouseIdentifier == WHEELMOUSE_I8042_HARDWARE
364 || MouseIdentifier == WHEELMOUSE_SERIAL_HARDWARE
365 || MouseIdentifier == WHEELMOUSE_HID_HARDWARE;
366#if (_WIN32_WINNT >= 0x0600)
367 HasHorizontalMouseWheel |= DeviceInfo->Mouse.Attributes.MouseIdentifier & HORIZONTAL_WHEEL_PRESENT;
368#endif
369 }
370 }
372
373 /* Update metrics */
374 gpsi->aiSysMet[SM_MOUSEPRESENT] = NumberOfMice > 0 ? 1 : 0;
375 gpsi->aiSysMet[SM_CMOUSEBUTTONS] = MaxNumberOfButtons;
376 gpsi->aiSysMet[SM_MOUSEWHEELPRESENT] = HasMouseWheel ? 1 : 0;
377#if (_WIN32_WINNT >= 0x0600)
378 gpsi->aiSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = HasHorizontalMouseWheel ? 1 : 0;
379#endif
380 /* FIXME: show/hide cursor depending of mouse presence */
381 TRACE("Mouse present %u, buttons %u, wheel %u\n",
382 gpsi->aiSysMet[SM_MOUSEPRESENT],
383 gpsi->aiSysMet[SM_CMOUSEBUTTONS],
384 gpsi->aiSysMet[SM_MOUSEWHEELPRESENT]);
385
386 if (PreviousNumberOfKeyboards == 0 && NumberOfKeyboards > 0)
387 {
389 // Register the Window hotkey.
391 // Register the Window Snap hotkey.
396 // Register the debug hotkeys.
398 UserLeave();
399 }
400 else if (PreviousNumberOfKeyboards > 0 && NumberOfKeyboards == 0)
401 {
403 // Unregister the Window hotkey.
405 // Unregister the Window Snap hotkey.
410 // Unregister the debug hotkeys.
413 UserLeave();
414 }
415 gNumberOfKeyboards = NumberOfKeyboards;
416 gKeyboardInfo.NumberOfFunctionKeys = MaxFunctionKeys;
417 TRACE("Keyboard type %u, subtype %u and number of func keys %u\n",
421}
#define IDHK_SNAP_LEFT
Definition: hotkey.h:20
#define IDHK_WINKEY
Definition: hotkey.h:16
#define IDHK_SNAP_UP
Definition: hotkey.h:22
#define IDHK_F12
Definition: hotkey.h:14
#define IDHK_SNAP_DOWN
Definition: hotkey.h:23
#define IDHK_SNAP_RIGHT
Definition: hotkey.h:21
#define IDHK_SHIFTF12
Definition: hotkey.h:15
#define PWND_BOTTOM
Definition: ntuser.h:797
#define WHEELMOUSE_I8042_HARDWARE
Definition: ntddmou.h:102
#define WHEELMOUSE_SERIAL_HARDWARE
Definition: ntddmou.h:103
#define HORIZONTAL_WHEEL_PRESENT
Definition: ntddmou.h:106
#define WHEELMOUSE_HID_HARDWARE
Definition: ntddmou.h:105
#define SM_CMOUSEBUTTONS
Definition: winuser.h:1017
#define MOD_WIN
Definition: winuser.h:2686
#define SM_MOUSEPRESENT
Definition: winuser.h:991
#define SM_MOUSEWHEELPRESENT
Definition: winuser.h:1046
#define VK_UP
Definition: winuser.h:2261
#define VK_LEFT
Definition: winuser.h:2260
#define VK_RIGHT
Definition: winuser.h:2262
#define VK_DOWN
Definition: winuser.h:2263
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
UCHAR Subtype
Definition: ntddkbd.h:102
UCHAR Type
Definition: ntddkbd.h:101
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:447
VOID FASTCALL SetDebugHotKeys(VOID)
Definition: hotkey.c:46
BOOL FASTCALL UserUnregisterHotKey(PWND pWnd, int id)
Definition: hotkey.c:499
static NTSTATUS NTAPI OpenInputDevice(_In_ PINPUT_DEVICE_INFO DeviceInfo)
Definition: input.c:151
static DWORD gNumberOfKeyboards
Definition: input.c:38
static VOID StartReadInputDevice(_In_ PINPUT_DEVICE_INFO DeviceInfo)
Definition: input.c:227
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17

Referenced by RawInputThreadMain().

◆ ProcessKeyboardUpdates()

static VOID ProcessKeyboardUpdates ( VOID  )
static

Definition at line 425 of file input.c.

427{
429 KEYBOARD_TYPEMATIC_PARAMETERS GlobalTypematic, LocalTypematic;
431 DWORD Updates;
432
433 Updates = InterlockedExchange(&gKeyboardFlags, 0);
434 if (!Updates)
435 return;
436
437 RtlZeroMemory(&LocalTypematic, sizeof(LocalTypematic));
438 RtlZeroMemory(&GlobalTypematic, sizeof(GlobalTypematic));
439 GlobalTypematic.Rate = gspv.dwKbdSpeed;
440 GlobalTypematic.Delay = gspv.iKbdDelay;
441
443 for (DeviceInfo = gpInputDeviceInfo; DeviceInfo; DeviceInfo = DeviceInfo->pNextDeviceInfo)
444 {
445 if (!DeviceInfo->Handle || DeviceInfo->DeviceType != RIM_TYPEKEYBOARD)
446 continue;
447
448 if (Updates & KBD_UPDATE_LEDS)
449 {
450 /* Update the lights on the hardware */
452 NULL,
453 NULL,
454 NULL,
455 &Iosb,
457 &gIndicators, sizeof(gIndicators),
458 NULL, 0);
459 }
460
461 if (Updates & KBD_UPDATE_TYPEMATIC)
462 {
463 /* Update typematic */
464#define CLAMP(v, lo, hi) ((v) < (lo) ? (lo) : (v) > (hi) ? (hi) : (v))
465 LocalTypematic.Rate = CLAMP(GlobalTypematic.Rate,
466 DeviceInfo->Keyboard.Attributes.KeyRepeatMinimum.Rate,
467 DeviceInfo->Keyboard.Attributes.KeyRepeatMaximum.Rate);
468 LocalTypematic.Delay = CLAMP(GlobalTypematic.Delay,
469 DeviceInfo->Keyboard.Attributes.KeyRepeatMinimum.Delay,
470 DeviceInfo->Keyboard.Attributes.KeyRepeatMaximum.Delay);
472 NULL,
473 NULL,
474 NULL,
475 &Iosb,
477 &LocalTypematic, sizeof(LocalTypematic),
478 NULL, 0);
479 }
480 }
482}
#define InterlockedExchange
Definition: armddk.h:54
#define IOCTL_KEYBOARD_SET_INDICATORS
Definition: ntddkbd.h:47
#define IOCTL_KEYBOARD_SET_TYPEMATIC
Definition: ntddkbd.h:44
INT iKbdDelay
Definition: sysparams.h:107
DWORD dwKbdSpeed
Definition: sysparams.h:104
#define CLAMP(v, lo, hi)
KEYBOARD_INDICATOR_PARAMETERS gIndicators
Definition: keyboard.c:16

Referenced by RawInputThreadMain().

◆ RawInputThreadMain()

VOID NTAPI RawInputThreadMain ( VOID  )

Definition at line 490 of file input.c.

491{
494 //LARGE_INTEGER WaitTimeout;
495 PVOID WaitObjects[4], pSignaledObject = NULL;
498 HWINSTA hWinSta;
501 UNICODE_STRING LegacyMouseName = RTL_CONSTANT_STRING(L"\\Device\\PointerClass0");
502 UNICODE_STRING LegacyKeyboardName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardClass0");
503
507
511
512 //WaitTimeout.QuadPart = (LONGLONG)(-10000000);
513
517
518 TRACE("Raw Input Thread %p\n", ptiRawInput);
519
522
524 0,
525 NULL,
528 UserMode,
529 (PHANDLE)&hWinSta);
530 if (NT_SUCCESS(Status))
531 {
533 }
534 else
535 {
536 ASSERT(FALSE);
537 /* Failed to open the interactive winsta! What now? */
538 }
539
544
545 Mouse = CreateInputDevice(RIM_TYPEMOUSE, &LegacyMouseName);
546 ASSERT(Mouse);
547 Keyboard = CreateInputDevice(RIM_TYPEKEYBOARD, &LegacyKeyboardName);
549
552 UserLeave();
553
555 for (;;)
556 {
557 /* Reset WaitHandles array */
558 WaitObjects[0] = ShutdownEvent;
559 WaitObjects[1] = MasterTimer;
560 WaitObjects[2] = gDeviceListChangedEvent;
561 WaitObjects[3] = gKeyboardUpdatesEvent;
562
564 WaitObjects,
565 WaitAny,
568 TRUE,
569 NULL,//&WaitTimeout,
571
572 if ((Status >= STATUS_WAIT_0) &&
573 (Status < (STATUS_WAIT_0 + RTL_NUMBER_OF(WaitObjects))))
574 {
575 /* Some device has finished reading */
576 pSignaledObject = WaitObjects[Status - STATUS_WAIT_0];
577
578 if (pSignaledObject == gDeviceListChangedEvent)
579 {
581 }
582 else if (pSignaledObject == gKeyboardUpdatesEvent)
583 {
585 }
586 else if (pSignaledObject == MasterTimer)
587 {
589 }
590 else if (pSignaledObject == ShutdownEvent)
591 {
592 break;
593 }
594 else ASSERT(FALSE);
595 }
596 }
597
599 while (gpInputDeviceInfo)
600 {
602 gpInputDeviceInfo = DeviceInfo->pNextDeviceInfo;
605 }
608
613
614 ERR("Raw Input Thread Exit!\n");
615}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static HANDLE ShutdownEvent
Definition: dcomlaunch.c:28
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define L(x)
Definition: resources.c:13
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define ExDeleteResourceLite(res)
Definition: env_spec_w32.h:647
_Must_inspect_result_ _In_ WAIT_TYPE _In_opt_ PLARGE_INTEGER _In_opt_ PKWAIT_BLOCK WaitBlockArray
Definition: fsrtlfuncs.h:1153
@ Keyboard
Definition: i8042prt.h:115
@ Mouse
Definition: i8042prt.h:116
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:806
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:292
#define LOW_REALTIME_PRIORITY
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define UserMode
Definition: asm.h:39
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
@ SynchronizationEvent
@ WaitAny
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:599
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_WAIT_0
Definition: ntstatus.h:330
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1614
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2769
NTSTATUS NTAPI PoRequestShutdownEvent(OUT PVOID *Event)
Definition: poshtdwn.c:384
struct _CLIENTINFO * pClientInfo
Definition: win32.h:95
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1300
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21
static PINPUT_DEVICE_INFO CreateInputDevice(_In_ UCHAR DeviceType, _In_ PUNICODE_STRING DeviceName)
Definition: input.c:116
PTHREADINFO ptiRawInput
Definition: input.c:29
static VOID ProcessKeyboardUpdates(VOID)
Definition: input.c:425
static VOID ProcessDeviceChanges(VOID)
Definition: input.c:305
static VOID CloseInputDevice(_In_ PINPUT_DEVICE_INFO DeviceInfo)
Definition: input.c:217
PERESOURCE gpDeviceInfoListMutex
Definition: input.c:36
VOID FASTCALL ProcessTimers(VOID)
Definition: timer.c:452
VOID FASTCALL StartTheTimers(VOID)
Definition: timer.c:374
@ UserRequest
Definition: ketypes.h:473

Referenced by UserSystemThreadProc().

◆ RITReadApc()

static VOID NTAPI RITReadApc ( _In_ PVOID  ApcContext,
_In_ PIO_STATUS_BLOCK  IoStatusBlock,
_In_ ULONG  Reserved 
)
static

Definition at line 263 of file input.c.

267{
269
270 if (DeviceInfo->Handle && NT_SUCCESS(IoStatusBlock->Status))
271 {
272 if (DeviceInfo->DeviceType == RIM_TYPEKEYBOARD)
273 {
274 TRACE("KeyboardEvent: %s %04x\n",
275 (DeviceInfo->Keyboard.Data.Flags & KEY_BREAK) ? "up" : "down",
276 DeviceInfo->Keyboard.Data.MakeCode);
277
278 /* Set LastInputTick */
280
281 /* Process data */
284 UserLeave();
285 }
286 else if (DeviceInfo->DeviceType == RIM_TYPEMOUSE)
287 {
288 TRACE("MouseEvent\n");
289
290 /* Set LastInputTick */
292
293 /* Process data */
296 UserLeave();
297 }
298 }
299
301}
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:727
#define KEY_BREAK
Definition: ntddkbd.h:71
WCHAR Data[ANYSIZE_ARRAY]
static DWORD FASTCALL IntLastInputTick(BOOL bUpdate)
Definition: input.c:50
VOID NTAPI UserProcessKeyboardInput(PINPUT_DEVICE_INFO pDeviceInfo, PKEYBOARD_INPUT_DATA pKeyInput)
Definition: keyboard.c:1499
VOID NTAPI UserProcessMouseInput(PINPUT_DEVICE_INFO pDeviceInfo, PMOUSE_INPUT_DATA pMouseInputData)
Definition: mouse.c:104

Referenced by StartReadInputDevice().

◆ StartReadInputDevice()

static VOID StartReadInputDevice ( _In_ PINPUT_DEVICE_INFO  DeviceInfo)
static

Definition at line 227 of file input.c.

229{
233
234 ByteOffset.QuadPart = (LONGLONG)0;
235
236 if (DeviceInfo->DeviceType == RIM_TYPEKEYBOARD)
237 {
238 Buffer = &DeviceInfo->Keyboard.Data,
239 BufferSize = sizeof(DeviceInfo->Keyboard.Data);
240 }
241 else if (DeviceInfo->DeviceType == RIM_TYPEMOUSE)
242 {
243 Buffer = &DeviceInfo->Mouse.Data,
244 BufferSize = sizeof(DeviceInfo->Mouse.Data);
245 }
246 else
247 return;
248
249 DeviceInfo->Status = ZwReadFile(
250 DeviceInfo->Handle,
251 NULL,
254 &DeviceInfo->Iosb,
255 Buffer,
257 &ByteOffset,
258 NULL);
259}
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
_In_ ULONG BufferSize
Definition: dispmprt.h:490
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:732
int64_t LONGLONG
Definition: typedefs.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static VOID NTAPI RITReadApc(_In_ PVOID ApcContext, _In_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG Reserved)
Definition: input.c:263

Referenced by ProcessDeviceChanges(), and RITReadApc().

◆ UserAttachThreadInput()

NTSTATUS FASTCALL UserAttachThreadInput ( PTHREADINFO  ptiFrom,
PTHREADINFO  ptiTo,
BOOL  fAttach 
)

Definition at line 744 of file input.c.

745{
746 MSG msg;
747 PATTACHINFO pai;
748 PCURICON_OBJECT CurIcon;
749
750 /* Can not be the same thread. */
751 if (ptiFrom == ptiTo) return STATUS_INVALID_PARAMETER;
752
753 /* Do not attach to system threads or between different desktops. */
754 if (ptiFrom->TIF_flags & TIF_DONTATTACHQUEUE ||
756 ptiFrom->rpdesk != ptiTo->rpdesk)
758
759 /* MSDN Note:
760 Keyboard and mouse events received by both threads are processed by the thread specified by the idAttachTo.
761 */
762
763 /* If Attach set, allocate and link. */
764 if (fAttach)
765 {
767 if (!pai) return STATUS_NO_MEMORY;
768
769 pai->paiNext = gpai;
770 pai->pti1 = ptiFrom;
771 pai->pti2 = ptiTo;
772 gpai = pai;
773 paiCount++;
774 ERR("Attach Allocated! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount);
775
776 if (ptiTo->MessageQueue != ptiFrom->MessageQueue)
777 {
778
779 ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
780
781 if (ptiFrom->MessageQueue == gpqForeground)
782 {
783 ERR("ptiFrom is Foreground\n");
784 ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive;
785 ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus;
786 ptiTo->MessageQueue->spwndCapture = ptiFrom->MessageQueue->spwndCapture;
787 ptiTo->MessageQueue->QF_flags ^= ((ptiTo->MessageQueue->QF_flags ^ ptiFrom->MessageQueue->QF_flags) & QF_CAPTURELOCKED);
788 RtlCopyMemory(&ptiTo->MessageQueue->CaretInfo,
789 &ptiFrom->MessageQueue->CaretInfo,
790 sizeof(ptiTo->MessageQueue->CaretInfo));
793 gptiForeground = ptiTo;
794 }
795 else
796 {
797 ERR("ptiFrom NOT Foreground\n");
798 if ( ptiTo->MessageQueue->spwndActive == 0 )
799 ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive;
800 if ( ptiTo->MessageQueue->spwndFocus == 0 )
801 ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus;
802 }
803
804 CurIcon = ptiFrom->MessageQueue->CursorObject;
805
806 MsqDestroyMessageQueue(ptiFrom);
807
808 if (CurIcon)
809 {
810 // Could be global. Keep it above the water line!
811 UserReferenceObject(CurIcon);
812 }
813
814 if (CurIcon && UserObjectInDestroy(UserHMGetHandle(CurIcon)))
815 {
816 UserDereferenceObject(CurIcon);
817 CurIcon = NULL;
818 }
819
820 ptiFrom->MessageQueue = ptiTo->MessageQueue;
821
822 // Pass cursor From if To is null. Pass test_SetCursor parent_id == current pti ID.
823 if (CurIcon && ptiTo->MessageQueue->CursorObject == NULL)
824 {
825 ERR("ptiTo receiving ptiFrom Cursor\n");
826 ptiTo->MessageQueue->CursorObject = CurIcon;
827 }
828
829 ptiFrom->MessageQueue->cThreads++;
830 ERR("ptiTo S Share count %u\n", ptiFrom->MessageQueue->cThreads);
831
833 }
834 else
835 {
836 ERR("Attach Threads are already associated!\n");
837 }
838 }
839 else /* If clear, unlink and free it. */
840 {
841 BOOL Hit = FALSE;
842 PATTACHINFO *ppai;
843
844 if (!gpai) return STATUS_INVALID_PARAMETER;
845
846 /* Search list and free if found or return false. */
847 ppai = &gpai;
848 while (*ppai != NULL)
849 {
850 if ( (*ppai)->pti2 == ptiTo && (*ppai)->pti1 == ptiFrom )
851 {
852 pai = *ppai;
853 /* Remove it from the list */
854 *ppai = (*ppai)->paiNext;
856 paiCount--;
857 Hit = TRUE;
858 break;
859 }
860 ppai = &((*ppai)->paiNext);
861 }
862
863 if (!Hit) return STATUS_INVALID_PARAMETER;
864
865 ERR("Attach Free! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount);
866
867 if (ptiTo->MessageQueue == ptiFrom->MessageQueue)
868 {
869 PWND spwndActive = ptiTo->MessageQueue->spwndActive;
870 PWND spwndFocus = ptiTo->MessageQueue->spwndFocus;
871
872 if (gptiForeground == ptiFrom)
873 {
874 ERR("ptiTo is now pti FG.\n");
875 // MessageQueue foreground is set so switch threads.
876 gptiForeground = ptiTo;
877 }
878 ptiTo->MessageQueue->cThreads--;
879 ERR("ptiTo E Share count %u\n", ptiTo->MessageQueue->cThreads);
880 ASSERT(ptiTo->MessageQueue->cThreads >= 1);
881
883
884 ptiFrom->MessageQueue = MsqCreateMessageQueue(ptiFrom);
885
886 if (spwndActive)
887 {
888 if (spwndActive->head.pti == ptiFrom)
889 {
890 ptiFrom->MessageQueue->spwndActive = spwndActive;
891 ptiTo->MessageQueue->spwndActive = 0;
892 }
893 }
894 if (spwndFocus)
895 {
896 if (spwndFocus->head.pti == ptiFrom)
897 {
898 ptiFrom->MessageQueue->spwndFocus = spwndFocus;
899 ptiTo->MessageQueue->spwndFocus = 0;
900 }
901 }
902 ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
903 }
904 else
905 {
906 ERR("Detaching Threads are not associated!\n");
907 }
908 }
909 /* Note that key state, which can be ascertained by calls to the GetKeyState
910 or GetKeyboardState function, is reset after a call to AttachThreadInput.
911 ATM which one?
912 */
913 RtlCopyMemory(ptiTo->MessageQueue->afKeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState));
914
915 ptiTo->MessageQueue->msgDblClk.message = 0;
916
917 /* Generate mouse move message */
918 msg.message = WM_MOUSEMOVE;
919 msg.wParam = UserGetMouseButtonsState();
920 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
921 msg.pt = gpsi->ptCursor;
923
924 return STATUS_SUCCESS;
925}
#define msg(x)
Definition: auth_time.c:54
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
PTHREADINFO gptiForeground
Definition: focus.c:15
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:296
#define UserHMGetHandle(obj)
Definition: ntuser.h:257
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
Definition: msgqueue.c:2434
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2407
#define QF_CAPTURELOCKED
Definition: msgqueue.h:114
#define IntReferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:220
#define IntDereferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:223
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
#define WM_MOUSEMOVE
Definition: winuser.h:1803
INT iCursorLevel
Definition: win32.h:128
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:90
Definition: ntuser.h:722
THRDESKHEAD head
Definition: ntuser.h:723
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
Definition: desktop.c:1347
INT paiCount
Definition: input.c:32
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:647
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:707
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:754
#define USERTAG_ATTACHINFO
Definition: tags.h:197

Referenced by co_IntSetParent(), co_UserCreateWindowEx(), co_UserDestroyWindow(), IntCreateWindow(), IntProcessOwnerSwap(), IsRemoveAttachThread(), and NtUserAttachThreadInput().

Variable Documentation

◆ gDeviceListChangedEvent

PKEVENT gDeviceListChangedEvent
static

Definition at line 40 of file input.c.

Referenced by CreateInputDevice(), and RawInputThreadMain().

◆ gKeyboardFlags

LONG gKeyboardFlags

Definition at line 33 of file input.c.

Referenced by IntKeyboardUpdateLeds(), OpenInputDevice(), ProcessKeyboardUpdates(), and SpiGetSet().

◆ gKeyboardUpdatesEvent

PKEVENT gKeyboardUpdatesEvent

Definition at line 34 of file input.c.

Referenced by IntKeyboardUpdateLeds(), OpenInputDevice(), RawInputThreadMain(), and SpiGetSet().

◆ gNumberOfKeyboards

DWORD gNumberOfKeyboards = 0
static

Definition at line 38 of file input.c.

Referenced by ProcessDeviceChanges().

◆ gpai

PATTACHINFO gpai = NULL

Definition at line 31 of file input.c.

Referenced by IsRemoveAttachThread(), and UserAttachThreadInput().

◆ gpDeviceInfoListMutex

PERESOURCE gpDeviceInfoListMutex = NULL

◆ gpInputDeviceInfo

◆ LastInputTick

DWORD LastInputTick = 0
static

Definition at line 39 of file input.c.

Referenced by DoTheScreenSaver(), and IntLastInputTick().

◆ MasterTimer

PKTIMER MasterTimer = NULL

Definition at line 30 of file input.c.

Referenced by InitInputImpl(), IntSetTimer(), ProcessTimers(), and RawInputThreadMain().

◆ paiCount

INT paiCount = 0

Definition at line 32 of file input.c.

Referenced by UserAttachThreadInput().

◆ ptiRawInput

PTHREADINFO ptiRawInput

Definition at line 29 of file input.c.

Referenced by IntSetTimer(), and RawInputThreadMain().