[Wine-patches] [eterhack 14/23] usbhub.sys: Simplify enum_reg_usb_devices().

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:14 MSD 2009


---
 dlls/usbhub.sys/usbhub.c |   30 ++++++++----------------------
 1 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 5b7dbae..81e5aa8 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -1098,24 +1098,18 @@ static BOOL enum_reg_usb_devices(void)
 
     while (SetupDiEnumDeviceInfo( set, i++, &devInfo ))
     {
-        /* get VID and PID */
-        SetupDiGetDeviceRegistryPropertyA( set, &devInfo, SPDRP_HARDWAREID,
-                NULL, NULL, 0, &size );
-        buf = HeapAlloc( GetProcessHeap(), 0, size );
+        /* get VID, PID and instance ID */
+        buf = HeapAlloc( GetProcessHeap(), 0, MAX_DEVICE_ID_LEN );
         if (buf == NULL) goto fail;
-        ret = SetupDiGetDeviceRegistryPropertyA( set, &devInfo, SPDRP_HARDWAREID,
-                NULL, (BYTE *)buf, size, NULL );
-        if (!ret)
-        {
-            HeapFree( GetProcessHeap(), 0, buf );
-            continue;
-        }
-        str = strstr( buf, "Vid_" );
+        ret = SetupDiGetDeviceInstanceIdA( set, &devInfo, buf,
+                MAX_DEVICE_ID_LEN, NULL );
+        if (!ret) goto fail;
+        str = strstr( buf, "VID_" );
         if (str != NULL)
         {
             str += 4;
             vid = strtol( str, NULL, 16 );
-            str = strstr( str, "Pid_" );
+            str = strstr( str, "PID_" );
         }
         if (str == NULL)
         {
@@ -1124,15 +1118,7 @@ static BOOL enum_reg_usb_devices(void)
         }
         str += 4;
         pid = strtol( str, NULL, 16 );
-        HeapFree( GetProcessHeap(), 0, buf );
-
-        /* get instance ID */
-        buf = HeapAlloc( GetProcessHeap(), 0, MAX_DEVICE_ID_LEN );
-        if (buf == NULL) goto fail;
-        ret = SetupDiGetDeviceInstanceIdA( set, &devInfo, buf,
-                MAX_DEVICE_ID_LEN, NULL );
-        if (!ret) goto fail;
-        str = strrchr( buf, '\\' );
+        str = strrchr( str, '\\' );
         if (str != NULL) ++str;
         if (str == NULL || *str == 0)
         {
-- 
1.6.3.1



Подробная информация о списке рассылки Wine-patches