Hi Doron,
No log information is generated into the setupapi.dev.log file if I unplug the device from the Win10 machine. After isolating the code, I finally found setting up the EvtIoRead cause the problem.
WDF_IO_QUEUE_CONFIG_INIT(
&queueConfig,
WdfIoQueueDispatchSequential
);
queueConfig.EvtIoRead = Bthxbus_EvtIoRead;
status = WdfIoQueueCreate(
hDevice,
&queueConfig,
&attributes,
&hQueue
);
IfFailGoToExit(status, BTHX_BUS, “WdfIoQueueCreate for read failed”);
status = WdfDeviceConfigureRequestDispatching(
hDevice,
hQueue,
WdfRequestTypeRead
);
IfFailGoToExit(status, BTHX_BUS, “WdfDeviceConfigureRequestDispatching for read failed”);
VOID
Bthxbus_EvtIoRead(
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t Length
)
{
WDFDEVICE hDevice = NULL;
WDFIOTARGET hIoTarget = NULL;
UNREFERENCED_PARAMETER(Length);
BthxTraceFuncEntry();
hDevice = WdfIoQueueGetDevice(Queue);
hIoTarget = WdfDeviceGetIoTarget(hDevice);
WdfRequestFormatRequestUsingCurrentType(Request);
WdfRequestSetCompletionRoutine(Request, Bthxbus_EvtIoReadComplete, hDevice);
if (WdfRequestSend(Request, hIoTarget, NULL) == FALSE)
{
WdfRequestSetCompletionRoutine(Request, NULL, NULL);
WdfRequestComplete(Request, WdfRequestGetStatus(Request));
}
BthxTraceFuncExit();
}
VOID
Bthxbus_EvtIoReadComplete(
IN WDFREQUEST Request,
IN WDFIOTARGET Target,
IN PWDF_REQUEST_COMPLETION_PARAMS Params,
IN WDFCONTEXT Context
)
{
NTSTATUS status = Params->IoStatus.Status;
WDFDEVICE hDevice = Context;
WDFREQUEST hRequest = NULL;
PBTHXBUS_DEVICE_CONTEXT pDeviceContext = Bthxbus_GetDeviceContext(hDevice);
LONG lEnableHid = FALSE;
PMDL pMdl = NULL;
PUCHAR pbBuffer = NULL;
ULONG ulIndex = 0;
BOOLEAN bComplete = TRUE;
BOOLEAN bDown = FALSE;
UNREFERENCED_PARAMETER(Target);
BthxTraceFuncEntry();
… …
if (bComplete == TRUE)
{
WdfRequestComplete(Request, status);
}
BthxTraceFuncExit();
}