I am playing with a striped disk driver. I create multiple IRPs for all reads and writes comming im. I copy the parameters from my driver’s stack location in the master IRP to the stack location for the driver being called with the new IRP. I’m not sure what parameters need to be copied. I know that I don’t want to copy the CompletionRoutine parameter, but should I just copy all of the others like this?
PIO_STACK_LOCATION IrpSp;
PIO_STACK_LOCATION NextIrpSp;
IrpSp = IoGetCurrentIrpStackLocation(MasterIrp);
NextIrpSp = IoGetNextIrpStackLocation(NewIrp);
*NextIrpSp = *IrpSp;
IoSetCompletionRoutine (NewIrp, …) ;
return IoCallDriver(NextDeviceObject, NewIrp);
I am currently doing this and it seems to work:
NewIrp->Flags = MasterIrp->Flags ;
NewIrp->RequestorMode = MasterIrp->RequestorMode ;
NewIrp->Tail.Overlay.Thread = MasterIrp->Tail.Overlay.Thread ;
NewIrp->Tail.Overlay.OriginalFileObject = MasterIrp->Tail.
Overlay.OriginalFileObject ;
NewIrp->IoStatus.Status = 0 ;
// Duplicate the parameters
// The length and the byte offset are the only changes to the parameters
NewIrpNextStackLocation->Parameters.Read.ByteOffset = curOffset ;
NewIrpNextStackLocation->Parameters.Read.Length = curLength ;
NewIrpNextStackLocation->Parameters.Read.Key = irpStack->Parameters.
Read.Key ;
NewIrpNextStackLocation->MajorFunction = irpStack->MajorFunction ;
NewIrpNextStackLocation->MinorFunction = irpStack->MinorFunction ;
NewIrpNextStackLocation->Flags = irpStack->Flags ;
NewIrpNextStackLocation->FileObject = irpStack->FileObject ;
NewIrpNextStackLocation->DeviceObject = irpStack->DeviceObject ;
IoSetCompletionRoutine (NewIrp, …) ;
Am I making any mistakes?
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Here are two useful macros. They are defined in Windows 2000 DDK, but
not in the NT 4.0- DDK.
// Copy the current IRP stack location to the next IRP stack location.
#ifndef IoCopyCurrentIrpStackLocationToNext
#define IoCopyCurrentIrpStackLocationToNext(Irp) {
PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; irpSp = IoGetCurrentIrpStackLocation((Irp)); nextIrpSp = IoGetNextIrpStackLocation((Irp)); RtlCopyMemory(nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION,
CompletionRoutine)); nextIrpSp->Control = 0; }
#endif
// Skip the current IRP stack location.
#ifndef IoSkipCurrentIrpStackLocation
#define IoSkipCurrentIrpStackLocation(Irp) { (Irp)->CurrentLocation++; (Irp)->Tail.Overlay.CurrentStackLocation++; }
#endif
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@powerquest.com
Sent: Thursday, July 12, 2001 2:56 PM
To: NT Developers Interest List
Subject: [ntdev] Copying parameters to new IRP
I am playing with a striped disk driver. I create multiple
IRPs for all reads and writes comming im. I copy the
parameters from my driver’s stack location in the master IRP
to the stack location for the driver being called with the
new IRP. I’m not sure what parameters need to be copied. I
know that I don’t want to copy the CompletionRoutine
parameter, but should I just copy all of the others like this?
PIO_STACK_LOCATION IrpSp;
PIO_STACK_LOCATION NextIrpSp;
IrpSp = IoGetCurrentIrpStackLocation(MasterIrp);
NextIrpSp = IoGetNextIrpStackLocation(NewIrp);
*NextIrpSp = *IrpSp;
IoSetCompletionRoutine (NewIrp, …) ;
return IoCallDriver(NextDeviceObject, NewIrp);
I am currently doing this and it seems to work:
NewIrp->Flags = MasterIrp->Flags ;
NewIrp->RequestorMode = MasterIrp->RequestorMode ;
Tail.Overlay.Thread =
NewIrp->MasterIrp->Tail.Overlay.Thread ;
Tail.Overlay.OriginalFileObject
NewIrp->= MasterIrp->Tail.
Overlay.OriginalFileObject ;
NewIrp->IoStatus.Status = 0 ;
// Duplicate the parameters
// The length and the byte offset are the only changes to the
parameters
NewIrpNextStackLocation->Parameters.Read.ByteOffset = curOffset ;
NewIrpNextStackLocation->Parameters.Read.Length = curLength ;
NewIrpNextStackLocation->Parameters.Read.Key = irpStack->Parameters.
Read.Key ;
NewIrpNextStackLocation->MajorFunction = irpStack->MajorFunction ;
NewIrpNextStackLocation->MinorFunction =
irpStack->MinorFunction ; Flags
NewIrpNextStackLocation->= irpStack->Flags ; FileObject =
NewIrpNextStackLocation->irpStack->FileObject ; DeviceObject =
NewIrpNextStackLocation->irpStack->DeviceObject ;
IoSetCompletionRoutine (NewIrp, …) ;
Am I making any mistakes?
You are currently subscribed to ntdev as:
xxxxx@storagecraft.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com