Repository navigation
Conversation
…ng and unhiding A handle opened before a change of cloaking keeps its access. Windows opens a game controller for Raw Input itself and keeps it open: a controller hidden after that stays readable to every Raw Input client, and one hidden when Raw Input opens it is dropped from Raw Input and stays out after it is unhidden, until it is replugged. The driver now keeps its filter devices and, when the blacklist, the active state or the session blacklist changes, restarts each device whose cloaking changed (WdfDeviceSetFailed with WdfDeviceFailedAttemptRestart). The new device object starts with the cloaking it then has. Not built yet: written without the WDK.
Adds the RestartOnChange driver parameter, IOCTL_GET_RESTART_ON_CHANGE and IOCTL_SET_RESTART_ON_CHANGE, and the CLI commands --restart-on, --restart-off and --restart-state, following the inverse application list. While it is off, HidHide behaves as before; turning it on restarts the devices hidden or shown while it was off. Not built yet: written without the WDK.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Turns the restart on change setting on and off, as Enable device hiding does for hiding. Not built yet: written without the WDK and the client toolchain.
Windows opens each game controller for Raw Input from kernel mode, inside csrss.exe rather than the System process. OnDeviceFileCreate refused that open for a hidden device, and Windows then dropped the controller from Raw Input until it was plugged in again, so unhiding it did nothing. A kernel-mode open is now granted like one from the System process; every user-mode open is checked as before. That fixes the cause, so the restart on change, its setting, IOCTLs, CLI commands and check box are removed.
ISSUE
People hide a controller, later unhide it, and games that read controllers through Raw Input still cannot see it. The
controller looks fine in Device Manager, and turning hiding off does not help. Only unplugging it and plugging it in
again brings it back. The opposite also happens: a hidden controller still shows up in some games, depending on what
opened it first. To the user, HidHide seems to work on some days and not on others.
PROBLEM
OnDeviceFileCreateallows an open only when the caller is the System process (SYSTEM_PID) or a program on theapplication list. The comment above the check says that a system-level process is always granted access.
Windows opens each game controller for Raw Input itself, from kernel mode, and keeps that handle open for every program
that reads Raw Input. The open runs inside
csrss.exerather than the System process, so HidHide refuses it. Adding thereading program or
csrss.exeto the application list did not change this.After a refused open, Windows does not try again, and the controller stays out of Raw Input until the device is plugged
in again. This was tested with HidHide 1.5.230 on Windows 11 build 26200, and
masterhas the same check:kept sending about 250 reports a second. This matches the FAQ, which says HidHide cannot block Raw Input.
GetRawInputDeviceList, andunhiding it does not bring it back. Turning hiding off and on, starting another program that reads Raw Input, and
calling
CM_Reenumerate_DevNodeas a standard user (it returnsCR_ACCESS_DENIED) do not bring it back either. Onlyplugging it in again, or restarting the device as administrator, does.
To reproduce, with no program reading Raw Input:
GetRawInputDeviceList.SOLUTION
This pull request changes the check in
OnDeviceFileCreateso that an open coming from kernel mode is allowed, the sameway an open from the System process already is:
Programs, including games, open devices from user mode, so they are checked exactly as before. Raw Input's own open
always succeeds, so Windows keeps the controller, and case 1 above applies whatever the order. The change is three lines
in
HidHide/src/Logic.c: the condition and two comments.PROS
or have administrator rights.
already describes.
check today, so allowing kernel-mode opens extends an existing exception rather than adding a new kind.
their Raw Input reader starts, or ask users to plug a controller in again.
CONS
for example at boot, is missing from Raw Input, and some users may depend on that. As long as HidHide checks access
only when a device is opened, hiding from Raw Input and unhiding cleanly cannot both work, because Windows opens the
device once for all programs and does not retry after a refusal.
device. Whether any such driver is in use has not been checked; the review below asks about it.
A HidHide trace of the reproduction would show it.
Weighing it up
People who unhide a controller, or whose controller was hidden at boot, currently have to plug it in again, and this
change removes that. People who relied on HidHide hiding a controller from Raw Input only got it when the device happened
to be hidden before Raw Input opened it, and the FAQ already says it is not supported.
The first version of this pull request restarted the device on every hide and unhide instead. That kept Raw Input
hiding, but it disconnected the controller each time and needed a new setting, two IOCTLs, three CLI commands, and a
device list with its own lock. This version changes one condition.
Conclusion: it solves more than it breaks.
Testing still to do
CreateFile), also with the inverseapplication list.
Review
Please have your AI reviewer check this as well as a human, in particular:
opens made with
OBJ_FORCE_ACCESS_CHECK.@coderabbitai review