[Wine-patches] [eterhack 18/23] usbhub.sys: Start root-enumerated devices.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:18 MSD 2009
---
dlls/usbhub.sys/usbhub.c | 42 +++++++++++++++++++++++++++++++++---------
1 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index ad1e2f7..c2e1051 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -1323,31 +1323,54 @@ done:
if (instance_idW) HeapFree( GetProcessHeap(), 0, instance_idW );
}
-static void start_device_drivers( DRIVER_OBJECT *hubdrv )
+static void start_root_devices( DRIVER_OBJECT *driver_obj )
{
- static const WCHAR grdkeyW[] = {'G','r','d','K','e','y',0};
+ static const WCHAR rootW[] = {'r','o','o','t',0};
- struct DeviceInstance *instance;
+ SP_DEVINFO_DATA devInfo = { sizeof(devInfo), { 0 } };
+ HDEVINFO set;
DRIVER_OBJECT *driver;
DEVICE_OBJECT *pdo;
NTSTATUS status;
+ DWORD size, i = 0;
+ WCHAR *serviceW;
- LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
+ set = SetupDiGetClassDevsW( NULL, rootW, 0, DIGCF_ALLCLASSES );
+ if (set == INVALID_HANDLE_VALUE) return;
+ while (SetupDiEnumDeviceInfo( set, i++, &devInfo ))
{
- if (instance->service == NULL || instance->dev == NULL) continue;
- /* HACK for grdkey.sys */
- if (instance->vid == 0xa89 && start_service( grdkeyW ))
+ 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( hubdrv, 0, NULL, 0, 0, FALSE, &pdo );
+ status = IoCreateDevice( driver_obj, 0, NULL, 0, 0, FALSE, &pdo );
if (status == STATUS_SUCCESS)
{
- while (!(driver = __wine_get_driver_object( grdkeyW )))
+ 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 void start_device_drivers( DRIVER_OBJECT *hubdrv )
+{
+ struct DeviceInstance *instance;
+ DRIVER_OBJECT *driver;
+ DEVICE_OBJECT *pdo;
+ NTSTATUS status;
+
+ LIST_FOR_EACH_ENTRY( instance, &Devices, struct DeviceInstance, entry )
+ {
+ if (instance->service == NULL || instance->dev == NULL) continue;
if (start_service( instance->service ))
{
pdo = create_pdo( instance, hubdrv );
@@ -1457,6 +1480,7 @@ static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
dev->descriptor.idProduct, dev );
}
#endif
+ start_root_devices( usbhubdrv );
start_device_drivers( usbhubdrv );
end:
event = CreateEventW( NULL, TRUE, FALSE, usbhub_started_eventW );
--
1.6.3.1
Подробная информация о списке рассылки Wine-patches