[Wine-patches] [eterwine 3/3] mountmgr: Fix enumerating devices with specified bus number (eterbug #6508).

Alexander Morozov amorozov на etersoft.ru
Вт Май 15 20:05:49 MSK 2012


---
 dlls/mountmgr.sys/usbhub.c |   30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/dlls/mountmgr.sys/usbhub.c b/dlls/mountmgr.sys/usbhub.c
index d9475aa..78303b1 100644
--- a/dlls/mountmgr.sys/usbhub.c
+++ b/dlls/mountmgr.sys/usbhub.c
@@ -172,18 +172,16 @@ struct DeviceInstance *get_device_by_index( struct usb_device *device,
         ULONG connection_index, ULONG *addr )
 {
     struct DeviceInstance *instance;
-    struct usb_device *dev;
     ULONG index = 0;
 
-    for (dev = device->next; dev; dev = dev->next)
-        if (++index == connection_index)
-            LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
-                if (instance->dev == dev)
-                {
-                    if (addr)
-                        *addr = dev->devnum;
-                    return instance;
-                }
+    LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
+        if (instance->dev && instance->dev != device &&
+            instance->dev->bus == device->bus && ++index == connection_index)
+        {
+            if (addr)
+                *addr = instance->dev->devnum;
+            return instance;
+        }
     return NULL;
 }
 
@@ -279,7 +277,7 @@ static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
 {
     USB_NODE_CONNECTION_INFORMATION *conn_info = buff;
     ULONG index = 0;
-    struct usb_device *dev;
+    struct DeviceInstance *instance;
     NTSTATUS status = STATUS_UNSUCCESSFUL;
 
     if (size < sizeof(*conn_info))
@@ -288,12 +286,15 @@ static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
         conn_info->ConnectionIndex > NUMBER_OF_PORTS)
         return STATUS_INVALID_PARAMETER;
     RtlZeroMemory( (ULONG *)conn_info + 1, sizeof(*conn_info) - sizeof(ULONG) );
-    for (dev = inst->dev->next; dev; dev = dev->next)
-        if (++index == conn_info->ConnectionIndex)
+    LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
+    {
+        if (instance->dev && instance->dev != inst->dev &&
+            instance->dev->bus == inst->dev->bus &&
+            ++index == conn_info->ConnectionIndex)
         {
             usb_dev_handle *husb;
 
-            memcpy( &conn_info->DeviceDescriptor, &dev->descriptor,
+            memcpy( &conn_info->DeviceDescriptor, &instance->dev->descriptor,
                     sizeof(USB_DEVICE_DESCRIPTOR) );
             husb = usb_open( inst->dev );
             if (husb)
@@ -308,6 +309,7 @@ static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
             status = STATUS_SUCCESS;
             break;
         }
+    }
     return status;
 }
 
-- 
1.7.9.7



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