[Wine-patches] [eter-1.0.10 6/7] usbhub.sys: Start root-enumerated devices.

Alexander Morozov amorozov на etersoft.ru
Вт Июн 30 15:53:31 MSD 2009


----------- следующая часть -----------
From c66dd3a42a65054880bc9903791d69f853243f9d Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 30 Jun 2009 15:27:41 +0400
Subject: [eter-1.0.10 6/7] usbhub.sys: Start root-enumerated devices.

---
 dlls/usbhub.sys/usbhub.c |   66 ++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index f6efc71..96bf557 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -493,10 +493,46 @@ fail:
     return FALSE;
 }
 
+static void start_root_devices( DRIVER_OBJECT *driver_obj )
+{
+    static const WCHAR rootW[] = {'r','o','o','t',0};
+
+    SP_DEVINFO_DATA devInfo = { sizeof(devInfo), { 0 } };
+    HDEVINFO set;
+    DRIVER_OBJECT *driver;
+    DEVICE_OBJECT *pdo;
+    NTSTATUS status;
+    DWORD size, i = 0;
+    WCHAR *serviceW;
+
+    set = SetupDiGetClassDevsW( NULL, rootW, 0, DIGCF_ALLCLASSES );
+    if (set == INVALID_HANDLE_VALUE) return;
+    while (SetupDiEnumDeviceInfo( set, i++, &devInfo ))
+    {
+        SetupDiGetDeviceRegistryPropertyW( set, &devInfo, SPDRP_SERVICE,
+                NULL, NULL, 0, &size );
+        serviceW = HeapAlloc( GetProcessHeap(), 0, size );
+        if (serviceW == NULL) break;
+        if (SetupDiGetDeviceRegistryPropertyW( set, &devInfo, SPDRP_SERVICE,
+                NULL, (BYTE *)serviceW, size, NULL ) && start_service( serviceW ))
+        {
+            status = IoCreateDevice( driver_obj, 0, NULL, 0, 0, FALSE, &pdo );
+            if (status == STATUS_SUCCESS)
+            {
+                while (!(driver = __wine_get_driver_object( serviceW )))
+                    Sleep( 100 );
+                status = __wine_add_device( driver, pdo );
+                if (status == STATUS_SUCCESS && pdo->AttachedDevice != NULL)
+                    __wine_start_device( pdo->AttachedDevice );
+            }
+        }
+        HeapFree( GetProcessHeap(), 0, serviceW );
+    }
+    SetupDiDestroyDeviceInfoList( set );
+}
+
 static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
 {
-    static const WCHAR grdkeyW[] = {'G','r','d','K','e','y',0};
-    static const WCHAR nkeyW[] = {'N','K','e','y',0};
     static const WCHAR usbhub_started_eventW[] = {'_','_','w','i','n','e',
                                                   '_','U','s','b','h','u','b',
                                                   'S','t','a','r','t','e','d',0};
@@ -520,6 +556,8 @@ static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
     usb_find_busses();
     usb_find_devices();
 
+    start_root_devices( usbhubdrv );
+
     for (bus = usb_busses; bus; bus = bus->next)
         for (dev = bus->devices; dev; dev = dev->next)
             LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
@@ -528,30 +566,6 @@ static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
                     dev->descriptor.idVendor == instance->vid &&
                     dev->descriptor.idProduct == instance->pid)
                 {
-                    /* HACK for grdkey.sys */
-                    if (instance->vid == 0xa89 && start_service( grdkeyW ))
-                    {
-                        status = IoCreateDevice( hubdrv, 0, NULL, 0, 0, FALSE, &pdo );
-                        if (status != STATUS_SUCCESS) break;
-                        while (!(driver = __wine_get_driver_object( grdkeyW )))
-                            Sleep( 100 );
-                        status = __wine_add_device( driver, pdo );
-                        if (status != STATUS_SUCCESS) break;
-                        if (pdo->AttachedDevice)
-                            __wine_start_device( pdo->AttachedDevice );
-                    }
-                    /* HACK for nkey.sys */
-                    if (instance->vid == 0x14a8 && start_service( nkeyW ))
-                    {
-                        status = IoCreateDevice( hubdrv, 0, NULL, 0, 0, FALSE, &pdo );
-                        if (status != STATUS_SUCCESS) break;
-                        while (!(driver = __wine_get_driver_object( nkeyW )))
-                            Sleep( 100 );
-                        status = __wine_add_device( driver, pdo );
-                        if (status != STATUS_SUCCESS) break;
-                        if (pdo->AttachedDevice)
-                            __wine_start_device( pdo->AttachedDevice );
-                    }
                     if (start_service( instance->service ))
                     {
                         pdo = create_pdo( instance, hubdrv );
-- 
1.6.3.2



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