Ryochan7 / DS4Windows

Like those other ds4tools, but sexier
https://ryochan7.github.io/ds4windows-site/
GNU General Public License v3.0
6.96k stars 807 forks source link

Disable Hidguard #878

Closed Chrisnetika closed 4 years ago

Chrisnetika commented 4 years ago

How to disable this entirely since exclusive never works for me no matter what?

Ryusennin commented 4 years ago

HidGuardian works. If it doesn't, chances are you haven't configured it properly (or your controller is not standard). The likely culprit would be the AffectedDevices registry key, which must be set for HidGuardian to properly hide your DInput controller. There used to be an option in DS4W settings to directly access the registry, but it seems to have been removed some time ago.

For info, the AffectedDevices key is located at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HidGuardian\Parameters

The HidGuardian Installer available in the wiki should make sure that this key is correctly created and configured:

https://github.com/Ryochan7/DS4Windows/wiki/DS4Windows-and-HIDGuardian-Install-and-Setup-Guide

Refer to the above guide for uninstalling the driver.

Chrisnetika commented 4 years ago

I have done all that and hidhuardian is installed, I even copied proper values in device manager.. it doesn't work so how to disable this so it do not get the uac prompt when i load ds4windows?

Ryochan7 commented 4 years ago

You probably don't have HidGuardian configured to block the device. Either way, the easiest way to disable HidGuardian entirely is to remove it from your system. You can run the following utility to remove HidGuardian from your system.

https://drive.google.com/open?id=1hs6AgM6yLeyr3htP9kY0T4N2vklRI2s9

It works but it has not been updated for a long time. I lost the source code during the last reformat; I thought that I had a backup somewhere. At some point I will probably have to rewrite it.

mika-n commented 4 years ago

After major Windows feature updates HidGuardian may stop working, so it needs to be re-installed to restore the functionality.

Anyway, if you can live with the DS4Windows built-in "Hide DS4 Controller" option (=exclusive mode) then go for it, but please be prepared to see scenarios where this exclusive mode doesn't work because some other app in your PC has hijacked the physical controller The above linked DS4Win wiki pages explains this issue and how you can try to resolve it (there is nothing DS4Win app itself can do about it, so please don't report that "exclusive mode is broken in DS4Win"). But the general consensus is that HidGuardian is the most sure way to hide the physical controller from all apps (except from DS4Windows itself).

I have never seen HidG failing to hide a controller as long the AffectedDevices sysreg entry is properly setup and HidGuardHelper.exe tool of DS4Windows app has permissions to update Whitelisted sysreg entry (that's why you'll see UAC warning because HidGuardHelper tries to add the process id of DS4Windows to Whitelist sysreg entry of HidG tool).

If you want to give HidG one more chance then maybe you should run the "DeviceDetect" debug version of DS4Windows (see the DS4Windows_DeviceDetectDebug.zip file in the following link) because it dumps more details about the gamepad (for example a full device path which can be used to check the validity of AffectedDevices sysreg entry) to Logs tabpage of DS4Win app. https://github.com/Ryochan7/DS4Windows/wiki/Troubleshooting#detailed-debug-log-file-from-gamepad-connection-problems

Ryochan7 commented 4 years ago

Good point. It seems the only feasible way around that problem would be to create a task that runs at boot and checks the UpperFilters(?) registry key for HidGuardian. If it no longer exists then it would have to add the string back, write it to the registry, and then prompt the user to reboot. I don't get why Windows cannot just restore that filter once it finishes installing relevant updates.

Chrisnetika commented 4 years ago

just to update, did a fresh reinstall of windows 10 due to getting an ssd and still it does not work.Even manually added my HW ID for my controller to affected devices USB\VID_054C&PID_09CC&MI_00 and still, also noticed I do not see any entries in whitelist

mika-n commented 4 years ago

Hmm... Usually the identifier starts as "HID\VID_xxxx" because gamepad devices are HID objects.

Have you run the DeviceDetect debug version? It will print out detailed gamepad identifiers in Logs tabpage of DS4Windows app. Try to use the debug version to verify the gamepad device path value. https://github.com/Ryochan7/DS4Windows/wiki/Troubleshooting#detailed-debug-log-file-from-gamepad-connection-problems

And there should be HidGuardHelper.exe app in the same folder with DS4Windows.exe app. DS4Windows calls HidGuardHelper tool to update the Whitelist sysreg entry (ie. adds DS4Windows process ID to the Whitelist list). Sysreg modification requires admin permissions. How do you launch DS4Windows app? Automatically in system boot or manually? Try to run the app manually to verify if the app asks you to accept admin privileges.

Ryochan7 commented 4 years ago

