changeofpace / MouClassInputInjection

MouClassInputInjection implements a kernel interface for injecting mouse input data packets into the input data stream of HID USB mouse devices.
MIT License
290 stars 82 forks source link

MouiiIoInitializeMouseDeviceStackContext failed: 317 #5

Closed guidra-rev closed 3 years ago

guidra-rev commented 4 years ago

Hello,

I would like to try MouiiCL in a Virtual Machine. I did the following :

The error code 317 from MSDN : ERROR_MR_MID_NOT_FOUND The system cannot find message text for message number 0x%1 in the message file for %2.

DebugView output image

Any idea on what I did wrong ?

changeofpace commented 4 years ago

You need to manually move the mouse and click at least one mouse button during driver initialization. The driver waits ~15 seconds for both types of input before failing.

The client prints the following line when the driver enters this timing window:

Waiting for user to provide mouse button and movement input.

The driver prints the following line (in debug builds) when it enters this timing window:

Waiting 15 seconds for user to provide button and movement input.
guidra-rev commented 4 years ago

Yes of cousre I did see this, I moved and click as instructed, I guess they are not detected

changeofpace commented 4 years ago

It may be an issue with a Virtual Box mouse filter driver. Can you paste the output of the following devcon command:

devcon stack =mouse

kaushikkumarbora commented 4 years ago

Same:

13:29:19.341  DBG  0004:0144  System           Loading \Device\MouClassInputInjection.
13:29:19.341  DBG  0004:0144  System           Loading MouHid Context.
13:29:19.341  DBG  0004:0144  System           Resolving MouHid connect data field offset.
13:29:19.341  DBG  0004:0144  System           Device Object List (DriverName = \Driver\mouhid):
13:29:19.341  DBG  0004:0144  System               0: DeviceObject = FFFFBE044D9BF040, Name = (unnamed)
13:29:19.341  DBG  0004:0144  System           Resolving MouHid connect data field offset for device. (DeviceObject = FFFFBE044D9BF040)
13:29:19.341  DBG  0004:0144  System           MouHid Context loaded:
13:29:19.341  DBG  0004:0144  System               ConnectDataFieldOffset:      0xE0
13:29:19.341  DBG  0004:0144  System           Loading MouClass Manager.
13:29:19.341  DBG  0004:0144  System           Device Object List (DriverName = \Driver\mouclass):
13:29:19.341  DBG  0004:0144  System               0: DeviceObject = FFFFBE044D9BF6D0, Name = \Device\PointerClass1
13:29:19.341  DBG  0004:0144  System               1: DeviceObject = FFFFBE044C02CB70, Name = \Device\PointerClass0
13:29:19.341  DBG  0004:0144  System           MouClass Manager loaded.
13:29:19.341  DBG  0004:0144  System           Loading MouHid Hook Manager.
13:29:19.341  DBG  0004:0144  System           Registered mouse PnP notification callback. (Callback = FFFFF80261C753F0, Context = 0000000000000000, RegistrationHandle = FFFFBE0447BD8360)
13:29:19.341  DBG  0004:0144  System           MouHid Hook Manager loaded.
13:29:19.341  DBG  0004:0144  System           Loading MouClass Input Injection.
13:29:19.341  DBG  0004:0144  System           Registered mouse PnP notification callback. (Callback = FFFFF80261C74070, Context = 0000000000000000, RegistrationHandle = FFFFBE0447BD8120)
13:29:19.341  DBG  0004:0144  System           MouClass Input Injection loaded.
13:29:19.341  DBG  0004:0144  System           \Device\MouClassInputInjection loaded.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Processing IRP_MJ_CREATE.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Processing IOCTL_INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Initializing the mouse device stack context.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Registering MHK callbacks. (HookCallback = FFFFF80261C73BA0, NotificationCallback = 0000000000000000, Context = FFFFBE0447B67F80)
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Hooking MouHid device objects.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Creating MouHid hook context.
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Device Object List (DriverName = \Driver\mouhid):
13:29:37.969  DBG  7816:7804  MouiiCL.exe          0: DeviceObject = FFFFBE044D9BF040, Name = (unnamed)
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Installing connect data hooks:
13:29:37.969  DBG  7816:7804  MouiiCL.exe          0. Hooked: FFFFF8026A0F14B0 -> FFFFF80261C75540 (DeviceObject = FFFFBE044D9BF040)
13:29:37.969  DBG  7816:7804  MouiiCL.exe      MHK callbacks registered. (RegistrationHandle = FFFFBE0447BD81E0)
13:29:37.969  DBG  7816:7804  MouiiCL.exe      Waiting 15 seconds for user to provide button and movement input.
13:29:53.017  DBG  7816:7804  MouiiCL.exe      Unregistering MHK callbacks. (RegistrationHandle = FFFFBE0447BD81E0)
13:29:53.017  DBG  7816:7804  MouiiCL.exe      Unhooking MouHid device objects.
13:29:53.017  DBG  7816:7804  MouiiCL.exe      Uninstalling connect data hooks:
13:29:53.017  DBG  7816:7804  MouiiCL.exe          0. Unhooked: FFFFF80261C75540 -> FFFFF8026A0F14B0 (DeviceObject = FFFFBE044D9BF040)
13:29:53.293  DBG  7816:7804  MouiiCL.exe      MHK callbacks unregistered.
13:29:53.293  DBG  7816:7804  MouiiCL.exe      Wait complete. Processed 0 mouse input data packets.
13:29:53.293  ERR  7816:7804  MouiiCL.exe      Device resolution callback timed out.
13:29:53.293  ERR  7816:7804  MouiiCL.exe      MiiInitializeMouseDeviceStackContext failed: 0xC000047D
13:30:01.027  DBG  7816:7804  MouiiCL.exe      Processing IRP_MJ_CLOSE.

