Hello,
My driver calls IoGetDeviceObjectPointer(…) to establish connections
to a number of lower devices. According to the DDK doc, I’ll need to set
the StackSize field in my device object to that of the next-lower-level
device object plus 1. The problem is which lower device object when
there are more than one?
Currently, I set the StackSize to the maximum of all lower device
StackSizes plus one. Just wonder if this is a valid solution for this
problem? Or should I reset the StackSize to that of the corresponding
lower device object before each call to IoCallDriver?
TIA,
Chu Bun
you should only set the stack size once.
you have two options.
the first is to simply set it to one, indicating that upper drivers only
need to ensure you have your own stack location. For each IRP you would
then allocate a new IRP to send to the appropriate device stack below
you.
the second is to set this value to the maximum of the lower devices + 1
as you have done.
the first is better if you will be handling most requests yourself and
only occasionally need to go to a sub-device, as the drivers above you
aren’t allocation ridiculously large IRPs for something you rarely need.
It is also your only option if you will need to change your set of lower
devices (specifically if you add a new device, since it could have a
larger stack count and you must not update your stack count after
initialization).
the second is better if you know the set of lower devices at
initialization time (DriverEntry or AddDevice) and will frequently
forward requests to them. If you don’t know the set of lower devices at
this time, then you need to go with option #1.
there are two reasons you can’t update your stack size at runtime.
-
drivers above you set their stack size to yours + 1. The IO manager
and other drivers create IRPs using the stack size of the topmost device
object. Even if you add one to your stack size, the top-most device
object won’t get updated so you still get smaller IRPs.
-
some upper component (driver or IO system) could be in between
allocating the new IRP and sending it to your driver. If you change
your stack requirements in that interval you will get an IRP which is
too small for what you need. If you were to forward this small IRP to a
new lower device and it’s not big enough, the system will bugcheck.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
Sent: Wednesday, June 11, 2003 4:29 PM
To: NT Developers Interest List
Subject: [ntdev] StackSize and Multiple lower device objects
Hello,
My driver calls IoGetDeviceObjectPointer(…) to establish connections
to a number of lower devices. According to the DDK doc, I’ll need to
set the StackSize field in my device object to that of the
next-lower-level device object plus 1. The problem is which lower
device object when there are more than one?
Currently, I set the StackSize to the maximum of all lower device
StackSizes plus one. Just wonder if this is a valid solution for this
problem? Or should I reset the StackSize to that of the corresponding
lower device object before each call to IoCallDriver?
TIA,
Chu Bun
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
--------------- 2003-06-11 You wrote---------------
Hello,
My driver calls IoGetDeviceObjectPointer(…) to establish connections
to a number of lower devices. According to the DDK doc, I’ll need to set
the StackSize field in my device object to that of the next-lower-level
device object plus 1. The problem is which lower device object when
there are more than one?
corresponding one.
Currently, I set the StackSize to the maximum of all lower device
StackSizes plus one. Just wonder if this is a valid solution for this
problem? Or should I reset the StackSize to that of the corresponding
lower device object before each call to IoCallDriver?
I think either is ok.
TIA,
Chu Bun
You are currently subscribed to ntdev as: ldxlq@263.net
To unsubscribe send a blank email to xxxxx@lists.osr.com
Thank you for a very detailed explaination. It is more complicated than
I like but I’ll need to implement the first option.
Chu Bun
“Peter Wieland” wrote in message
news:xxxxx@ntdev…
you should only set the stack size once.
you have two options.
the first is to simply set it to one, indicating that upper drivers only
need to ensure you have your own stack location. For each IRP you would
then allocate a new IRP to send to the appropriate device stack below
you.
the second is to set this value to the maximum of the lower devices + 1
as you have done.
the first is better if you will be handling most requests yourself and
only occasionally need to go to a sub-device, as the drivers above you
aren’t allocation ridiculously large IRPs for something you rarely need.
It is also your only option if you will need to change your set of lower
devices (specifically if you add a new device, since it could have a
larger stack count and you must not update your stack count after
initialization).
the second is better if you know the set of lower devices at
initialization time (DriverEntry or AddDevice) and will frequently
forward requests to them. If you don’t know the set of lower devices at
this time, then you need to go with option #1.
there are two reasons you can’t update your stack size at runtime.
1) drivers above you set their stack size to yours + 1. The IO manager
and other drivers create IRPs using the stack size of the topmost device
object. Even if you add one to your stack size, the top-most device
object won’t get updated so you still get smaller IRPs.
2) some upper component (driver or IO system) could be in between
allocating the new IRP and sending it to your driver. If you change
your stack requirements in that interval you will get an IRP which is
too small for what you need. If you were to forward this small IRP to a
new lower device and it’s not big enough, the system will bugcheck.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
Sent: Wednesday, June 11, 2003 4:29 PM
To: NT Developers Interest List
Subject: [ntdev] StackSize and Multiple lower device objects
Hello,
My driver calls IoGetDeviceObjectPointer(…) to establish connections
to a number of lower devices. According to the DDK doc, I’ll need to
set the StackSize field in my device object to that of the
next-lower-level device object plus 1. The problem is which lower
device object when there are more than one?
Currently, I set the StackSize to the maximum of all lower device
StackSizes plus one. Just wonder if this is a valid solution for this
problem? Or should I reset the StackSize to that of the corresponding
lower device object before each call to IoCallDriver?
TIA,
Chu Bun
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com