Hello All,
Iam new to driver programming on NT. currently iam seeing a problem with my driver where it is trying to reuse an IRP that is already is in progress because of which it panics with NO_MORE_IRP_STACK_LOCATIONS bugcheck code. Is there any way to detect if an IRP is already in progress so that i can stop reusing that?
Thanks for your help
regards,
Pandya
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
No, there is no way to do this, but I am not sure that your analyzing this crash correctly. NO_MORE_IRP_STACK_LOCATIONS indicates that someone is calling IoCallDriver but there are no more stack locations left in the irp. This usually means that when a driver did IoGetDeviceObjectPointer to get the DeviceObject of the Device that the driver wanted to talk to, the caller did not set his deviceObject->StackSize to the The received DeviceObject->StackSize + 1; If this is not done, the IoManager (if he is the one that allocated the Irp) will not create an Irp with the correct number of stack locations…
–Mark
Mark Cariddi
Consulting Associate
Open Systems Resources, Inc.
www.osr.com
“ntdev user” wrote in message news:xxxxx@ntdev…
Hello All,
Iam new to driver programming on NT. currently iam seeing a problem with my driver where it is trying to reuse an IRP that is already is in progress because of which it panics with NO_MORE_IRP_STACK_LOCATIONS bugcheck code. Is there any way to detect if an IRP is already in progress so that i can stop reusing that?
Thanks for your help
regards,
Pandya
------------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
Mark,
let me explain this in more detail
The Irp that iam using is preallocated and will only be released when the driver unloads. Also the device to which the driver talks doesn’t change so the devobj of the device is stored in a global variable that is accessible by all threads.
let’s assume i have two threads that call the same function foo() that looks like this.
foo()
{
…
…
Acquire lock
NextIrpStackPtr =
IoGetNextIrpStackLocation ( GlobalIrpPtr);
NextIrpStackPtr->MajorFunction = IRP_MJ_WRITE;
NextIrpStackPtr->MinorFunction = 0;
NextIrpStackPtr->Flags = 0;
NextIrpStackPtr->DeviceObject = GlobalDevicePtr;
…
…
…
Release lock ( don’t want to call IoCallDriver at dispatch level)
status = IoCallDriver (GlobalDevicePtr,GlobalIrpPtr );
…
…
}
let’s assume the first thread has called the driver below . Now the other thread calls the same function. call to GetNextIrpStackLocation will now return pointer to end of the packet. The thread will write to the end of the I/O packet and IoCallDriver will now panic with NO_MORE_IRP_STACK_LOCATIONS.
Anyway since you said that there is no way of knowing if an IRP is in progress or not, is it “OK to hack the flags field of the fixed part of IRP to store some info that can be used for this purpose”
Thanks
Mark Cariddi wrote:No, there is no way to do this, but I am not sure that your analyzing this crash correctly. NO_MORE_IRP_STACK_LOCATIONS indicates that someone is calling IoCallDriver but there are no more stack locations left in the irp. This usually means that when a driver did IoGetDeviceObjectPointer to get the DeviceObject of the Device that the driver wanted to talk to, the caller did not set his deviceObject->StackSize to the The received DeviceObject->StackSize + 1; If this is not done, the IoManager (if he is the one that allocated the Irp) will not create an Irp with the correct number of stack locations… --Mark Mark CariddiConsulting AssociateOpen Systems Resources, Inc.www.osr.com “ntdev user” wrote in message news:xxxxx@ntdev…
Hello All,
Iam new to driver programming on NT. currently iam seeing a problem with my driver where it is trying to reuse an IRP that is already is in progress because of which it panics with NO_MORE_IRP_STACK_LOCATIONS bugcheck code. Is there any way to detect if an IRP is already in progress so that i can stop reusing that?
Thanks for your help
regards,
Pandya
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now—
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to %%email.unsub%%
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
I wouldn’t “HACK” the irp. I would have some sort of synchronization around the use of the irp. I would get some lock and look at a BOOLEAN indicating whether or not the IRP is in use, if the BOOLEAN is set, you can’t use the IRP, if it is not set you can use the irp and you set the BOOLEAN to TRUE, release the lock… Does that work for you???
Mark Cariddi
Consulting Associate
Open Systems Resources, Inc.
www.osr.com
“ntdev user” wrote in message news:xxxxx@ntdev…
Mark,
let me explain this in more detail
The Irp that iam using is preallocated and will only be released when the driver unloads. Also the device to which the driver talks doesn’t change so the devobj of the device is stored in a global variable that is accessible by all threads.
let’s assume i have two threads that call the same function foo() that looks like this.
foo()
{
…
…
Acquire lock
NextIrpStackPtr =
IoGetNextIrpStackLocation ( GlobalIrpPtr);
NextIrpStackPtr->MajorFunction = IRP_MJ_WRITE;
NextIrpStackPtr->MinorFunction = 0;
NextIrpStackPtr->Flags = 0;
NextIrpStackPtr->DeviceObject = GlobalDevicePtr;
…
…
…
Release lock ( don’t want to call IoCallDriver at dispatch level)
status = IoCallDriver (GlobalDevicePtr,GlobalIrpPtr );
…
…
}
let’s assume the first thread has called the driver below . Now the other thread calls the same function. call to GetNextIrpStackLocation will now return pointer to end of the packet. The thread will write to the end of the I/O packet and IoCallDriver will now panic with NO_MORE_IRP_STACK_LOCATIONS.
Anyway since you said that there is no way of knowing if an IRP is in progress or not, is it “OK to hack the flags field of the fixed part of IRP to store some info that can be used for this purpose”
Thanks
Mark Cariddi wrote:
No, there is no way to do this, but I am not sure that your analyzing this crash correctly. NO_MORE_IRP_STACK_LOCATIONS indicates that someone is calling IoCallDriver but there are no more stack locations left in the irp. This usually means that when a driver did IoGetDeviceObjectPointer to get the DeviceObject of the Device that the driver wanted to talk to, the caller did not set his deviceObject->StackSize to the The received DeviceObject->StackSize + 1; If this is not done, the IoManager (if he is the one that allocated the Irp) will not create an Irp with the correct number of stack locations…
–Mark
Mark Cariddi
Consulting Associate
Open Systems Resources, Inc.
www.osr.com
“ntdev user” wrote in message news:xxxxx@ntdev…
Hello All,
Iam new to driver programming on NT. currently iam seeing a problem with my driver where it is trying to reuse an IRP that is already is in progress because of which it panics with NO_MORE_IRP_STACK_LOCATIONS bugcheck code. Is there any way to detect if an IRP is already in progress so that i can stop reusing that?
Thanks for your help
regards,
Pandya
--------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
—
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to %%email.unsub%%
------------------------------------------------------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
I guess it should solve the problem. I will give it a try. Thanks for the help
Mark Cariddi wrote:I wouldn’t “HACK” the irp. I would have some sort of synchronization around the use of the irp. I would get some lock and look at a BOOLEAN indicating whether or not the IRP is in use, if the BOOLEAN is set, you can’t use the IRP, if it is not set you can use the irp and you set the BOOLEAN to TRUE, release the lock… Does that work for you??? Mark CariddiConsulting AssociateOpen Systems Resources, Inc.www.osr.com"ntdev user" wrote in message news:xxxxx@ntdev…
Mark,
let me explain this in more detail
The Irp that iam using is preallocated and will only be released when the driver unloads. Also the device to which the driver talks doesn’t change so the devobj of the device is stored in a global variable that is accessible by all threads.
let’s assume i have two threads that call the same function foo() that looks like this.
foo()
{
…
…
Acquire lock
NextIrpStackPtr =
IoGetNextIrpStackLocation ( GlobalIrpPtr);
NextIrpStackPtr->MajorFunction = IRP_MJ_WRITE;
NextIrpStackPtr->MinorFunction = 0;
NextIrpStackPtr->Flags = 0;
NextIrpStackPtr->DeviceObject = GlobalDevicePtr;
…
…
…
Release lock ( don’t want to call IoCallDriver at dispatch level)
status = IoCallDriver (GlobalDevicePtr,GlobalIrpPtr );
…
…
}
let’s assume the first thread has called the driver below . Now the other thread calls the same function. call to GetNextIrpStackLocation will now return pointer to end of the packet. The thread will write to the end of the I/O packet and IoCallDriver will now panic with NO_MORE_IRP_STACK_LOCATIONS.
Anyway since you said that there is no way of knowing if an IRP is in progress or not, is it “OK to hack the flags field of the fixed part of IRP to store some info that can be used for this purpose”
Thanks
Mark Cariddi wrote: No, there is no way to do this, but I am not sure that your analyzing this crash correctly. NO_MORE_IRP_STACK_LOCATIONS indicates that someone is calling IoCallDriver but there are no more stack locations left in the irp. This usually means that when a driver did IoGetDeviceObjectPointer to get the DeviceObject of the Device that the driver wanted to talk to, the caller did not set his deviceObject->StackSize to the The received DeviceObject->StackSize + 1; If this is not done, the IoManager (if he is the one that allocated the Irp) will not create an Irp with the correct number of stack locations… --Mark Mark CariddiConsulting AssociateOpen Systems Resources, Inc.www.osr.com “ntdev user” wrote in message news:xxxxx@ntdev…
Hello All,
Iam new to driver programming on NT. currently iam seeing a problem with my driver where it is trying to reuse an IRP that is already is in progress because of which it panics with NO_MORE_IRP_STACK_LOCATIONS bugcheck code. Is there any way to detect if an IRP is already in progress so that i can stop reusing that?
Thanks for your help
regards,
Pandya
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now—
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to %%email.unsub%%
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now—
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to %%email.unsub%%
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now