Skip to content

Commit

Permalink
windows: Always open with sharing enabled
Browse files Browse the repository at this point in the history
In the past, there was desire to make hid_open() open devices
exclusively, preventing devices from being opened more than once.
Unfortunately, recent versions of Windows have made this largely
impossible for many devices, as it appears that Windows itself is
holding certain HID devices open or preventing them from being
opened in exclusive mode.

This patch will always open devices in SHARED mode on Windows.
  • Loading branch information
signal11 committed Mar 3, 2016
1 parent d17db57 commit b5b2e17
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions windows/hid.c
Expand Up @@ -222,9 +222,7 @@ static HANDLE open_device(const char *path, BOOL enumerate)
{
HANDLE handle;
DWORD desired_access = (enumerate)? 0: (GENERIC_WRITE | GENERIC_READ);
DWORD share_mode = (enumerate)?
FILE_SHARE_READ|FILE_SHARE_WRITE:
FILE_SHARE_READ;
DWORD share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;

handle = CreateFileA(path,
desired_access,
Expand Down

0 comments on commit b5b2e17

Please sign in to comment.