Hi All,

What is the difference between setting Irp->IoStatus.Status and the Dipatch
function return value?

I have a little trouble seeing the difference between those, as they seem to
fulfil the same functionality, ie telling the system about the status of the
Irp.

kind regards,
Bruno.

Re: Irp->IoStatus.Status vs return value? by Calvin

Calvin
Wed May 25 13:34:15 CDT 2005

Status block indicates the final completion status of an IRP. RC of dispatch
routine may not be the final code if you returned PENDING. On the flip
side, if you return RC code other than PENDING, it means you finally
complete the IRP, so the Status block should equal to your dispatch routine
RC, or DV will assert.

--
Calvin Guan Windows DDK MVP
Enterprise Network Controller Engineering
Broadcom Corporation www.broadcom.com


"Bruno van Dooren" <microvax@hotmail.com> wrote in message
news:OB4EJFVYFHA.2380@tk2msftngp13.phx.gbl...
> Hi All,
>
> What is the difference between setting Irp->IoStatus.Status and the
> Dipatch function return value?
>
> I have a little trouble seeing the difference between those, as they seem
> to fulfil the same functionality, ie telling the system about the status
> of the Irp.
>
> kind regards,
> Bruno.
>



Re: Irp->IoStatus.Status vs return value? by Bruno

Bruno
Wed May 25 13:50:15 CDT 2005

Thanks.
PENDING was the only difference I could see, but i didn't know if there were
other differences.

does this mean that driver verifier might bugcheck in the following example
if the next lower device (and as a result IoCallDriver?) returns an error
status?

NTSTATUS HandleQryRemoveDevice(IN PDEVICE_OBJECT Fdo, PIRP Irp)
{
NTSTATUS status = STATUS_SUCCESS;
Irp->IoStatus.Status = STATUS_SUCCESS;
...

IoSkipCurrentIrpStackLocation(Irp);
PDEVICE_EXTENSION deviceExtension =
(PDEVICE_EXTENSION) Fdo->DeviceExtension;

return IoCallDriver(deviceExtension->LowerDeviceObject, Irp);
}

"Calvin Guan" <hguan@nospam.broadcom.com> wrote in message
news:eLgnehVYFHA.2996@TK2MSFTNGP10.phx.gbl...
> Status block indicates the final completion status of an IRP. RC of
> dispatch routine may not be the final code if you returned PENDING. On
> the flip side, if you return RC code other than PENDING, it means you
> finally complete the IRP, so the Status block should equal to your
> dispatch routine RC, or DV will assert.
>
> --
> Calvin Guan Windows DDK MVP
> Enterprise Network Controller Engineering
> Broadcom Corporation www.broadcom.com
>
>
> "Bruno van Dooren" <microvax@hotmail.com> wrote in message
> news:OB4EJFVYFHA.2380@tk2msftngp13.phx.gbl...
>> Hi All,
>>
>> What is the difference between setting Irp->IoStatus.Status and the
>> Dipatch function return value?
>>
>> I have a little trouble seeing the difference between those, as they seem
>> to fulfil the same functionality, ie telling the system about the status
>> of the Irp.
>>
>> kind regards,
>> Bruno.
>>
>
>



Re: Irp->IoStatus.Status vs return value? by Maxim

Maxim
Wed May 25 14:15:47 CDT 2005

> What is the difference between setting Irp->IoStatus.Status and the Dipatch
> function return value?

The Dispatch function's return value can be STATUS_PENDING. This is the main
difference (and the main use of this return value).

The Dispatch function can finish with must either:
- call IoCompleteRequest inline, filling ->IoStatus before it. In this case,
the return value must be the same as ->IoStatus.Status
- do "return IoCallDriver". In this case, neither IoCompleteRequest nor
IoMarkIrpPending can be called.
- do IoMarkIrpPending and return STATUS_PENDING. IoCompleteRequest will be
called by some other routine later.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Irp->IoStatus.Status vs return value? by Maxim

Maxim
Wed May 25 14:16:56 CDT 2005

> NTSTATUS HandleQryRemoveDevice(IN PDEVICE_OBJECT Fdo, PIRP Irp)
> {
> NTSTATUS status = STATUS_SUCCESS;
> Irp->IoStatus.Status = STATUS_SUCCESS;
> ...
>
> IoSkipCurrentIrpStackLocation(Irp);
> PDEVICE_EXTENSION deviceExtension =
> (PDEVICE_EXTENSION) Fdo->DeviceExtension;
>
> return IoCallDriver(deviceExtension->LowerDeviceObject, Irp);
> }

This code is fine.
What is NOT fine is:

IoMarkIrpPending(Irp);
return IoCallDriver(..);

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Irp->IoStatus.Status vs return value? by Calvin

Calvin
Wed May 25 14:19:10 CDT 2005

> does this mean that driver verifier might bugcheck in the following
> example if the next lower device (and as a result IoCallDriver?) returns
> an error status?

Shouldn't bugcheck. The lower driver(s) should take care of the Status
Block.

--
Calvin Guan Windows DDK MVP
Enterprise Network Controller Engineering
Broadcom Corporation www.broadcom.com


"Bruno van Dooren" <bruno_nos_pam_van_dooren@hotmail.com> wrote in message
news:uHK1ZqVYFHA.3220@TK2MSFTNGP14.phx.gbl...
> Thanks.
> PENDING was the only difference I could see, but i didn't know if there
> were other differences.
>
> does this mean that driver verifier might bugcheck in the following
> example if the next lower device (and as a result IoCallDriver?) returns
> an error status?
>
> NTSTATUS HandleQryRemoveDevice(IN PDEVICE_OBJECT Fdo, PIRP Irp)
> {
> NTSTATUS status = STATUS_SUCCESS;
> Irp->IoStatus.Status = STATUS_SUCCESS;
> ...
>
> IoSkipCurrentIrpStackLocation(Irp);
> PDEVICE_EXTENSION deviceExtension =
> (PDEVICE_EXTENSION) Fdo->DeviceExtension;
>
> return IoCallDriver(deviceExtension->LowerDeviceObject, Irp);
> }
>
> "Calvin Guan" <hguan@nospam.broadcom.com> wrote in message
> news:eLgnehVYFHA.2996@TK2MSFTNGP10.phx.gbl...
>> Status block indicates the final completion status of an IRP. RC of
>> dispatch routine may not be the final code if you returned PENDING. On
>> the flip side, if you return RC code other than PENDING, it means you
>> finally complete the IRP, so the Status block should equal to your
>> dispatch routine RC, or DV will assert.
>>
>> --
>> Calvin Guan Windows DDK MVP
>> Enterprise Network Controller Engineering
>> Broadcom Corporation www.broadcom.com
>>
>>
>> "Bruno van Dooren" <microvax@hotmail.com> wrote in message
>> news:OB4EJFVYFHA.2380@tk2msftngp13.phx.gbl...
>>> Hi All,
>>>
>>> What is the difference between setting Irp->IoStatus.Status and the
>>> Dipatch function return value?
>>>
>>> I have a little trouble seeing the difference between those, as they
>>> seem to fulfil the same functionality, ie telling the system about the
>>> status of the Irp.
>>>
>>> kind regards,
>>> Bruno.
>>>
>>
>>
>
>