MouClassInputInjection
MouClassInputInjection implements a kernel interface for injecting mouse input data packets into the input data stream of HID USB mouse devices.
Packets injected using this technique are indistinguishable from packets generated by a physical mouse device. For example, mouse events for injected packets are not marked with the LLMHF_INJECTED or LLMHF_LOWER_IL_INJECTED flags.
Projects
MouClassInputInjection
The core driver project which implements the injection interface.
MouiiCL
A command line MouClassInputInjection client which allows users to inject mouse button data and mouse movement data via text commands.
Mouse Device Stacks
A HID USB mouse device has one or more HID USB mouse device stacks in the device tree. These device stacks implement the device interface for reading button data and movement data from the physical mouse device. The number of device stacks required for a mouse device depends on the presence of third party mouse filter drivers. The following image depicts the mouse device stacks for Windows 7 SP1 x64 when no third party filter drivers are active:
There is one HID USB mouse device stack for button data and movement data. All input packets from the physical mouse device are transferred to the data queue contained in the \Device\PointerClass0 device object.
In contrast, the following image depicts the mouse device stacks for Windows 7 SP1 x64 when the VMware vmusbmouse filter driver is active:
There are two HID USB mouse device stacks. The \Device\PointerClass2 device stack receives movement data packets, and the \Device\PointerClass3 device stack receives button data packets. The 'VMware Tools' package installs the vmusbmouse filter driver to smooth mouse movement. This filter driver hooks into the input data stream by modifying the CONNECT_DATA object sent down the mouse movement device stack during device initialization.
Interface
The MouClass Input Injection module defines an interface for injecting mouse button data, mouse movement data, and raw mouse input data packets in a specified process context.
Implementation
The MouClass Input Injection module injects input by invoking a mouse class service callback to copy synthesized packets to the mouse class data queue in the target HID USB mouse device stack. This module uses the MouHid Hook Manager module from the MouHidInputHook project to dynamically resolve the connect data objects for the button device stack and the movement device stack. These objects are contained in a 'device stack context' which must be initialized before the injection interface can be used.
The MouClass Input Injection module registers a PnP notification callback for mouse device interface changes. Each mouse device interface event invalidates the device stack context. This convention ensures that synthesized packets are always injected into the correct data queues using the correct service callbacks.
Related Projects
MouHidInputHook
https://github.com/changeofpace/MouHidInputHook
MouHidInputHook enables users to filter, modify, and inject mouse input data packets into the input data stream of HID USB mouse devices without modifying the mouse device stacks.
Limitations
- The mouse cursor does not visually update to reflect injected packets for absolute movement when the vmusbmouse filter driver is active.
- The MouClassInputInjection driver will fail to initialize if the MouHidMonitor logging feature of the MouHidInputHook driver is active.
Notes
- The MouClassInputInjection project was developed for Windows 7 SP1 x64. Support for other platforms is unknown.
- The injection strategy is PatchGuard safe.