Complete routine question

Hello,

I am using following scheme to process the IRP (see psedo code):

CreateHandler()
{

irp1 = TdiBuildInternalDeviceControlIrp(…)
irp2 = TdiBuildInternalDeviceControlIrp(…)

Set (CompleteRoutine)
}

NTSTATUS CompleteRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN
PVOID Context)
{
PIO_STACK_LOCATION irps = IoGetCurrentIrpStackLocation(Irp);

TdiBuildQueryInformation(irp1, DeviceObject, irps->FileObject,
CompleteRoutine2,…);

}

NTSTATUS CompleteRoutine2(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN
PVOID Context)
{
PIO_STACK_LOCATION irps = IoGetCurrentIrpStackLocation(Irp);

TdiBuildQueryInformation(irp2, DeviceObject, irps->FileObject,
CompleteRoutine3,…);

}

In CompleteRoutine2 I receive both DeviceObject = NULL and irps->FileObject
= NULL; Both irp1 and irp2 are identical as well as their processing in
complete routines. In CompleteRoutine DeviceObject has a right value.

What does it mean that complete routine recieve DeviceObject = NULL

Thank you
Leonid

> In CompleteRoutine2 I receive both DeviceObject = NULL and irps->FileObject

It is a much better idea to rely on Context parameter to completion routines,
not to DeviceObject parameter.

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