Hi,
I’m working the driver of the lower filter of the XUsb11.sys for the third party keypad. I hook the IOCTL_INTERNAL_USB_SUBMIT_URB/URB_FUNCTION_SELECT_CONFIGURATION and call WdfUsbTargetDeviceSelectConfig to get the WdfUsbPipe. After that, I call WdfIoTargetStart for the IoTarget that associated with the pipe. Then I configure the continuous reader for the pipe. All operation succeeds but the problem is that I can’t receive any data from the pipe. The MSDN says WdfIoTargetStart must be called in EvtD0Entry. But in my case, the pipe is not valid in EvtD0Entry. Is it the root cause that I can’t receive the data from that pipe? I dictate some code here for your referece.
//
// After configuration, we can retrieve the pipe handle of keypad for later
// usage. According to the doc, the pipe address of the keypad is always 0x84.
//
status = XFilter_GetKeypadPipe(hDevice,
XFILTER_KEYPAD_PIPE_ADDRESS,
&pDeviceContext->hKeypadPipe
);
//
// Start the pipe to transfer the request
//
status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDeviceContext->hKeypadPipe));
//
// Configure the keypad continuous reader
//
status = XFilter_ConfigureKeypadContinuousReader(
hDevice,
pDeviceContext->hKeypadPipe,
XFilter_EvtReadCompleteForKeypad
);
NTSTATUS
XFilter_GetKeypadPipe(
IN WDFDEVICE hDevice,
IN UCHAR ucKeypadPipeAddress,
OUT WDFUSBPIPE *phUsbPipe
)
{
pDeviceContext = XFilter_GetDeviceContext(hDevice);
ucInterfaceNumber = WdfUsbTargetDeviceGetNumInterfaces(pDeviceContext->usbDevice);
for (ucInterfaceIndex = 0; ucInterfaceIndex < ucInterfaceNumber && bFound == FALSE; ucInterfaceIndex++)
{
hUsbInterface = WdfUsbTargetDeviceGetInterface(pDeviceContext->usbDevice, ucInterfaceIndex);
ucPipeNumber = WdfUsbInterfaceGetNumConfiguredPipes(hUsbInterface);
for (ucPipeIndex = 0; ucPipeIndex < ucPipeNumber && bFound == FALSE; ucPipeIndex++)
{
WDF_USB_PIPE_INFORMATION_INIT(&usbPipeInfo);
hUsbPipe = WdfUsbInterfaceGetConfiguredPipe(hUsbInterface, ucPipeIndex, &usbPipeInfo);
if (usbPipeInfo.EndpointAddress == ucKeypadPipeAddress)
{
bFound = TRUE;
*phUsbPipe = hUsbPipe;
}
}
}
return status;
}
NTSTATUS
XFilter_ConfigureKeypadContinuousReader(
IN WDFDEVICE hDevice,
IN WDFUSBPIPE hUsbPipe,
IN PFN_WDF_USB_READER_COMPLETION_ROUTINE pfnUsbReaderCompletionRoutine
)
{
//
// Tell the framework that it’s okay to read less than
// MaximumPacketSize
//
WdfUsbTargetPipeSetNoMaximumPacketSizeCheck(hUsbPipe);
WDF_USB_PIPE_INFORMATION_INIT(&usbPipeInfo);
WdfUsbTargetPipeGetInformation(hUsbPipe, &usbPipeInfo);
WDF_USB_CONTINUOUS_READER_CONFIG_INIT(
&usbContinuousReaderConfig,
pfnUsbReaderCompletionRoutine,
hDevice,
1024
);
//
// Reader requests are not posted to the target automatically.
// Driver must explictly call WdfIoTargetStart to kick start the
// reader.
//
status = WdfUsbTargetPipeConfigContinuousReader(
hUsbPipe,
&usbContinuousReaderConfig
);
return status;
}