Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

OSR is Hiring! Click here to find out more.

Upcoming OSR Seminars:
Kernel Debugging & Crash Analysis for Windows Lab, Santa Clara, CA 9-13 September, 2013
Upcoming OSR Seminars:
Windows Internals & Software Drivers Lab, Santa Clara, CA 16-20 September, 2013
Writing WDF Drivers for Windows Lab, Boston/Waltham, MA 7-11 October, 2013
Developing File Systems for Windows, Seattle, WA 5-8 November, 2013


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 4  
03 Jul 12 22:59
David F.
xxxxxx@terabyteunlimited.com
Join Date: 12 Jan 2012
Posts To This List: 59
Is a Remove Lock needed even in a simple dispatch routine?

Is the remove lock actually needed in the sample below? I know it would be needed if there was a completion routine setup, but in this case, it's just a simple forward. TIA!! NTSTATUS DispatchRead(IN PDEVICE_OBJECT fido, PIRP irp) { // Make sure device doesn't get deleted on a removal request psDeviceExtension pdx=(psDeviceExtension) fido->DeviceExtension; NTSTATUS status=IoAcquireRemoveLock(&pdx->RemoveLock, irp); if (!NT_SUCCESS(status)) { // Device waiting to being deleted so complete with STATUS_DELETE_PENDING return(CompleteRequest(irp, status, 0)); } // Pass this through to next driver to handle request IoSkipCurrentIrpStackLocation(irp); status=IoCallDriver(pdx->LowerDeviceObject, irp); // Release the lock and exit IoReleaseRemoveLock(&pdx->RemoveLock, irp); return(status); }
  Message 2 of 4  
03 Jul 12 23:07
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 8350
RE: Is a Remove Lock needed even in a simple dispatch routine?

Are you filtering a stack with only handle based io? If yes, you don't need a remlock. If you are filtering a stack where non handle based io is sent, a remlock is usually a good idea. d -----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@terabyteunlimited.com Sent: Tuesday, July 03, 2012 7:58 PM To: Windows System Software Devs Interest List Subject: [ntdev] Is a Remove Lock needed even in a simple dispatch routine? Is the remove lock actually needed in the sample below? I know it would be needed if there was a completion routine setup, but in this case, it's just a simple forward. TIA!! NTSTATUS DispatchRead(IN PDEVICE_OBJECT fido, PIRP irp) { // Make sure device doesn't get deleted on a removal request psDeviceExtension pdx=(psDeviceExtension) fido->DeviceExtension; NTSTATUS status=IoAcquireRemoveLock(&pdx->RemoveLock, irp); if (!NT_SUCCESS(status)) { // Device waiting to being deleted so complete with STATUS_DELETE_PENDING return(CompleteRequest(irp, status, 0)); } // Pass this through to next driver to handle request IoSkipCurrentIrpStackLocation(irp); status=IoCallDriver(pdx->LowerDeviceObject, irp); // Release the lock and exit IoReleaseRemoveLock(&pdx->RemoveLock, irp); return(status); } --- NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
  Message 3 of 4  
03 Jul 12 23:53
David F.
xxxxxx@terabyteunlimited.com
Join Date: 12 Jan 2012
Posts To This List: 59
RE: Is a Remove Lock needed even in a simple dispatch routine?

The disk drive stack so I presume that is handle only based IO and therefore a remove lock is not needed unless setting up a completion routine? >Are you filtering a stack with only handle based io? If yes, you don't need a remlock. >If you are filtering a stack where non handle based io is sent, a remlock is >usually a good idea.
  Message 4 of 4  
06 Jul 12 13:37
David F.
xxxxxx@terabyteunlimited.com
Join Date: 12 Jan 2012
Posts To This List: 59
RE: Is a Remove Lock needed even in a simple dispatch routine?

Can someone confirm the presumption above? Because it differs from what others have written which suggest you must do the remove lock before IoCallDriver and then unlock after, even if no completion routine?
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 12:50.


Copyright ©2012, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license