Re: IRP_MJ_READ Problem
- From: "Alexander Grigoriev" <alegr@xxxxxxxxxxxxx>
- Date: Thu, 20 Oct 2005 09:04:42 -0700
If you have any IRP queue, which can be handled asynchronously, you MUST
call IoMarkIrpPending BEFORE the IRP is queued. After the IRP is queued, you
should NOT touch it.
If design of your Insert function doesn't actually queue the IRP if it
returns STATUS_SUCCESS, then it should not call IoMarkIrpPending for it. You
should not blindly assign Insert return code to Status, becaus the IRP may
not exist at that point (may be asynchronously completed).
By the way, you return STATUS_SUCCESS even if your IRP is unsuccessful, this
is what causes DV bugcheck. And NT_SUCCESS(STATUS_PENDING) is TRUE.
You should change your code to the following:
NTSTATUS OnDeviceRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
NTSTATUS status;
if(0 == m_lConnected)
{
status=STATUS_DEVICE_NOT_CONNECTED;
}
else
{
NTSTATUS status =m_pIrpQ->Insert(Irp);
if (STAUS_PENDING == status)
{
// IoMarkIrpPending should be done in Insert()
return status;
}
}
Irp->IoStatus.Status=status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
"Nadav" <Nadav@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F47A77BD-4C5B-49B6-A3B3-5D14D7D2BE4F@xxxxxxxxxxxxxxxx
> Hi,
>
> I have an upper-layer function driver, I am using DriverVerifier with this
> driver.
> DriverVerifier indicate a 224 BugCheck on my IRP_MJ_READ handler, BugCheck
> 224 reads: " (Fatal error) An IRP dispatch handler has returned a status
> that
> is inconsistent with the IRP's IoStatus.Status field. (Dispatch handler
> routine, IRP, IRP's IoStatus.Status, and returned Status specified.) ".
>
> Following is a code snippet of the IRP_MJ_READ handler, what is wrong with
> it? What am I missing here?
>
> NTSTATUS OnDeviceRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
> {
> if(0 == m_lConnected)
> Irp->IoStatus.Status=STATUS_DEVICE_NOT_CONNECTED;
> else
> Irp->IoStatus.Status=m_pIrpQ->Insert(Irp);//always return SUCCESS
> if(FALSE == NT_SUCCESS(Irp->IoStatus.Status))
> {
> IoCompleteRequest(Irp, IO_NO_INCREMENT);
> return STATUS_SUCCESS;
> }
> IoMarkIrpPending(Irp);
> return STATUS_PENDING;
> }
>
> Nadav
> http://www.sophin.com
.
- References:
- IRP_MJ_READ Problem
- From: Nadav
- IRP_MJ_READ Problem
- Prev by Date: Re: Kernel / user mode shared events and remote desktop
- Next by Date: Re: Custom Printer Driver
- Previous by thread: Re: IRP_MJ_READ Problem
- Next by thread: Re: IRP_MJ_READ Problem
- Index(es):
Relevant Pages
|