[Wine-patches] [eterhack 13/23] usbhub.sys: Implement IOCTL_USB_GET_NODE_INFORMATION handling.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:13 MSD 2009
---
dlls/usbhub.sys/usbhub.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
include/ddk/usb100.h | 10 +++++++++
include/ddk/usbioctl.h | 26 +++++++++++++++++++++++++
3 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index fb3f860..5b7dbae 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -46,6 +46,7 @@
#include "devguid.h"
#include "ddk/ntddk.h"
#include "ddk/usbdrivr.h"
+#include "ddk/usbioctl.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/list.h"
@@ -91,6 +92,51 @@ static void add_data( unsigned char **dst, ULONG *dst_size, const void *src, ULO
*dst_size -= copy;
}
+static NTSTATUS WINAPI usbhub_ioctl( DEVICE_OBJECT *device, IRP *irp )
+{
+ IO_STACK_LOCATION *irpsp;
+ NTSTATUS status = STATUS_UNSUCCESSFUL;
+ struct DeviceInstance *inst;
+ ULONG_PTR info = 0;
+
+ TRACE( "%p, %p\n", device, irp );
+
+ inst = ((struct PdoExtension *)device->DeviceExtension)->instance;
+ if (inst->service) goto done;
+ irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
+
+ switch (irpsp->Parameters.DeviceIoControl.IoControlCode)
+ {
+ case IOCTL_USB_GET_NODE_INFORMATION:
+ {
+ USB_NODE_INFORMATION *node_info = irp->AssociatedIrp.SystemBuffer;
+
+ if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(*node_info))
+ {
+ status = STATUS_BUFFER_TOO_SMALL;
+ break;
+ }
+ RtlZeroMemory( node_info, sizeof(*node_info) );
+ node_info->u.HubInformation.HubDescriptor.bDescriptorLength = 9;
+ node_info->u.HubInformation.HubDescriptor.bDescriptorType = 41;
+ node_info->u.HubInformation.HubDescriptor.bNumberOfPorts = 8;
+ status = STATUS_SUCCESS;
+ info = sizeof(*node_info);
+ break;
+ }
+ default:
+ FIXME( "IOCTL %08x is not implemented\n",
+ irpsp->Parameters.DeviceIoControl.IoControlCode );
+ }
+
+done:
+ irp->IoStatus.u.Status = status;
+ irp->IoStatus.Information = info;
+ IoCompleteRequest( irp, IO_NO_INCREMENT );
+
+ return status;
+}
+
#ifdef HAVE_LIBUSB_H
static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
@@ -1289,6 +1335,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
#ifdef HAVE_LIBUSB
HANDLE thread;
+ driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = usbhub_ioctl;
driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = usbhub_internal_ioctl;
driver->MajorFunction[IRP_MJ_PNP] = usbhub_dispatch_pnp;
diff --git a/include/ddk/usb100.h b/include/ddk/usb100.h
index 534dca1..8a868e0 100644
--- a/include/ddk/usb100.h
+++ b/include/ddk/usb100.h
@@ -96,6 +96,16 @@ typedef struct _USB_COMMON_DESCRIPTOR {
} USB_COMMON_DESCRIPTOR;
typedef struct _USB_COMMON_DESCRIPTOR *PUSB_COMMON_DESCRIPTOR;
+typedef struct _USB_HUB_DESCRIPTOR {
+ UCHAR bDescriptorLength;
+ UCHAR bDescriptorType;
+ UCHAR bNumberOfPorts;
+ USHORT wHubCharacteristics;
+ UCHAR bPowerOnToPowerGood;
+ UCHAR bHubControlCurrent;
+ UCHAR bRemoveAndPowerMask[64];
+} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
+
#include <poppack.h>
#endif
diff --git a/include/ddk/usbioctl.h b/include/ddk/usbioctl.h
index 34615fc..e2b914d 100644
--- a/include/ddk/usbioctl.h
+++ b/include/ddk/usbioctl.h
@@ -24,4 +24,30 @@
#define IOCTL_USB_GET_NODE_INFORMATION CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#include <pshpack1.h>
+
+typedef enum _USB_HUB_NODE {
+ UsbHub,
+ UsbMIParent
+} USB_HUB_NODE;
+
+typedef struct _USB_HUB_INFORMATION {
+ USB_HUB_DESCRIPTOR HubDescriptor;
+ BOOLEAN HubIsBusPowered;
+} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
+
+typedef struct _USB_MI_PARENT_INFORMATION {
+ ULONG NumberOfInterfaces;
+} USB_MI_PARENT_INFORMATION, *PUSB_MI_PARENT_INFORMATION;
+
+typedef struct _USB_NODE_INFORMATION {
+ USB_HUB_NODE NodeType;
+ union {
+ USB_HUB_INFORMATION HubInformation;
+ USB_MI_PARENT_INFORMATION MiParentInformation;
+ } u;
+} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
+
+#include <poppack.h>
+
#endif /* __USBIOCTL_H__ */
--
1.6.3.1
Подробная информация о списке рассылки Wine-patches