Zhiyi Zhang : hidclass.sys: Handle create existent device failure.

Alexandre Julliard julliard at winehq.org
Thu Mar 21 17:21:19 CDT 2019


Module: wine
Branch: master
Commit: 56b509a84a26576e4dbfe95b076e5463f2496b6f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=56b509a84a26576e4dbfe95b076e5463f2496b6f

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Mar 20 23:27:41 2019 +0800

hidclass.sys: Handle create existent device failure.

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

---

 dlls/hidclass.sys/device.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index 547c355..81d5c3c 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -90,26 +90,24 @@ NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device)
 
     RtlInitUnicodeString( &nameW, ext->device_name);
 
-    devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_HIDCLASS, NULL, NULL, DIGCF_DEVICEINTERFACE);
-    if (!devinfo)
+    devinfo = SetupDiCreateDeviceInfoList(&GUID_DEVCLASS_HIDCLASS, NULL);
+    if (devinfo == INVALID_HANDLE_VALUE)
     {
         FIXME( "failed to get ClassDevs %x\n", GetLastError());
         return STATUS_UNSUCCESSFUL;
     }
     Data.cbSize = sizeof(Data);
-    if (!SetupDiCreateDeviceInfoW(devinfo, ext->instance_id, &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)
+        if (!SetupDiRegisterDeviceInfo(devinfo, &Data, 0, NULL, NULL, NULL))
         {
-            SetupDiDestroyDeviceInfoList(devinfo);
-            return STATUS_SUCCESS;
+            FIXME( "failed to register device info %x\n", GetLastError());
+            goto error;
         }
-        FIXME( "failed to Create Device Info %x\n", GetLastError());
-        goto error;
     }
-    if (!SetupDiRegisterDeviceInfo( devinfo, &Data, 0, NULL, NULL, NULL ))
+    else if (GetLastError() != ERROR_DEVINST_ALREADY_EXISTS)
     {
-        FIXME( "failed to Register Device Info %x\n", GetLastError());
+        FIXME( "failed to create device info %x\n", GetLastError());
         goto error;
     }
     SetupDiDestroyDeviceInfoList(devinfo);




More information about the wine-cvs mailing list