Removing VirtualBox Guest Filter Fixed it.

02:18:34.913  DBG  4680:6464  MouiiCL.exe      Waiting 15 seconds for user to provide button and movement input.
02:18:37.888  DBG  4680:6464  MouiiCL.exe      Unregistering MHK callbacks. (RegistrationHandle = FFFFE587393E6330)
02:18:37.888  DBG  4680:6464  MouiiCL.exe      Unhooking MouHid device objects.
02:18:37.888  DBG  4680:6464  MouiiCL.exe      Uninstalling connect data hooks:
02:18:37.888  DBG  4680:6464  MouiiCL.exe          0. Unhooked: FFFFF8050FB85540 -> FFFFF805173E4BE0 (DeviceObject = FFFFE5873BFBC750)
02:18:38.153  DBG  4680:6464  MouiiCL.exe      MHK callbacks unregistered.
02:18:38.153  DBG  4680:6464  MouiiCL.exe      Wait complete. Processed 44 mouse input data packets.
02:18:38.153  DBG  4680:6464  MouiiCL.exe      Mouse Device Stack Context:
02:18:38.153  DBG  4680:6464  MouiiCL.exe          Button Device
02:18:38.153  DBG  4680:6464  MouiiCL.exe              ConnectData
02:18:38.153  DBG  4680:6464  MouiiCL.exe                  ClassDeviceObject:   FFFFE5873BFBCB60
02:18:38.159  DBG  4680:6464  MouiiCL.exe                  ClassService:        FFFFF805173E4BE0
02:18:38.159  DBG  4680:6464  MouiiCL.exe              UnitId:                  1
02:18:38.159  DBG  4680:6464  MouiiCL.exe          Movement Device
02:18:38.165  DBG  4680:6464  MouiiCL.exe              ConnectData
02:18:38.165  DBG  4680:6464  MouiiCL.exe                  ClassDeviceObject:   FFFFE5873BFBCB60
02:18:38.165  DBG  4680:6464  MouiiCL.exe                  ClassService:        FFFFF805173E4BE0
02:18:38.165  DBG  4680:6464  MouiiCL.exe              UnitId:                  1
02:18:38.169  DBG  4680:6464  MouiiCL.exe              AbsoluteMovement:        TRUE
02:18:38.169  DBG  4680:6464  MouiiCL.exe              VirtualDesktop:          FALSE
02:18:38.169  DBG  4680:6464  MouiiCL.exe      Mouse device stack context initialized.
JitCompiler commented 3 years ago

virtual box is emulating the mouse through a filter driver attached to the PS/2 device stack instead of the usb device stack. So, inside the guest mouclass.sys is receiving input from i8042prt.sys instead of mouhid.sys. But the MouClassInputInjection driver hooks the mouhid.sys only and is waiting for input packet from it. Hence MouiiCL will timeout when "Waiting for user to provide mouse button and movement input.".

We just need a way to force virtual box to use the usb mouse instead. My solution is in Setting->USB, adds the host's usb mouse to the guest.

changeofpace commented 3 years ago

Thanks for the info @JitCompiler. I'm going to close this because it seems isolated to VirtualBox and old PS/2 mice.