From DDK topic “Using Remove Locks”:
A driver typically calls IoInitializeRemoveLock in its AddDevice routine. Driver must call IoAcquireRemoveLock each time it starts an I/O operation and call IoReleaseRemoveLock each time it finishes an I/O operation. In its dispatch code for IRP_MN_REMOVE_DEVICE, the driver must acquire the lock once more and then call IoReleaseRemoveLockAndWait.
Code generated by Walter Owney’s WDM Application Wizard follows these rules, except one detail: in IRP_MN_REMOVE_DEVICE handler it doesn’t acquire the lock:
NTSTATUS HandleRemoveDevice(IN PDEVICE_OBJECT fdo, IN PIRP Irp)
{
…
IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
}
Is this right or it should be:
IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com
> IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
Thanks.
“Maxim S. Shatskih” wrote:> IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
> IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
However, after adding this line, when I try to uninstall the driver from Device Manager, Device Manager hangs and driver is not unloaded. After this it is possible to shutdown computer only using Power button.
“Maxim S. Shatskih” wrote:> IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
> IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
---------------------------------
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com
Try to invoke WinDbg.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Alex Farber
To: Windows System Software Devs Interest List
Sent: Thursday, November 11, 2004 2:30 PM
Subject: Re: [ntdev] IO_REMOVE_LOCK in WDM driver
However, after adding this line, when I try to uninstall the driver from Device Manager, Device Manager hangs and driver is not unloaded. After this it is possible to shutdown computer only using Power button.
“Maxim S. Shatskih” wrote:
> IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
> IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
------------------------------------------------------------------------------
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@storagecraft.com To unsubscribe send a blank email to xxxxx@lists.osr.com
Walter tends to write code that works. My guess is that there is a
corresponding IoAcquireRemoveLock in either AddDevice or StartDevice that is
released in RemoveDevice.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alex Farber
Sent: Thursday, November 11, 2004 6:30 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] IO_REMOVE_LOCK in WDM driver
However, after adding this line, when I try to uninstall the driver from
Device Manager, Device Manager hangs and driver is not unloaded. After this
it is possible to shutdown computer only using Power button.
“Maxim S. Shatskih” wrote:
> IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
> IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
_____
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com — Questions? First
check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@hollistech.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
You are absolutely right. There is IoAcquireRemoveLock call in DispatchPnp function, and after this it calls HandleRemoveDevice. HandleRemoveDevice only calls IoReleaseRemoveLockAndWait. So, this code is written according to DDK recommendations, I didn’t understand this first.
Thanks for the answers.
Mark Roddy wrote:
Walter tends to write code that works. My guess is that there is a corresponding IoAcquireRemoveLock in either AddDevice or StartDevice that is released in RemoveDevice.
---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alex Farber
Sent: Thursday, November 11, 2004 6:30 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] IO_REMOVE_LOCK in WDM driver
However, after adding this line, when I try to uninstall the driver from Device Manager, Device Manager hangs and driver is not unloaded. After this it is possible to shutdown computer only using Power button.
“Maxim S. Shatskih” wrote: > IoAcquireRemoveLock(&pdx->RemoveLock, Irp);
> IoReleaseRemoveLockAndWait(&pdx->RemoveLock, Irp);
This one is correct.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
---------------------------------
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@hollistech.com To unsubscribe send a blank email to xxxxx@lists.osr.com—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com