Created the Queue Config DeviceIoControl callback in the Add Device routine. below is the code.
//
// Configure the default queue to be Parallel.
//
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig,
WdfIoQueueDispatchParallel);
ioQueueConfig.EvtIoDeviceControl = UVCIoDeviceControl;
WDF_OBJECT_ATTRIBUTES_INIT(&deviceAttributes);
DbgPrint("%s: Line %d \n", FUNCTION, LINE);
__analysis_assume(ioQueueConfig.EvtIoStop != 0);
status = WdfIoQueueCreate(device,
&ioQueueConfig,
&deviceAttributes,
&queue // pointer to default queue
);
__analysis_assume(ioQueueConfig.EvtIoStop == 0);
if (!NT_SUCCESS(status)) {
DbgPrint("WdfIoQueueCreate failed %x ", status);
goto End;
}
In the DeviceIoControl Function Trying to get the URB from the IRP.
Forward the request with the IoCompletion routine.
VOID
UVCIoDeviceControl(
In WDFQUEUE Queue,
In WDFREQUEST Request,
In size_t OutputBufferLength,
In size_t InputBufferLength,
In ULONG IoControlCode
)
{
WDFDEVICE device;
PIRP wdmIrp;
WDF_REQUEST_PARAMETERS params;
PURB pUrb;
UNREFERENCED_PARAMETER(Queue);
UNREFERENCED_PARAMETER(InputBufferLength);
UNREFERENCED_PARAMETER(OutputBufferLength);
DbgPrint("UVCIoDeviceControl: Entry %d\n" ,__LINE__);
DbgPrint("%s: Line %d \n", __FUNCTION__, __LINE__);
//
// Get the WDM IRP
//
wdmIrp = WdfRequestWdmGetIrp(Request);
WDF_REQUEST_PARAMETERS_INIT(¶ms);
WdfRequestGetParameters(Request, ¶ms);
DbgPrint("UVCIoDeviceControl: IoControlCode %x\n", IoControlCode);
pUrb = URB_FROM_IRP(wdmIrp);
if ((pUrb->UrbHeader.Function == URB_FUNCTION_CONTROL_TRANSFER)
|| (pUrb->UrbHeader.Function == URB_FUNCTION_CONTROL_TRANSFER_EX))
{
DbgPrint("URB.Header.Status %x, \n", pUrb->UrbHeader.Status);
}
device = WdfIoQueueGetDevice(Queue);
FilterForwardRequestWithCompletion(Request, WdfDeviceGetIoTarget(device),
InternalIOCompletionRoutine, WDF_NO_CONTEXT);
return;
}
VOID
FilterForwardRequestWithCompletion(
IN WDFREQUEST Request,
IN WDFIOTARGET Target,
IN PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine,
IN WDFCONTEXT CompletionContext
)
{
NTSTATUS status;
DbgPrint("%s: Entry %d\n", __FUNCTION__, __LINE__);
WdfRequestFormatRequestUsingCurrentType(Request);
WdfRequestSetCompletionRoutine(Request, CompletionRoutine, CompletionContext);
if (!WdfRequestSend(Request, Target, WDF_NO_SEND_OPTIONS)) {
status = WdfRequestGetStatus(Request);
DbgPrint("WdfRequestSend failed - 0x % x\n", status);
WdfRequestComplete(Request, status);
}
return;
}