Irp reusing

Hello,

I also have a question regarding Irp reusing
which probably goes to Microsoft’s people too.

You probably know that there is a routine called
IoReuseIrp which is able to “cleanup” an Irp used
more than one time. However this routine is not
available on Lite platform and if you are writing
a WDM driver you need something stable across platforms.

There is also another routine IoInitializeIrp.
The main difference between it and IoReuseIrp as I
understand it is that the first routine is used for
Irps not allocated by Io while the second one must be
used for Irps allocated by IoAllocateIrp. Other
difference may be that IoInitializeIrp should be called
befor the Irp is used for the first time while IoAllocateIrp
has already initialized the allocated Irp. Etc. etc. etc…

So what should I do to be as most correct as I can be?
a)

  1. Allocate my own memory of size IoSizeOfIrp(StackSize)
  2. Initialize it by IoInitializeIrp(…, IoSizeOfIrp(StackSize),
    StackSize)
  3. Use it to pass requests and after every such request has been
    completed “clean” the Irp by repeating the step 2.
    Q: Last two parameters are already present inside the Irp itself,
    so have I to remeber them separately or can I touch the basic
    fields of the Irp, concretely Irp->Size and Irp->StackCount?
    b)
  4. Allocate the Irp using IoAllocateIrp(StackSize, FALSE)
  5. Use it to pass requests and after every such request has been
    completed “clean” the Irp:
    A] only partially, mainly clear Irp->Cancel flag and maybe some
    other interesting fields
    Q: which?
    B] completely, but using some hack by saving Irp->AllocationFlags
    (which is probably affected by the following routine), then
    call IoInitializeIrp(…) and finally restore the Irp->AllocationFlags
    Q: as in a)3.

Or is there some other correct way using only WDM exports?

Thank you for your suggestions.
Paul

PS: My client for this particular problem is USB driver stack
and those Irps are used only for sending down the URBs -
thus breaking many rules for passing buffer pointers and
so on, becuase this is internal device control and from the
definition it can be issued only by kernel mode (and thus
“trusted”) components only - allowing some exceptions.


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

"If a driver allocates an IRP with IoAllocateIrp and with the
ChargeQuota parameter set to FALSE, then it can safely use
IoInitializeIrp to reinitialize the IRP. Drivers that must also work on
Windows 98 can use this method as a work-around. Drivers strictly for
Windows 2000 and later operating systems should use the previous method.
" - the XP ddk.

The previous method is of course IoReuseIrp. If this does not work and
you are doing everything correctly then you have a bug in either windos
or nt.

=====================
Mark Roddy
Windows XP/2000/NT Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com
xxxxx@hollistech.com
For Windows Device Driver Training: see www.azius.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@compelson.com
Sent: Monday, January 28, 2002 3:00 PM
To: NT Developers Interest List
Subject: [ntdev] Irp reusing

Hello,

I also have a question regarding Irp reusing
which probably goes to Microsoft’s people too.

You probably know that there is a routine called
IoReuseIrp which is able to “cleanup” an Irp used
more than one time. However this routine is not
available on Lite platform and if you are writing
a WDM driver you need something stable across platforms.

There is also another routine IoInitializeIrp.
The main difference between it and IoReuseIrp as I
understand it is that the first routine is used for
Irps not allocated by Io while the second one must be
used for Irps allocated by IoAllocateIrp. Other
difference may be that IoInitializeIrp should be called
befor the Irp is used for the first time while IoAllocateIrp has already
initialized the allocated Irp. Etc. etc. etc…

So what should I do to be as most correct as I can be?
a)

  1. Allocate my own memory of size IoSizeOfIrp(StackSize)
  2. Initialize it by IoInitializeIrp(…, IoSizeOfIrp(StackSize),
    StackSize)
  3. Use it to pass requests and after every such request has been
    completed “clean” the Irp by repeating the step 2.
    Q: Last two parameters are already present inside the Irp itself,
    so have I to remeber them separately or can I touch the basic
    fields of the Irp, concretely Irp->Size and Irp->StackCount?
    b)
  4. Allocate the Irp using IoAllocateIrp(StackSize, FALSE)
  5. Use it to pass requests and after every such request has been
    completed “clean” the Irp:
    A] only partially, mainly clear Irp->Cancel flag and maybe some
    other interesting fields
    Q: which?
    B] completely, but using some hack by saving Irp->AllocationFlags
    (which is probably affected by the following routine), then
    call IoInitializeIrp(…) and finally restore the
    Irp->AllocationFlags
    Q: as in a)3.