It has been a while since I played with HidGuardian. I will get it installed again and make sure DS4Windows can still work with it. The HidGuardHelper.exe (? not at computer now) program handles creating the whitelist entry. DS4Windows will launch that program and pass its current Process ID if it detects that HidGuardian is installed on your system.

Ryochan7 commented 4 years ago

Just checked it and HidGuardian support still works in DS4Windows. However, HidGuardian support does not work in the current WPF beta despite that build launching HidGuardHelper.exe. It looks like the app fails and then exits.

Ryochan7 commented 4 years ago

Made an oopsie there. Forgot to bundle an important DLL file so HidGuardHelper.exe fails in the WPF beta build. Including UtilLibrary.dll makes HidGuardian support work for the WPF beta.

Chrisnetika commented 4 years ago

using windows 10 enterprise if that helps any bit.I launch it manual at the time and I do not see it update the registry.Trying also Hid Cerberus and seems no luck.I will try the debug version.

Ryochan7 commented 4 years ago

That will not work. HidGuardHelper.exe is launched with the current DS4Windows process ID as a command argument. HidGuardHelper.exe will exit if no command line argument is passed and it will also exit if the process with that PID cannot be detected. The program will close once the other process is closed. Theoretically, HidGuardHelper.exe could be used with any program as long as you pass the current program PID as an argument.

Chrisnetika commented 4 years ago

This the debug log for USB https://pastebin.com/GVqXKw0X

and here for bluetooth https://pastebin.com/ZGrMtHtH

Hidguardian Registry https://pastebin.com/F8jvVzf0

HidCerberus Registry https://pastebin.com/RkZcPMEZ

Hope this helps the cause in some way

Ryochan7 commented 4 years ago

I would hope that DS4Windows had a PID of 7320 at that time because there is a whitelist entry for that program. Also, it is a quirk that kind of makes sense but I should point it out. When using HidGuardian while the Hide DS4 Controller option is not checked, DS4Windows will still open the device in Shared mode so the exclusive access check will show up as false in the controller listing. Another program that is compatible with HidGuardian would still be allowed access to the HID device. Hide DS4 Controller still has to be checked if you want to absolutely force exclusive access even to other programs that can use HidGuardian.

Ryochan7 commented 4 years ago

Also, can you take a screenshot of the AffectedDevices registry value or copy the plain text to a text file? The hex value that is printed is not that helpful.

Chrisnetika commented 4 years ago

Affected Devices https://pastebin.com/LJdxyQ3n

Entry in whitelist was hidcerberus trying whitelist DS4Windows but PID keeps changing so it pointless -_-

Chrisnetika commented 4 years ago

Hide DS4Windows does work to get exclusive mode working

Ryochan7 commented 4 years ago

Entry in whitelist was hidcerberus trying whitelist DS4Windows but PID keeps changing so it pointless -_-

Unfortunately that is the consequence of relying on PIDs. It changes each time you launch a program. No newer version of HidGuardian, that would whitelist apps based on other criteria, ever went beyond the experimental phase.

mika-n commented 4 years ago

AffectedDevices sysreg entry seem to have required "HID\VID_054c&PID_09cc&MI_03" (usb) identifier, but "HID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc" (BT) identifier is missing, so HidG cannot do its magic for a BT connected gamepad. Also, there seems to be unnecessary USB\xxx entries which you don't need (and may cause even problems if the underlying USB device handle is hidden).

I'm not 100% sure if HidGuardian.AffectedDevices is case sensitive (probably not). Anyway, these two identifiers should work with DS4 v2 usb and BT connections.

To verify that Whitelist entry is updated then try this:

Also. if you have recently installed some major WinOS updates then HidGuardian driver must be re-installed (some WinOS updates break its registration). Easiest way to re-install HidGuuardian is to use TestInstaller from DS4Windows toolpack. https://github.com/Ryochan7/DS4Windows/wiki/DS4Windows-and-HIDGuardian-Install-and-Setup-Guide#hidguardian-test-installer

Chrisnetika commented 4 years ago

I followed the directions above (mika-n post) 1st taking off hide ds4 hide option ryochan mentioned above, and it seemed to put the proper pid entry in the whitelist but exclusive mode still does not work this method.

Chrisnetika commented 4 years ago

