Aric Stewart : hidclass.sys: Use the instance id for the device link.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Apr 6 11:12:04 CDT 2016


Module: wine
Branch: master
Commit: 056425734912ec657bd2595360c82d6dc1c77691
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=056425734912ec657bd2595360c82d6dc1c77691

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Apr  5 08:45:48 2016 -0500

hidclass.sys: Use the instance id for the device link.

Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/hidclass.sys/device.c | 21 +++++++--------------
 dlls/hidclass.sys/hid.h    |  2 +-
 dlls/hidclass.sys/pnp.c    |  2 +-
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index aae4e5f..b137c9b 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -40,12 +40,7 @@ WINE_DECLARE_DEBUG_CHANNEL(hid_report);
 
 static const WCHAR device_name_fmtW[] = {'\\','D','e','v','i','c','e',
     '\\','H','I','D','#','%','p','&','%','p',0};
-static const WCHAR device_regname_fmtW[] = {'H','I','D','\\',
-    'v','i','d','_','%','0','4','x','&','p','i','d','_','%',
-    '0','4','x','&','%','s','\\','%','i','&','%','s',0};
-static const WCHAR device_link_fmtW[] = {'\\','?','?','\\','h','i','d','#',
-    'v','i','d','_','%','0','4','x','&','p','i','d','_','%',
-    '0','4','x','&','%','s','#','%','i','&','%','s','#','%','s',0};
+static const WCHAR device_link_fmtW[] = {'\\','?','?','\\','%','s','#','%','s',0};
 /* GUID_DEVINTERFACE_HID */
 static const WCHAR class_guid[] = {'{','4','D','1','E','5','5','B','2',
     '-','F','1','6','F','-','1','1','C','F','-','8','8','C','B','-','0','0',
@@ -83,10 +78,10 @@ NTSTATUS HID_CreateDevice(DEVICE_OBJECT *native_device, HID_MINIDRIVER_REGISTRAT
     return S_OK;
 }
 
-NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device, LPCWSTR serial, LPCWSTR index)
+NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device)
 {
-    WCHAR regname[255];
     WCHAR dev_link[255];
+    WCHAR *ptr;
     SP_DEVINFO_DATA Data;
     UNICODE_STRING nameW, linkW;
     NTSTATUS status;
@@ -97,9 +92,9 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device, LPCWSTR serial, LPCWSTR index)
     HidD_GetHidGuid(&hidGuid);
     ext = device->DeviceExtension;
 
-    sprintfW(dev_link, device_link_fmtW, ext->information.VendorID,
-        ext->information.ProductID, index, ext->information.VersionNumber, serial,
-        class_guid);
+    sprintfW(dev_link, device_link_fmtW, ext->instance_id, class_guid);
+    ptr = dev_link + 4;
+    do { if (*ptr == '\\') *ptr = '#'; } while (*ptr++);
     struprW(dev_link);
 
     RtlInitUnicodeString( &nameW, ext->device_name);
@@ -117,8 +112,6 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device, LPCWSTR serial, LPCWSTR index)
         return status;
     }
 
-    sprintfW(regname, device_regname_fmtW, ext->information.VendorID, ext->information.ProductID, index, ext->information.VersionNumber, serial);
-
     devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_HIDCLASS, NULL, NULL, DIGCF_DEVICEINTERFACE);
     if (!devinfo)
     {
@@ -126,7 +119,7 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device, LPCWSTR serial, LPCWSTR index)
         return GetLastError();
     }
     Data.cbSize = sizeof(Data);
-    if (!SetupDiCreateDeviceInfoW(devinfo, regname, &GUID_DEVCLASS_HIDCLASS, NULL, NULL, DICD_INHERIT_CLASSDRVS, &Data))
+    if (!SetupDiCreateDeviceInfoW(devinfo, ext->instance_id, &GUID_DEVCLASS_HIDCLASS, NULL, NULL, DICD_INHERIT_CLASSDRVS, &Data))
     {
         if (GetLastError() == ERROR_DEVINST_ALREADY_EXISTS)
         {
diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h
index 8d384c6..2820c9d 100644
--- a/dlls/hidclass.sys/hid.h
+++ b/dlls/hidclass.sys/hid.h
@@ -86,7 +86,7 @@ minidriver* find_minidriver(DRIVER_OBJECT* driver) DECLSPEC_HIDDEN;
 
 /* Internal device functions */
 NTSTATUS HID_CreateDevice(DEVICE_OBJECT *native_device, HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT **device) DECLSPEC_HIDDEN;
-NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device, LPCWSTR serial, LPCWSTR index) DECLSPEC_HIDDEN;
+NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
 void HID_DeleteDevice(HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
 void HID_StartDeviceThread(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
 
diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c
index fe3371f..d97184f 100644
--- a/dlls/hidclass.sys/pnp.c
+++ b/dlls/hidclass.sys/pnp.c
@@ -250,7 +250,7 @@ NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO)
     sprintfW(ext->instance_id, device_instanceid_fmtW, device_enumeratorW, ext->information.VendorID, ext->information.ProductID, interface, ext->information.VersionNumber, serial);
     sprintfW(ext->device_id, device_deviceid_fmtW, device_enumeratorW, ext->information.VendorID, ext->information.ProductID);
 
-    HID_LinkDevice(device, serial, interface);
+    HID_LinkDevice(device);
 
     ext->poll_interval = DEFAULT_POLL_INTERVAL;
 




More information about the wine-cvs mailing list