[Wine-patches] [eter-1.0.10] usbhub.sys: Improve enum_reg_usb_devices().
Alexander Morozov
amorozov на etersoft.ru
Ср Июл 29 17:45:45 MSD 2009
Патч исправляет проблему с перечислением USB-устройств, появляющуюся при
запуске в .wine, в которой запускался eterhack:
err:usbhub:enum_usb_devices failed to enumerate USB devices
----------- следующая часть -----------
From 6b8b9f42a698ce256be54e3fb5699e973efaec96 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 29 Jul 2009 17:42:27 +0400
Subject: [eter-1.0.10] usbhub.sys: Improve enum_reg_usb_devices().
---
dlls/usbhub.sys/usbhub.c | 31 +++++++++++++------------------
1 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 96bf557..bd00246 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -413,20 +413,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 );
+ ret = SetupDiGetDeviceInstanceIdA( set, &devInfo, buf,
+ MAX_DEVICE_ID_LEN, NULL );
if (!ret) goto fail;
- str = strstr( buf, "Vid_" );
+ 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)
{
@@ -435,15 +433,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)
{
@@ -463,7 +453,11 @@ static BOOL enum_reg_usb_devices(void)
if (buf == NULL) goto fail;
ret = SetupDiGetDeviceRegistryPropertyW( set, &devInfo, SPDRP_SERVICE,
NULL, (BYTE *)buf, size, NULL );
- if (!ret) goto fail;
+ if (!ret)
+ {
+ HeapFree( GetProcessHeap(), 0, buf );
+ buf = NULL;
+ }
/* add DeviceInstance structure to Devices list */
instance = HeapAlloc( GetProcessHeap(), 0, sizeof(*instance) );
@@ -489,6 +483,7 @@ fail:
HeapFree( GetProcessHeap(), 0, instance->instance_id );
HeapFree( GetProcessHeap(), 0, instance->service );
list_remove( &instance->entry );
+ HeapFree( GetProcessHeap(), 0, instance );
}
return FALSE;
}
--
1.6.3.3
Подробная информация о списке рассылки Wine-patches