Hi,
I am facing an issue when performing ZwReadFile function. When i am trying to perform ZwReadFile operation, its hanging when it is in this ZwReadile function. I found this issue when i’m debugging my driver code. Please find below the code and WinDbg debug commands
VOID
RfmEvtRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)
{
NTSTATUS status;
PCAIFRFM_DEVICE_CONTEXT deviceData = 0;
PVOID outBuf = 0;
ULONG_PTR bytesRead = 0;
IO_STATUS_BLOCK ioStatus;
UCHAR buffer[4096];
UNREFERENCED_PARAMETER(Queue);
UNREFERENCED_PARAMETER(Length);
DbgBreakPoint();
RFMDBG((“\nRfmEvtRead Start\n”));
//
// Get a pointer to our device extension, just to show how it’s done.
// (get the WDFDEVICE from the WDFQUEUE, and the extension from the device)
//
deviceData = CaifRfmGetContextFromDevice(
WdfIoQueueGetDevice(Queue) );
status = WdfRequestRetrieveOutputBuffer(Request, 1, &outBuf, &Length);
if(!NT_SUCCESS(status))
{
#if DBG
DbgPrint(“CaifRFMEvtRead failed\n”);
#endif
WdfRequestCompleteWithInformation(Request, status, 0);
return;
}
#if DBG
DbgPrint(“CaifRFMEvtRead success\n”);
#endif
if(deviceData->FileHandle) {
status = ZwReadFile ((HANDLE)deviceData->FileHandle,
NULL,// Event,
NULL,// PIO_APC_ROUTINE ApcRoutine
NULL,// PVOID ApcContext
&ioStatus,
outBuf,
(ULONG)Length,
0, // ByteOffset
NULL // Key
);
if (!NT_SUCCESS(status)) {
DbgPrint(“\nZwReadFile failed with status 0x%x”, status);
}
else
{
DbgPrint(“\nZwReadFile Succeeded”);
}
status = ioStatus.Status;
bytesRead = ioStatus.Information;
//for(index = 0; index < 32; index++) {
DbgPrint(“outbuf = 0x%0x”, *(&outBuf));
}
RtlCopyMemory(outBuf, buffer, Length);
WdfRequestCompleteWithInformation(Request,
STATUS_SUCCESS,
0);
}
WinDbg output log:
// WinDbg
CaifRFM!RfmEvtRead+0xbf:
9547f8bf 6a00 push 0
kd> p
*** Fatal System Error: 0x0000007f
(0x00000008,0x801C6000,0x00000000,0x00000000)
WARNING: This break is not a step/trace completion.
The last command has been cleared to prevent
accidental continuation of this unrelated event.
Check the event, location and thread before resuming.
Break instruction exception - code 80000003 (first chance)
A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.
A fatal system error has occurred.
nt!RtlpBreakWithStatusInstruction:
82860d00 cc int 3
Regards,
Pradeep