Or is there some other correct way using only WDM exports?

Thank you for your suggestions.
Paul

PS: My client for this particular problem is USB driver stack
and those Irps are used only for sending down the URBs -
thus breaking many rules for passing buffer pointers and
so on, becuase this is internal device control and from the
definition it can be issued only by kernel mode (and thus
“trusted”) components only - allowing some exceptions.


You are currently subscribed to ntdev as: xxxxx@hollistech.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

> I also have a question regarding Irp reusing

which probably goes to Microsoft’s people too.

IoAllocateIrp seems to use lookasides and be extremely fast.
I don’t think it is a good idea to optimize it out at the cost of some non-trivialities.

Max


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

Hi paul

create IRP with IoAllocateIrp .
when you want to reuse the IRP , use the following code which should solve
the problem of working on Cross platforms.

UCHAR Allocflags = pIrp->AllocationFlags;
CCHAR NoOfstack = pIrp->StackCount;

IoInitializeIrp(pIrp,IoSizeOfIrp(NoOfstack),NoOfstack);

pIrp->AllocationFlags = Allocflags;
pIrp->IoStatus.Status = ntStatus;
It works fine on all OS’s

Good luck
srinivasa

-----Original Message-----
From: xxxxx@compelson.com [mailto:xxxxx@compelson.com]
Sent: Sunday, January 27, 2002 5:00 PM
To: NT Developers Interest List
Subject: [ntdev] Irp reusing

Hello,

I also have a question regarding Irp reusing
which probably goes to Microsoft’s people too.

You probably know that there is a routine called
IoReuseIrp which is able to “cleanup” an Irp used
more than one time. However this routine is not
available on Lite platform and if you are writing
a WDM driver you need something stable across platforms.

There is also another routine IoInitializeIrp.
The main difference between it and IoReuseIrp as I
understand it is that the first routine is used for
Irps not allocated by Io while the second one must be
used for Irps allocated by IoAllocateIrp. Other
difference may be that IoInitializeIrp should be called
befor the Irp is used for the first time while IoAllocateIrp
has already initialized the allocated Irp. Etc. etc. etc…

So what should I do to be as most correct as I can be?
a)

  1. Allocate my own memory of size IoSizeOfIrp(StackSize)
  2. Initialize it by IoInitializeIrp(…, IoSizeOfIrp(StackSize),
    StackSize)
  3. Use it to pass requests and after every such request has been
    completed “clean” the Irp by repeating the step 2.
    Q: Last two parameters are already present inside the Irp itself,
    so have I to remeber them separately or can I touch the basic
    fields of the Irp, concretely Irp->Size and Irp->StackCount?
    b)
  4. Allocate the Irp using IoAllocateIrp(StackSize, FALSE)
  5. Use it to pass requests and after every such request has been
    completed “clean” the Irp:
    A] only partially, mainly clear Irp->Cancel flag and maybe some
    other interesting fields
    Q: which?
    B] completely, but using some hack by saving Irp->AllocationFlags
    (which is probably affected by the following routine), then
    call IoInitializeIrp(…) and finally restore the Irp->AllocationFlags
    Q: as in a)3.

Or is there some other correct way using only WDM exports?

Thank you for your suggestions.
Paul

PS: My client for this particular problem is USB driver stack
and those Irps are used only for sending down the URBs -
thus breaking many rules for passing buffer pointers and
so on, becuase this is internal device control and from the
definition it can be issued only by kernel mode (and thus
“trusted”) components only - allowing some exceptions.


You are currently subscribed to ntdev as: xxxxx@microtune.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