[Wine-patches] [15/23] usbhub.sys: Partially implement IRP_MN_QUERY_ID handler.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пн Янв 19 18:24:51 MSK 2009


For eterhack branch
----------- следующая часть -----------
From 205bc0ffdfb0c66c78a104629041641861ef113a Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 14 Jan 2009 17:48:25 +0300
Subject: [PATCH] usbhub.sys: Partially implement IRP_MN_QUERY_ID handler.

---
 dlls/usbhub.sys/usbhub.c |   62 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 76c86a4..33992c4 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -250,7 +250,13 @@ NTSTATUS WINAPI __wine_usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
 
 NTSTATUS WINAPI __wine_usbhub_dispatch_pnp( DEVICE_OBJECT *device, IRP *irp )
 {
+    static const WCHAR device_idW[] = {'U','S','B','\\',
+                                       'V','i','d','_','%','0','4','x','&',
+                                       'P','i','d','_','%','0','4','x',0};
+
     IO_STACK_LOCATION *irpsp;
+    NTSTATUS status;
+    ULONG_PTR info = 0;
 
     TRACE( "%p, %p\n", device, irp );
 
@@ -258,11 +264,63 @@ NTSTATUS WINAPI __wine_usbhub_dispatch_pnp( DEVICE_OBJECT *device, IRP *irp )
     switch (irpsp->MinorFunction)
     {
     case IRP_MN_QUERY_DEVICE_RELATIONS:
+        status = irp->IoStatus.u.Status;
+        info = irp->IoStatus.Information;
+        break;
+    case IRP_MN_QUERY_ID:
+        switch (irpsp->Parameters.QueryId.IdType)
+        {
+        case BusQueryDeviceID:
+        {
+            struct PdoExtension *dx = device->DeviceExtension;
+            WCHAR *device_id = ExAllocatePool( PagedPool, sizeof(device_idW) );
+
+            if (device_id == NULL)
+            {
+                status = STATUS_INSUFFICIENT_RESOURCES;
+                break;
+            }
+            snprintfW( device_id, strlenW(device_idW) + 1, device_idW,
+                    dx->instance->vid, dx->instance->pid );
+            status = STATUS_SUCCESS;
+            info = (ULONG_PTR)device_id;
+            break;
+        }
+        case BusQueryInstanceID:
+        {
+            struct PdoExtension *dx = device->DeviceExtension;
+            char *instance_id;
+            ULONG len;
+            ULONG size;
+            WCHAR *instance_idW;
+
+            instance_id = strrchr( dx->instance->instance_id, '&' );
+            instance_id = instance_id ? (instance_id + 1) : dx->instance->instance_id;
+            len = strlen(instance_id) + 1;
+            size = len * sizeof(WCHAR);
+            instance_idW = ExAllocatePool( PagedPool, size );
+            if (instance_idW == NULL)
+            {
+                status = STATUS_INSUFFICIENT_RESOURCES;
+                break;
+            }
+            RtlMultiByteToUnicodeN( instance_idW, size, NULL, instance_id, len );
+            status = STATUS_SUCCESS;
+            info = (ULONG_PTR)instance_idW;
+            break;
+        }
+        default:
+            FIXME( "IRP_MN_QUERY_ID: IdType %u is not implemented\n",
+                    irpsp->Parameters.QueryId.IdType );
+            status = STATUS_NOT_IMPLEMENTED;
+        }
         break;
     default:
-        irp->IoStatus.u.Status = STATUS_SUCCESS;
-        irp->IoStatus.Information = 0;
+        status = STATUS_SUCCESS;
     }
+
+    irp->IoStatus.u.Status = status;
+    irp->IoStatus.Information = info;
     wine_complete_request( irp, IO_NO_INCREMENT );
 
     return STATUS_SUCCESS;
-- 
1.6.0.2.GIT



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