[Wine-patches] [eterhack 5/5] Add hack for Consultant+ for flash drive (eterbug #2581).

Alexander Morozov amorozov на etersoft.ru
Вт Июн 23 16:16:52 MSD 2009


---
 dlls/usbhub.sys/usbhub.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/wine.inf.in        |    2 ++
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index b468625..65b0740 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -1442,12 +1442,52 @@ static char *new_instance_id( USHORT vid, USHORT pid )
     return ret;
 }
 
+#ifdef HAVE_LIBUSB_H
+
+static BOOL is_mass_storage( libusb_device *dev )
+{
+    struct libusb_config_descriptor *conf;
+    int i, k;
+    BOOL ret = FALSE;
+
+    if (libusb_get_active_config_descriptor( dev, &conf ))
+        return FALSE;
+    for (i = 0; !ret && i < conf->bNumInterfaces; ++i)
+        for (k = 0; !ret && k < conf->interface[i].num_altsetting; ++k)
+            if (conf->interface[i].altsetting[k].bInterfaceClass == 8)
+                ret = TRUE;
+    libusb_free_config_descriptor( conf );
+    return ret;
+}
+
+#else
+
+static BOOL is_mass_storage( struct usb_device *dev )
+{
+    struct usb_config_descriptor *conf = &dev->config[0];
+    int i, k;
+    BOOL ret = FALSE;
+
+    for (i = 0; !ret && i < conf->bNumInterfaces; ++i)
+        for (k = 0; !ret && k < conf->interface[i].num_altsetting; ++k)
+            if (conf->interface[i].altsetting[k].bInterfaceClass == 8)
+                ret = TRUE;
+    return ret;
+}
+
+#endif
+
 static void register_usb_device( USHORT vid, USHORT pid, void *dev )
 {
     static const WCHAR id_fmtW[] = {'U','S','B',
                                     '\\','V','i','d','_','%','0','4','x',
                                     '&','P','i','d','_','%','0','4','x',
                                     '\\','%','s',0};
+    static const WCHAR driverW[] = {'{','3','6','F','C','9','E','6','0','-',
+                                    'C','4','6','5','-','1','1','C','F','-',
+                                    '8','0','5','6','-','4','4','4','5',
+                                    '5','3','5','4','0','0','0','0','}',
+                                    '\\','0','0','0','0',0};
 
     struct DeviceInstance *instance;
     HDEVINFO set = INVALID_HANDLE_VALUE;
@@ -1488,7 +1528,13 @@ static void register_usb_device( USHORT vid, USHORT pid, void *dev )
     devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
     if (SetupDiCreateDeviceInfoW( set, devnameW, &GUID_DEVCLASS_USB,
             NULL, NULL, 0, &devInfo ))
+    {
         SetupDiRegisterDeviceInfo( set, &devInfo, 0, NULL, NULL, NULL );
+        /* This is need for Consultant+ for flash drive */
+        if (is_mass_storage( dev ))
+            SetupDiSetDeviceRegistryPropertyW( set, &devInfo, SPDRP_DRIVER,
+                    (BYTE *)driverW, sizeof(driverW) );
+    }
 done:
     if (set != INVALID_HANDLE_VALUE)
         SetupDiDestroyDeviceInfoList( set );
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index 3045183..46bb3e8 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -395,6 +395,8 @@ HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"StemmerClas
 HKLM,System\CurrentControlSet\Control\ContentIndex\Language\Neutral,"Locale",0x10003,0
 
 [ControlClass]
+HKLM,System\CurrentControlSet\Control\Class\{36fc9e60-c465-11cf-8056-444553540000},"Class",,"USB"
+HKLM,System\CurrentControlSet\Control\Class\{36fc9e60-c465-11cf-8056-444553540000}\0000,,,
 HKLM,System\CurrentControlSet\Control\Class\{4d36e978-e325-11ce-bfc1-08002be10318},,,"Ports (COM & LPT)"
 HKLM,System\CurrentControlSet\Control\Class\{4d36e978-e325-11ce-bfc1-08002be10318},"Class",,"Ports"
 
-- 
1.6.3.2



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