Windows 10 AU (1607) no longer allows the creation of an exclusive access SafeFileHandle with connected devices.

As of update 1607, kernel32.dll CreateFile() using only the flags GENERIC_READ and GENERIC_WRITE and 0 for dwShareMode no longer allow exclusive (non shared) access to devices needed in some circumstances.

An example of a device that is not allowing exclusive access any more is the Sony Dualshock 4 Game controller.

Any attempt to connect sets the IsInvalid field for the returned SafeFileHandle.

Example usage:

internal const uint GENERIC_READ = 0x80000000;
internal const uint GENERIC_WRITE = 0x40000000;
internal const Int32 OpenExisting = 3;

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern SafeFileHandle CreateFile(String lpFileName, UInt32 dwDesiredAccess, Int32 dwShareMode, IntPtr lpSecurityAttributes, Int32 dwCreationDisposition, Int32 dwFlagsAndAttributes, Int32 hTemplateFile);

hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OpenExisting, 0, 0);

 

Question Info


Last updated February 25, 2019 Views 6,118 Applies to:

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

For IM users; Until a solution is found, you may defer the update by following the steps here: http://www.thewindowsclub.com/defer-upgrades-in-windows-10

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Update:

The cause is once again, a so far undetermined Windows process is enumerating and connecting to all HID devices. This enumeration should be better filtered as it should only apply to certain GUID or device classes such as keyboards and mice and not also to devices that also appear in HID enumeration such as gamepads.

This issue was corrected once before in Windows 10 as the early releases had the same issue.

Current workaround is to disable then re-enable the HID device in device manager. Other programs will then be able to access it exclusively again.

This is not a fix, just a temporary workaround.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Small tool that automates the process in the video: https://inputmapper.com/downloads/download/5-tools/63-duleshock-4-exclusive-mode-tool

Must be run after each restart and before IM/DS4W/SCP is launched and requires elevation.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

didnt work for me

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Use the exe, its easier.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

UPDATE:
Now I tried this:
Close DS4 tools

Open Device Manager > HID devices > Game Controller > Disable > wait for refresh > Enable
Open DS4 tools
Now it works. Great!

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

One major issue from a development standpoint, when using this fix to allow exclusive access to the device again, the device no longer triggers proper WMI events under __InstanceCreationEvent or __InstanceDeletionEvent

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

This behavior change is not limited to game controllers. For example, the official control program for MSI laptop keyboard lightning, Keyboard Light Manager, fails to start following Anniversary Update, and tests with third party replacements expose the exclusive access issue as probable culprit.

The problem covers basically every program trying to obtain exclusive access to a device. Given that HID is just a protocol and some hardware implementations send differing input reports depending on output reports, usage of exclusive access is natural in such cases. Given the above, I find the lack of commentary from Microsoft about this change troubling.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Hey, this fix doesn't work for me. I have no bluetooth capabilities, and I only ever use a usb. No possible combination of your steps here fixes my problem. In my device manager, i have three controllers. I'm about to give up on pc gaming forever. asdfahwserlgvbqafv oawgi0jwh aesuipcip fgawserj ****

2 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.