[Wine-patches] [eterhack 17/24] usbhub.sys: Check IoControlCode.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Ср Мар 4 12:25:26 MSK 2009
---
dlls/usbhub.sys/usbhub.c | 237 ++++++++++++++++++++++++---------------------
1 files changed, 126 insertions(+), 111 deletions(-)
diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 2fd7e38..8dedd64 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -33,13 +33,14 @@
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
+#include "winioctl.h"
#include "winreg.h"
#include "winsvc.h"
#include "winuser.h"
#include "setupapi.h"
#include "cfgmgr32.h"
#include "ddk/ntddk.h"
-#include "ddk/usb.h"
+#include "ddk/usbdrivr.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/list.h"
@@ -94,148 +95,162 @@ NTSTATUS WINAPI __wine_usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
urb = irpsp->Parameters.Others.Argument1;
- switch (urb->u.UrbHeader.Function)
+ switch (irpsp->Parameters.DeviceIoControl.IoControlCode)
{
- case URB_FUNCTION_SELECT_CONFIGURATION:
+ case IOCTL_INTERNAL_USB_SUBMIT_URB:
+ switch (urb->u.UrbHeader.Function)
{
- USB_CONFIGURATION_DESCRIPTOR *conf_desc =
- urb->u.UrbSelectConfiguration.ConfigurationDescriptor;
- usb_dev_handle *husb;
-
- TRACE( "URB_FUNCTION_SELECT_CONFIGURATION\n" );
-
- husb = usb_open( inst->dev );
- if (husb)
+ case URB_FUNCTION_SELECT_CONFIGURATION:
{
- int ret;
-
- ret = usb_set_configuration( husb, conf_desc->bConfigurationValue );
- if (ret < 0)
- ERR( "%s\n", usb_strerror() );
- else
- status = STATUS_SUCCESS;
- usb_close( husb );
- }
- }
- break;
- case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
- {
- struct _URB_CONTROL_DESCRIPTOR_REQUEST *request =
- &urb->u.UrbControlDescriptorRequest;
+ USB_CONFIGURATION_DESCRIPTOR *conf_desc =
+ urb->u.UrbSelectConfiguration.ConfigurationDescriptor;
+ usb_dev_handle *husb;
- TRACE( "URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n" );
+ TRACE( "URB_FUNCTION_SELECT_CONFIGURATION\n" );
- switch (request->DescriptorType)
- {
- case USB_DEVICE_DESCRIPTOR_TYPE:
- TRACE( "USB_DEVICE_DESCRIPTOR_TYPE\n" );
- if (request->TransferBuffer == NULL)
- break;
- if (sizeof(USB_DEVICE_DESCRIPTOR) <= request->TransferBufferLength)
+ husb = usb_open( inst->dev );
+ if (husb)
{
- memcpy( request->TransferBuffer, &inst->dev->descriptor,
- sizeof(USB_DEVICE_DESCRIPTOR) );
- status = STATUS_SUCCESS;
+ int ret;
+
+ ret = usb_set_configuration( husb,
+ conf_desc->bConfigurationValue );
+ if (ret < 0)
+ ERR( "%s\n", usb_strerror() );
+ else
+ status = STATUS_SUCCESS;
+ usb_close( husb );
}
- break;
- case USB_CONFIGURATION_DESCRIPTOR_TYPE:
- TRACE( "USB_CONFIGURATION_DESCRIPTOR_TYPE\n" );
- {
- unsigned int i, k;
- char *buf = request->TransferBuffer;
- struct usb_config_descriptor *conf = &inst->dev->config[0];
- struct usb_interface_descriptor *intf;
- struct usb_endpoint_descriptor *endp;
- int size = request->TransferBufferLength;
+ }
+ break;
+ case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
+ {
+ struct _URB_CONTROL_DESCRIPTOR_REQUEST *request =
+ &urb->u.UrbControlDescriptorRequest;
- /* FIXME: case of num_altsetting > 1 */
+ TRACE( "URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n" );
- if (buf == NULL)
+ switch (request->DescriptorType)
+ {
+ case USB_DEVICE_DESCRIPTOR_TYPE:
+ TRACE( "USB_DEVICE_DESCRIPTOR_TYPE\n" );
+ if (request->TransferBuffer == NULL)
break;
- add_data( &buf, &size, conf,
- sizeof(USB_CONFIGURATION_DESCRIPTOR) );
- if (size > 0 && conf->extra)
- add_data( &buf, &size, conf->extra, conf->extralen );
- for (i = 0; i < conf->bNumInterfaces; ++i)
+ if (sizeof(USB_DEVICE_DESCRIPTOR) <= request->TransferBufferLength)
{
- intf = &conf->interface[i].altsetting[0];
- if (size > 0)
- add_data( &buf, &size, intf,
- sizeof(USB_INTERFACE_DESCRIPTOR) );
- if (size > 0 && intf->extra)
- add_data( &buf, &size, intf->extra, intf->extralen );
- for (k = 0; k < intf->bNumEndpoints; ++k)
+ memcpy( request->TransferBuffer, &inst->dev->descriptor,
+ sizeof(USB_DEVICE_DESCRIPTOR) );
+ status = STATUS_SUCCESS;
+ }
+ break;
+ case USB_CONFIGURATION_DESCRIPTOR_TYPE:
+ TRACE( "USB_CONFIGURATION_DESCRIPTOR_TYPE\n" );
+ {
+ unsigned int i, k;
+ char *buf = request->TransferBuffer;
+ struct usb_config_descriptor *conf = &inst->dev->config[0];
+ struct usb_interface_descriptor *intf;
+ struct usb_endpoint_descriptor *endp;
+ int size = request->TransferBufferLength;
+
+ /* FIXME: case of num_altsetting > 1 */
+
+ if (buf == NULL)
+ break;
+ add_data( &buf, &size, conf,
+ sizeof(USB_CONFIGURATION_DESCRIPTOR) );
+ if (size > 0 && conf->extra)
+ add_data( &buf, &size, conf->extra, conf->extralen );
+ for (i = 0; i < conf->bNumInterfaces; ++i)
{
- endp = &intf->endpoint[k];
+ intf = &conf->interface[i].altsetting[0];
if (size > 0)
- add_data( &buf, &size, endp,
- sizeof(USB_ENDPOINT_DESCRIPTOR) );
- if (size > 0 && endp->extra)
- add_data( &buf, &size, endp->extra, endp->extralen );
+ add_data( &buf, &size, intf,
+ sizeof(USB_INTERFACE_DESCRIPTOR) );
+ if (size > 0 && intf->extra)
+ add_data( &buf, &size, intf->extra, intf->extralen );
+ for (k = 0; k < intf->bNumEndpoints; ++k)
+ {
+ endp = &intf->endpoint[k];
+ if (size > 0)
+ add_data( &buf, &size, endp,
+ sizeof(USB_ENDPOINT_DESCRIPTOR) );
+ if (size > 0 && endp->extra)
+ add_data( &buf, &size, endp->extra,
+ endp->extralen );
+ }
}
+ status = STATUS_SUCCESS;
}
- status = STATUS_SUCCESS;
+ break;
+ default:
+ FIXME( "unsupported descriptor type %x\n",
+ request->DescriptorType );
}
- break;
- default:
- FIXME( "unsupported descriptor type %x\n", request->DescriptorType );
}
- }
- break;
- case URB_FUNCTION_VENDOR_DEVICE:
- case URB_FUNCTION_VENDOR_INTERFACE:
- case URB_FUNCTION_VENDOR_ENDPOINT:
- {
- usb_dev_handle *husb;
- struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST *request =
- &urb->u.UrbControlVendorClassRequest;
+ break;
+ case URB_FUNCTION_VENDOR_DEVICE:
+ case URB_FUNCTION_VENDOR_INTERFACE:
+ case URB_FUNCTION_VENDOR_ENDPOINT:
+ {
+ usb_dev_handle *husb;
+ struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST *request =
+ &urb->u.UrbControlVendorClassRequest;
- TRACE( "URB_FUNCTION_VENDOR_*\n" );
+ TRACE( "URB_FUNCTION_VENDOR_*\n" );
- husb = usb_open( inst->dev );
- if (husb)
- {
- UCHAR req_type = request->RequestTypeReservedBits | (2 << 5);
- char *buf;
- int ret;
-
- if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_INTERFACE)
- req_type |= 1;
- else if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_ENDPOINT)
- req_type |= 2;
- buf = HeapAlloc( GetProcessHeap(), 0, request->TransferBufferLength );
- if (buf != NULL)
+ husb = usb_open( inst->dev );
+ if (husb)
{
- memcpy( buf, request->TransferBuffer, request->TransferBufferLength );
- if (request->TransferFlags & USBD_TRANSFER_DIRECTION_IN)
- req_type |= (1 << 7);
- ret = usb_control_msg( husb, req_type, request->Request, request->Value,
- request->Index, buf, request->TransferBufferLength, 1000 );
- if (ret < 0)
- ERR( "%s\n", usb_strerror() );
- else
+ UCHAR req_type = request->RequestTypeReservedBits | (2 << 5);
+ char *buf;
+ int ret;
+
+ if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_INTERFACE)
+ req_type |= 1;
+ else if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_ENDPOINT)
+ req_type |= 2;
+ buf = HeapAlloc( GetProcessHeap(), 0,
+ request->TransferBufferLength );
+ if (buf != NULL)
{
+ memcpy( buf, request->TransferBuffer,
+ request->TransferBufferLength );
if (request->TransferFlags & USBD_TRANSFER_DIRECTION_IN)
+ req_type |= (1 << 7);
+ ret = usb_control_msg( husb, req_type, request->Request,
+ request->Value, request->Index, buf,
+ request->TransferBufferLength, 1000 );
+ if (ret < 0)
+ ERR( "%s\n", usb_strerror() );
+ else
{
- request->TransferBufferLength =
- (ret <= request->TransferBufferLength) ?
- ret : request->TransferBufferLength;
- memcpy( request->TransferBuffer, buf,
- request->TransferBufferLength );
+ if (request->TransferFlags & USBD_TRANSFER_DIRECTION_IN)
+ {
+ request->TransferBufferLength =
+ (ret <= request->TransferBufferLength) ?
+ ret : request->TransferBufferLength;
+ memcpy( request->TransferBuffer, buf,
+ request->TransferBufferLength );
+ }
+ status = STATUS_SUCCESS;
}
- status = STATUS_SUCCESS;
+ HeapFree( GetProcessHeap(), 0, buf );
}
- HeapFree( GetProcessHeap(), 0, buf );
+ usb_close( husb );
}
- usb_close( husb );
}
+ break;
+ default:
+ FIXME( "unsupported URB function %x\n", urb->u.UrbHeader.Function );
}
+ urb->u.UrbHeader.Status = status;
break;
default:
- FIXME( "unsupported URB function %x\n", urb->u.UrbHeader.Function );
+ FIXME( "IOCTL %08x is not implemented\n",
+ irpsp->Parameters.DeviceIoControl.IoControlCode );
}
- urb->u.UrbHeader.Status = status;
irp->IoStatus.u.Status = status;
irp->IoStatus.Information = 0;
wine_complete_request( irp, IO_NO_INCREMENT );
--
1.6.1.3.GIT
Подробная информация о списке рассылки Wine-patches