Hi all,
i am developing a USB upper filter client driver in which i need to send a request to the usb device(OUT endpoint) attached on receiving certain events.
i would like to know how to send the request from the filter driver to the lower drivers.
i am using USB HID filter driver sample from msdn. i am using UsbBuildInterruptOrBulkTransferRequest() to create the URB, and send to out pipe by calling WdfUsbTargetPipeSendUrbSynchronously() function.
now i am facing a small problem …
i get STATUS_INVALID_PARAMETER1 error for WdfUsbTargetDeviceCreateWithParameters() call.
parameter1 is the WDFDEVICE … i am using the sample code itself… i have not modified creation of the device object …
is there any way that the ‘Device’ parameter getting wrong … ?
please let me know if i have gone wrong anywhere …
my sample code is as below …
send_cmd(WDFDEVICE Device,
COMMAND_PKT *pcmd_pkt
)
{
NTSTATUS status = STATUS_SUCCESS;
PURB purb = NULL;
USBD_PIPE_HANDLE PipeHandle = NULL;
WDF_USB_DEVICE_CREATE_CONFIG Config;
//ULONG USBDClientContractVersion = 0;
WDFUSBINTERFACE UsbInterface = NULL;
WDF_OBJECT_ATTRIBUTES Attributes;
WDFUSBDEVICE UsbDevice = NULL;
UCHAR InterfaceIndex = 1;//Interface 1
WDFUSBPIPE Pipe = NULL;
UCHAR PipeIndex = 1; //Endpoint 2[OUT ep]
WDF_USB_PIPE_INFORMATION PipeInfo;
PDEVICE_CONTEXT pDeviceContext;
PIRP pirp;
CCHAR StackSize;
BOOLEAN ChargeQuota;
KdPrint((“send_read_command\n”));
#ifdef USB_INT_TRANSFER2
//=======1. Generate Pipe Handle=============================
WDF_USB_DEVICE_CREATE_CONFIG_INIT(//memset0, size, version update
&Config,
USBD_CLIENT_CONTRACT_VERSION_602
);
KdPrint((“Device: 0x%x\n”, Device));
//pDeviceContext = WdfObjectGet_DEVICE_CONTEXT(Device);
status = WdfUsbTargetDeviceCreateWithParameters(
Device,
&Config,
WDF_NO_OBJECT_ATTRIBUTES,//&Attributes,
&UsbDevice//&pDeviceContext->wdfusbdevice
);
if (!NT_SUCCESS(status))
{
KdPrint((“WdfUsbTargetDeviceCreateWithParameters failed %x\n”, status));
return status;
}
else
{
KdPrint((“WdfUsbTargetDeviceCreateWithParameters succcess\n”));
}
UsbInterface = WdfUsbTargetDeviceGetInterface(
UsbDevice,
InterfaceIndex
);
if(!UsbInterface)
{
KdPrint((“WdfUsbTargetDeviceGetInterface failed\n”));
return STATUS_INVALID_PARAMETER;//
}
else
KdPrint((“WdfUsbTargetDeviceGetInterface success\n”));
Pipe = WdfUsbInterfaceGetConfiguredPipe(
UsbInterface,
PipeIndex,
&PipeInfo);
if(!Pipe)
KdPrint((“WdfUsbInterfaceGetConfiguredPipe failed\n”));
KdPrint((“PipeInfo.EndpointAddress: 0x%x\n”, PipeInfo.EndpointAddress));
KdPrint((“PipeInfo.PipeType: 0x%x\n”, PipeInfo.PipeType));
KdPrint((“PipeInfo.SettingIndex: 0x%x\n”, PipeInfo.SettingIndex));
KdPrint((“PipeInfo.SettingIndex: 0x%x\n”, PipeInfo.SettingIndex));
KdPrint((“Pipe: 0x%x\n”, Pipe));
PipeHandle = WdfUsbTargetPipeWdmGetPipeHandle(
Pipe
);
KdPrint((“PipeInfo.PipeHandle: 0x%x\n”, PipeHandle));
//==========================================================
//=======2. create URB for Sending Interrupt Data============
UsbBuildInterruptOrBulkTransferRequest (
purb,
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
PipeHandle,
pcmd_pkt,//TransferBuffer
NULL,//TransferBufferMDL
sizeof(COMMAND_PKT),//TransferBufferLength
0,//TransferFlags
NULL//Link
);
KdPrint((“purb: 0x%x\n”, purb));
//==========================================================
//============3. Send Urb to Interrupt OUT Pipe=============
WdfUsbTargetPipeSendUrbSynchronously(
Pipe,
NULL,//Request: check
NULL,//Request Options: check
purb
);
//==========================================================