This is a bug fixing filter driver for Microsoft Windows xusb22.sys Xbox gamepad driver (version 06/12/2019 10.0.19041.1).
Windows xusb22.sys driver interacting with dwm.exe (Desktop Window Manager) can sometimes cause a very long (possibly infinite) loop where dwm.exe and the driver are consuming 100% CPU. Especially when running Windows 10/11 in a QEMU/KVM virtual machine and using the ViGEm Bus driver, the system is rendered unusable as soon as a gamepad is connected.
The looping occurs in an xusb22.sys function called ProcessWaitRequests
(named according to the published PDB file) similar to the following
pseudocode:
while (TRUE) {
WDFREQUEST request:
WdfIoQueueRetrieveNextRequest(queue, &request);
if (!request)
break;
// ... processing ...
WdfRequestCompleteWithInformation(request, STATUS_SUCCESS, 29);
}
The request
above originates from dwm.exe sending IOCTL 0x8000E3AC
(WaitForInput, to get gamepad stick and button state etc). Apparently, as soon
as the request is completed, dwm.exe sends a new IOCTL request to the driver
which inserts it into the same queue
which is being processed by the loop
above. It can happen that the new request gets inserted into queue
before
next WdfIoQueueRetrieveNextRequest
call and this can repeat apparently
indefinitely.
The xusbfixer driver is intended to be a temporary solution until Microsoft fixes xusb22. It is both an upper and lower filter driver where the driver stack ends up looking like:
- xusbfixer
- xusb22
- xusbfixer
- ViGEmBus
The upper xusbfixer manages IOCTL 0x8000E3AC requests and doesn't let them pass
while the ProcessWaitRequests
loop is running in xusb22. The lower xusbfixer
monitors USB interrupt transfer requests and their completion in an attempt to
detect when the ProcessWaitRequests
loop is going to start and has finished.
Unpack the release zip file containing the inf
and sys
files. In file
explorer, right click on the inf
file and select Install
.
Another way to fix the infinite looping in xusb22 ProcessWaitRequests
is to
install the previous version of Microsoft's driver, xusb21. That version does
not support the IOCTL 0x8000E3AC and doesn't have the ProcessWaitRequests
function. However, some applications won't be able to use gamepads anymore
(such as Windows start and settings menus.) The xusbfixer driver has an
alternative simple mode that mimics xusb21 and responds with invalid parameter
status to the IOCTL 0x8000E004 (GetCapabilities). To turn on this alternative
mode, simply remove xusbfixer from the lower filter list in Windows registry
(cf. step 5 below in the uninstalling section.) To restore the default
behaviour, add xusbfixer back.
Run the included PowerShell script uninstall-xusbfixer.ps1
as an
administrator and reboot. Alternatively, you can uninstall manually:
- In command prompt, run
pnputil /enum-drivers
and note the "Published name" (e.g.oemXX.inf
filename) for xusbfixer.inf, - Run
pnputil /delete-driver oemXX.inf
whereoemXX.inf
is from the previous step, - Delete file
C:\Windows\System32\drivers\xusbfixer.sys
, - Run
regedit.exe
and delete keyHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\xusbfixer
, - Delete also
LowerFilters
andUpperFilters
properties under theHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{d61ca365-5af4-4486-998b-9db4734c6ca3}
key, - Reboot.
This driver is only self-signed so you will have to use test mode or disable Windows driver signature enforcement. Either
- Disable Secure Boot in UEFI settings, enable test mode using the command
bcdedit /set testsigning on
and reboot, or - Reboot Windows by pressing Shift and clicking Restart from start menu,
then select Troubleshoot / Advanced options / Start-up Settings and restart.
When the boot menu shows up, select "Disable driver signature enforcement".
You can make the boot menu show up on every boot by running the command
bcdedit /set advancedoptions on
.
To build the driver from source code, install Visual Studio 2022, Windows SDK and Windows Driver Kit.
(Tip: if VS2022 starts consuming 100% cpu and the UI freezes for a while
whenever you start editing a file (like it does for me with version 17.8.5),
try setting "Tools -> Options -> Text Editor -> C/C++ -> Advanced -> Disable Database Auto Updates" to True
.)
The project is licensed under the MIT License. See LICENSE.txt for details.
- ViGEm Bus driver
- Application software to accompany the bus driver: