IOStatus and IoCompleteRequest

Hi

I have the following code:

pIrp = IoBuildDeviceIoControlRequest(
IOCTL_GENERIC,
PhysicalDeviceObject,
buffer,
in_len,
buffer,
out_len,
IRP_MJ_INTERNAL_DEVICE_CONTROL,
pEvent,
&IoStatus);

status = IoCallDriver(commonExt->PhysicalDeviceObject,pIrp);

if( status == STATUS_PENDING ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status == STATUS_TIMEOUT ){
if( IoCancelIrp(pIrp) ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status != STATUS_SUCCESS )
DebugPrint((“Timeout waiting cancel Irp\n”));

}
else
DebugPrint((“CancelIrp failed\n”));

status = STATUS_TIMEOUT;
out_len = 0;
}
}

Irp->IoStatus.Status = status;
Irp->IoStatus.Information = IoStatus.Information;

In the below driver (PhysicalDeviceObject) I make some work and then :

Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 10;
IoCompleteRequest(Irp,IO_NO_INCREMENT);

and I have the following behaviour which I don’t understand:

In the PhysicalDriver I set the IoStatus.Status and IoStatus.Information.
if the returned status is STATUS_SUCCESS on return the both IoStatus.Status
and IoStatus.Information have same values like set on the below driver. If
the status is not successfull then the values from IoStatus are changed.

I’ve checked this on Win2K and WinXP. Is this the way it should be ?

thanks
horatiu

this doesn’t look quite right.

in the event that the dispatch routine for the lower driver returns
STATUS_PENDING it looks like you put the status of KeWaitForSingleObject
into the IRP you’re completing. You’ll want to propagate the status
value from the IoStatus block instead in this case.

-p

-----Original Message-----
From: Horatiu G. [mailto:xxxxx@intech.ro]
Sent: Tuesday, June 11, 2002 7:17 AM
To: NT Developers Interest List
Subject: [ntdev] IOStatus and IoCompleteRequest

Hi

I have the following code:

pIrp = IoBuildDeviceIoControlRequest(
IOCTL_GENERIC,
PhysicalDeviceObject,
buffer,
in_len,
buffer,
out_len,
IRP_MJ_INTERNAL_DEVICE_CONTROL,
pEvent,
&IoStatus);

status = IoCallDriver(commonExt->PhysicalDeviceObject,pIrp);

if( status == STATUS_PENDING ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status == STATUS_TIMEOUT ){
if( IoCancelIrp(pIrp) ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status != STATUS_SUCCESS )
DebugPrint((“Timeout waiting cancel Irp\n”));

}
else
DebugPrint((“CancelIrp failed\n”));

status = STATUS_TIMEOUT;
out_len = 0;
}
}

Irp->IoStatus.Status = status;
Irp->IoStatus.Information = IoStatus.Information;

In the below driver (PhysicalDeviceObject) I make some work and then :

Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 10;
IoCompleteRequest(Irp,IO_NO_INCREMENT);

and I have the following behaviour which I don’t understand:

In the PhysicalDriver I set the IoStatus.Status and
IoStatus.Information. if the returned status is STATUS_SUCCESS on return
the both IoStatus.Status and IoStatus.Information have same values like
set on the below driver. If the status is not successfull then the
values from IoStatus are changed.

I’ve checked this on Win2K and WinXP. Is this the way it should be ?

thanks
horatiu


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

I would recommend the following two links:

http://www.osr.com/ntinsider/1997/ryo.htm

http://www.osr.com/ntinsider/1997/iocomp/iocomp.htm

However the bottom link seems broken at the moment.

I would also read Pages 211-220 of Walter Oney’s Book. With special
attention to page 214. - Eric

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Horatiu G. [mailto:xxxxx@intech.ro]
Sent: Tuesday, June 11, 2002 7:17 AM
To: NT Developers Interest List
Subject: [ntdev] IOStatus and IoCompleteRequest

Hi

I have the following code:

pIrp = IoBuildDeviceIoControlRequest(
IOCTL_GENERIC,
PhysicalDeviceObject,
buffer,
in_len,
buffer,
out_len,
IRP_MJ_INTERNAL_DEVICE_CONTROL,
pEvent,
&IoStatus);

status = IoCallDriver(commonExt->PhysicalDeviceObject,pIrp);

if( status == STATUS_PENDING ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status == STATUS_TIMEOUT ){
if( IoCancelIrp(pIrp) ){
status =
KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
if( status != STATUS_SUCCESS )
DebugPrint((“Timeout waiting cancel Irp\n”));

}
else
DebugPrint((“CancelIrp failed\n”));

status = STATUS_TIMEOUT;
out_len = 0;
}
}

Irp->IoStatus.Status = IoStatus.Status;
Irp->IoStatus.Information = IoStatus.Information;

In the below driver (PhysicalDeviceObject) I make some work and then :

Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 10;
IoCompleteRequest(Irp,IO_NO_INCREMENT);

and I have the following behaviour which I don’t understand:

In the PhysicalDriver I set the IoStatus.Status and
IoStatus.Information. if the returned status is STATUS_SUCCESS on return
the both IoStatus.Status and IoStatus.Information have same values like
set on the below driver. If the status is not successfull then the
values from IoStatus are changed.

I’ve checked this on Win2K and WinXP. Is this the way it should be ?

thanks
horatiu


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

>“Eric W Hanson” wrote in message
news:xxxxx@ntdev…
>
>I would recommend the following two links:
>
>http://www.osr.com/ntinsider/1997/ryo.htm
>
>http://www.osr.com/ntinsider/1997/iocomp/iocomp.htm
>
>However the bottom link seems broken at the moment.

As we continue to sort out network issues, for http://www.osr.com you might
try:

http://208.13.232.200/

as in

http://208.13.232.200/ntinsider/1997/iocomp/iocomp.htm

Peter
OSR

It seemed to work here using the new IP address.

Pete

Peter Scott
xxxxx@KernelDrivers.com
http://www.KernelDrivers.com

>-----Original Message-----
>From: xxxxx@lists.osr.com [mailto:bounce-ntdev-
>xxxxx@lists.osr.com] On Behalf Of Eric W Hanson
>Sent: Thursday, June 13, 2002 11:27 AM
>To: NT Developers Interest List
>Subject: [ntdev] RE: IOStatus and IoCompleteRequest
>
>I would recommend the following two links:
>
>http://www.osr.com/ntinsider/1997/ryo.htm
>
>http://www.osr.com/ntinsider/1997/iocomp/iocomp.htm
>
>However the bottom link seems broken at the moment.
>
>I would also read Pages 211-220 of Walter Oney’s Book. With special
>attention to page 214. - Eric
>
>This posting is provided “AS IS” with no warranties, and confers no
>rights.
>
>-----Original Message-----
>From: Horatiu G. [mailto:xxxxx@intech.ro]
>Sent: Tuesday, June 11, 2002 7:17 AM
>To: NT Developers Interest List
>Subject: [ntdev] IOStatus and IoCompleteRequest
>
>
>Hi
>
>I have the following code:
>
> pIrp = IoBuildDeviceIoControlRequest(
> IOCTL_GENERIC,
> PhysicalDeviceObject,
> buffer,
> in_len,
> buffer,
> out_len,
> IRP_MJ_INTERNAL_DEVICE_CONTROL,
> pEvent,
> &IoStatus);
>
> status = IoCallDriver(commonExt->PhysicalDeviceObject,pIrp);
>
> if( status == STATUS_PENDING ){
> status =
>KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
> if( status == STATUS_TIMEOUT ){
> if( IoCancelIrp(pIrp) ){
> status =
>KeWaitForSingleObject(pEvent,Executive,KernelMode,FALSE,&Timeout);
> if( status != STATUS_SUCCESS )
> DebugPrint((“Timeout waiting cancel Irp\n”));
>
> }
> else
> DebugPrint((“CancelIrp failed\n”));
>
> status = STATUS_TIMEOUT;
> out_len = 0;
> }
> }
>
> Irp->IoStatus.Status = IoStatus.Status;
> Irp->IoStatus.Information = IoStatus.Information;
>
>
>In the below driver (PhysicalDeviceObject) I make some work and then :
>
>Irp->IoStatus.Status = status;
>Irp->IoStatus.Information = 10;
>IoCompleteRequest(Irp,IO_NO_INCREMENT);
>
>and I have the following behaviour which I don’t understand:
>
>In the PhysicalDriver I set the IoStatus.Status and
>IoStatus.Information. if the returned status is STATUS_SUCCESS on
return
>the both IoStatus.Status and IoStatus.Information have same values
like
>set on the below driver. If the status is not successfull then the
>values from IoStatus are changed.
>
>I’ve checked this on Win2K and WinXP. Is this the way it should be ?
>
>thanks
>horatiu
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to %%email.unsub%%
>
>—
>You are currently subscribed to ntdev as: xxxxx@KernelDrivers.com
>To unsubscribe send a blank email to %%email.unsub%%