Need help passing on set feature request in KMDF

Hi,

I’m trying to make a kmdf driver that modifies the hid report descriptor of my device. I started with the hidusbfx2 sample. My device defaults to sending data via one collection and we send a set feature to put it into custom mode where it sends data via the second collection. I’ve got it modifying the report descriptor and the default collection works. My problem is that when I send the feature request to my WDFUSBDEVICE it returns with error 0xc0000001 (STATUS_UNSUCCESSFUL). I’ve tried everything I can think of to at least get a different ntstatus so I think there must be something fundamental that I don’t understand.

Here’s what my SendFeature function looks like:

NTSTATUS
SendFeatureCommand( IN WDFDEVICE Device,
IN UCHAR FeatureCommand,
IN PUCHAR CommandData )
{
NTSTATUS status = STATUS_SUCCESS;
ULONG bytesTransferred =0;
PDEVICE_EXTENSION devContext = NULL;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
WDF_REQUEST_SEND_OPTIONS sendOptions;

PAGED_CODE();

TraceEvents( TRACE_LEVEL_INFORMATION,
DBG_IOCTL,
“SendVendorCommand Enter\n” );

devContext = GetDeviceContext(Device);

TraceEvents( TRACE_LEVEL_INFORMATION, DBG_IOCTL,
" Command:0x%x, data: 0x%x\n",
FeatureCommand, *CommandData );

WDF_REQUEST_SEND_OPTIONS_INIT( &sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT );
WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT( &sendOptions, WDF_REL_TIMEOUT_IN_SEC( 5 ) );

WDF_USB_CONTROL_SETUP_PACKET_INIT_FEATURE( &controlSetupPacket,
BMREQUEST_TO_DEVICE,
USB_DEVICE_DESCRIPTOR_TYPE,
FeatureCommand,
TRUE );

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER( &memDesc, CommandData, sizeof(UCHAR) );

status = WdfUsbTargetDeviceSendControlTransferSynchronously( devContext->UsbDevice,
WDF_NO_HANDLE,
&sendOptions,
&controlSetupPacket,
&memDesc,
&bytesTransferred );

if( !NT_SUCCESS( status ) )
{
TraceEvents( TRACE_LEVEL_ERROR, DBG_IOCTL,
" Failed to set feature - 0x%x\n", status );
}

TraceEvents( TRACE_LEVEL_INFORMATION, DBG_IOCTL,
“SendVendorCommand Exit with status:0x%x\n”, status );

return status;
}

Thanks much for any help.
-Dan

Try !wdfkd.wdflogdump to see if the failure is coming from KMDF or the lower stack. !wdfkd.wdfusbdevice might give an indication to the state of the WDFUSBDEVICE.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@wacom.com
Sent: Monday, December 14, 2009 11:13 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need help passing on set feature request in KMDF

Hi,

I’m trying to make a kmdf driver that modifies the hid report descriptor of my device. I started with the hidusbfx2 sample. My device defaults to sending data via one collection and we send a set feature to put it into custom mode where it sends data via the second collection. I’ve got it modifying the report descriptor and the default collection works. My problem is that when I send the feature request to my WDFUSBDEVICE it returns with error 0xc0000001 (STATUS_UNSUCCESSFUL). I’ve tried everything I can think of to at least get a different ntstatus so I think there must be something fundamental that I don’t understand.

Here’s what my SendFeature function looks like:

NTSTATUS
SendFeatureCommand( IN WDFDEVICE Device,
IN UCHAR FeatureCommand,
IN PUCHAR CommandData )
{
NTSTATUS status = STATUS_SUCCESS;
ULONG bytesTransferred =0;
PDEVICE_EXTENSION devContext = NULL;
WDF_MEMORY_DESCRIPTOR memDesc;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
WDF_REQUEST_SEND_OPTIONS sendOptions;

PAGED_CODE();

TraceEvents( TRACE_LEVEL_INFORMATION,
DBG_IOCTL,
“SendVendorCommand Enter\n” );

devContext = GetDeviceContext(Device);

TraceEvents( TRACE_LEVEL_INFORMATION, DBG_IOCTL,
" Command:0x%x, data: 0x%x\n",
FeatureCommand, *CommandData );

WDF_REQUEST_SEND_OPTIONS_INIT( &sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT );
WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT( &sendOptions, WDF_REL_TIMEOUT_IN_SEC( 5 ) );

WDF_USB_CONTROL_SETUP_PACKET_INIT_FEATURE( &controlSetupPacket,
BMREQUEST_TO_DEVICE,
USB_DEVICE_DESCRIPTOR_TYPE,
FeatureCommand,
TRUE );

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER( &memDesc, CommandData, sizeof(UCHAR) );

status = WdfUsbTargetDeviceSendControlTransferSynchronously( devContext->UsbDevice,
WDF_NO_HANDLE,
&sendOptions,
&controlSetupPacket,
&memDesc,
&bytesTransferred );

if( !NT_SUCCESS( status ) )
{
TraceEvents( TRACE_LEVEL_ERROR, DBG_IOCTL,
" Failed to set feature - 0x%x\n", status );
}

TraceEvents( TRACE_LEVEL_INFORMATION, DBG_IOCTL,
“SendVendorCommand Exit with status:0x%x\n”, status );

return status;
}

Thanks much for any help.
-Dan


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer