[Wine-devel] [try 2] Changes for compatibility with old version of libusb

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Чт Июн 19 17:19:38 MSD 2008


----------- следующая часть -----------
From 9ef6bc00b7dc9a95807b00bd6192b57f309e9717 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Thu, 19 Jun 2008 17:10:18 +0400
Subject: [PATCH] Changes for compatibility with old version of libusb

---
 dlls/wineusbhub/wineusbhub.c    |   10 +++++-----
 dlls/wineusbhub/wineusbhub.spec |    2 +-
 programs/winedevice/device.c    |    6 +++---
 programs/wineusb/main.c         |    6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/dlls/wineusbhub/wineusbhub.c b/dlls/wineusbhub/wineusbhub.c
index 4c32813..0f3afb0 100644
--- a/dlls/wineusbhub/wineusbhub.c
+++ b/dlls/wineusbhub/wineusbhub.c
@@ -299,7 +299,7 @@ NTSTATUS WINAPI __wine_usbhub_dispatch_pnp( DEVICE_OBJECT *device, IRP *irp )
 }
 #endif
 
-DEVICE_OBJECT *__wine_usbhub_get_pdo( ULONG pdonum, ULONG location, ULONG devnum )
+DEVICE_OBJECT *__wine_usbhub_get_pdo( UCHAR *pdo_info )
 {
 #ifdef HAVE_USB_H
     static const WCHAR usbpdoW[] = {'\\','D','e','v','i','c','e','\\',
@@ -308,17 +308,17 @@ DEVICE_OBJECT *__wine_usbhub_get_pdo( ULONG pdonum, ULONG location, ULONG devnum
     UNICODE_STRING pdo_name;
     struct usb_bus *bus;
 
-
-    TRACE( "%u, %u, %u\n", pdonum, location, devnum );
+    TRACE( "%s\n", pdo_info );
 
     for (bus = usb_busses; bus; bus = bus->next)
         for (dev = bus->devices; dev; dev = dev->next)
-            if (bus->location == location && dev->devnum == devnum)
+            if (!strcmp( bus->dirname, pdo_info + 1 ) &&
+                    !strcmp( dev->filename, pdo_info + 2 + strlen( bus->dirname ) ))
             {
                 hubdrv.MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = __wine_usbhub_internal_ioctl;
                 hubdrv.MajorFunction[IRP_MJ_PNP] = __wine_usbhub_dispatch_pnp;
 
-                snprintfW( bufW, sizeof(bufW), usbpdoW, pdonum );
+                snprintfW( bufW, sizeof(bufW), usbpdoW, pdo_info[0] );
                 RtlInitUnicodeString( &pdo_name, bufW );
 
                 if (STATUS_SUCCESS == IoCreateDevice( &hubdrv, 0, &pdo_name, 0, 0, FALSE, &usbdev ))
diff --git a/dlls/wineusbhub/wineusbhub.spec b/dlls/wineusbhub/wineusbhub.spec
index e91487e..85e5361 100644
--- a/dlls/wineusbhub/wineusbhub.spec
+++ b/dlls/wineusbhub/wineusbhub.spec
@@ -4,4 +4,4 @@
 # All functions must be prefixed with '__wine_' (for internal functions)
 # or 'wine_' (for user-visible functions) to avoid namespace conflicts.
 
-@ cdecl __wine_usbhub_get_pdo(long long)
+@ cdecl __wine_usbhub_get_pdo(ptr)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index 6945f96..8813b05 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -43,7 +43,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(winedevice);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
 
-extern DEVICE_OBJECT *__wine_usbhub_get_pdo( ULONG pdonum, ULONG location, ULONG devnum );
+extern DEVICE_OBJECT *__wine_usbhub_get_pdo( UCHAR *pdo_info );
 extern NTSTATUS wine_ntoskrnl_main_loop( HANDLE stop_event );
 
 static WCHAR *driver_name;
@@ -287,7 +287,7 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
         {
             NTSTATUS (*AddDevice)( PDRIVER_OBJECT, PDEVICE_OBJECT ) = driver_extension.AddDevice;
             PDEVICE_OBJECT pdev_obj = NULL;
-            ULONG pdo_info[3];
+            UCHAR pdo_info[PATH_MAX + 3];
             data_size_t reply_size = 0;
 
             while (!reply_size)
@@ -301,7 +301,7 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
                 }
                 SERVER_END_REQ;
 
-            pdev_obj = __wine_usbhub_get_pdo( pdo_info[0], pdo_info[1], pdo_info[2] );
+            pdev_obj = __wine_usbhub_get_pdo( pdo_info );
             if (pdev_obj)
             {
                 WINE_TRACE( "calling AddDevice( %p, %p )\n", &driver_obj, pdev_obj );
diff --git a/programs/wineusb/main.c b/programs/wineusb/main.c
index beff003..3e1ebd9 100644
--- a/programs/wineusb/main.c
+++ b/programs/wineusb/main.c
@@ -109,7 +109,7 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
     {
 #ifdef HAVE_USB_H
         UNICODE_STRING drvname;
-        ULONG pdo_info[3] = { 0, 0, 0 };
+        UCHAR pdo_info[PATH_MAX + 3] = {0};
         struct usb_device *dev;
         struct usb_bus *bus;
 #endif
@@ -186,8 +186,8 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
                         }
                         /* FIXME: check if driver is loaded */
                         RtlInitUnicodeString( &drvname, (PWSTR)buf );
-                        pdo_info[1] = bus->location;
-                        pdo_info[2] = dev->devnum;
+                        strcpy( (char *)(pdo_info + 1), bus->dirname );
+                        strcpy( (char *)(pdo_info + 2 + strlen( bus->dirname )), dev->filename );
 
                         SERVER_START_REQ( call_add_device )
                         {
-- 
1.5.4.5.GIT



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