Affected Devices: HID\VID_054c&PID_09cc&MI_03 HID{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc

USB Debug: https://pastebin.com/szTx5rGT

BTH Debug: https://pastebin.com/BS7sUxuX

Again it a new installation of windows 10 using latest nov 12th update already https://i.imgur.com/vKmtWiA.png

Going back to method Ryochan mention "Hide DS4 Controller" option as it seems to be only method that works so far.

mika-n commented 4 years ago

Naturally I managed to make a typing error in bluetooth device path. It should beHID\{00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc (ie. my previous post was missing the first backslash). Anyway, the USB device path was correct and if you tried that and connected the gamepad via USB and it still doesn't work then I'm out of ideas why HidG doesn't work in your setup (if you tried to uninstall HidG and re-installed it also).

If the DS4Windows built-in HideDS4Controller option (=exclusive access) works for you then go for it and hope that other programs won't hijack DS4 gamepad before DS4Windows can open it in exclusive mode.

Ryusennin commented 4 years ago

Missing backslash (without spaces): HID \ {00001124-0000-1000-8000-00805f9b34fb}_VID&0002054c_PID&09cc

I'm now very confused about what "Hide DS4" actually does. I think it's really not well documented.

If HidGuardian is not installed, "Hide DS4" tries to implement its own, very limited, exclusive mode.

If HidGuardian is installed, then what? The same setting forces DS4W to be the only app whitelisted by HidGuardian? In other words, for practical purposes, the setting should be enabled at all times?

mika-n commented 4 years ago

Uuuh. Right. My bad. I didn't realize that comment box here drops backslash chars. I changed the text to use CODE block, so now my original and the previous post should show special chars properly.

If HidGuardian is not installed, "Hide DS4" tries to implement its own, very limited, exclusive mode.

Yes. If you use "Hide DS4 Controller" option in DS4Windows settings then you don't need to use HidGuardian tool at all. DS4Windows app tries to hide the original physical HID gamepad object from all other apps. It does this by trying to open an EXCLUSIVE lock on the HID handle. This way all other apps may try to open a connection to the physical gamepad but opening should fail because only one process can have an exclusive lock on a handle Anyway. As you can see this also means that DS4Windows MUST BE the very first app using the physical gamepad because otherwise exclusive lock fails if some other app has already opened a shared connection to a gamepad.

AffectedDevices/Whitelisted sysreg entries have nothing to do with this DS4Win HideDS4Controller option.

If HidGuardian is installed, then what? The same setting forces DS4W to be the only app whitelisted by HidGuardian? In other words, for practical purposes, the setting should be enabled at all times?

If you use the HidGuardian tool created by Nefarious to hide certain devices (AffectedDevices sysreg) from apps (other than Whitelist sysreg) then you don't have to use HideDS4Controller option at all in DS4Windows because these two try to do the same but in a completely different way. In fact using both HideDS4Controller option and HidGuardian driver tool at the same time may lead to unexpected problems.

AffectedDevices and Whitelisted sysreg entries are the interface to control what HidGuardian tool should do (devices to be hidden from apps and specific processes being able to use the device).

Please see the following link for more info. It mentions that HidG and HideDS4Controller options are alternative solutions and should not be used both at the same time. https://github.com/Ryochan7/DS4Windows/wiki/Exclusive-Mode-(Hide-DS4-Controller-config-option)-tips-and-issues

Ryusennin commented 4 years ago

using both HideDS4Controller option and HidGuardian driver tool at the same time may lead to unexpected problems.

Thanks Mika for the clarification.

Ryochan7 commented 4 years ago

One big reason that the "Hide DS4 Controller" option is not enabled by default is that it used to be a very unsafe option. The routine was set up in a way that would frequently permanently disable the DS4 HID device so it could no longer be detected. The issue would then have to be fixed in the Windows Device Manager so the device would be usable again.

Another minor reason is because of UAC pop-ups. If exclusive access cannot be obtained in the first pass, DS4Windows will disable and then re-enable the DS4 HID device before it attempts to get exclusive access again. Performing that action requires administrator privileges. I normally run DS4Windows as the administrator so I don't encounter that problem.

One final reason that the option is not enabled by default is because that workaround does not work that well anymore. Many pieces of software interfere with obtaining exclusive access (Nvidia GeForce Experience suite for example) and there isn't much that can be done about it. Using HidGuardian is a more sure way to allow DS4Widows to obtain sole access to the DS4. However, Microsoft has to make using HidGuardian difficult as Windows updates can actually remove HidGuardian support; specifically, Windows updates can clear the UpperFilters registry value that is used to tell Windows to use HidGuardian as an HID filter driver.

Chrisnetika commented 4 years ago

Yea I notice even if i run DS4 as admin then plug in a controller a UAC still pops ups, other minor annoying thing is my game still picks up the "Wireless Controller" and lists it which is annoying bc when I try use bluetooth it has a habit switching to that controller zzz.

Ryochan7 commented 4 years ago

Yea I notice even if i run DS4 as admin then plug in a controller a UAC still pops ups

You might be listed as an admin user but that doesn't mean DS4Windows will run elevated. You have to explicitly tell Windows to run DS4Windows ad the Administrator either via the right click context menu or via compatibility settings.