none
Remove Locks outside of device extension RRS feed

  • Question

  • Hello,

    The https://msdn.microsoft.com/en-us/library/windows/hardware/ff561042%28v=vs.85%29.aspx seems to suggest that remove locks are to be used only in device objects.

    Can I use them outside? I need it to be a global variable so I can sync the driver unload with a PERFLIB callback.

    I already implemented my own remove lock but thought it might be better to use this one as it'd be safer.

    Many thanks,

    Tiago

    Friday, February 13, 2015 12:32 PM

Answers

  • You should be able to call the lock from anywhere in your driver, while they are called device objects, they are not objects in the C++ class model.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com

    Friday, February 13, 2015 12:39 PM

All replies

  • You should be able to call the lock from anywhere in your driver, while they are called device objects, they are not objects in the C++ class model.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com

    Friday, February 13, 2015 12:39 PM
  • yes, you can use and store remove locks anywhere you want, but there is one property you need to make sure is satisfied. The remove lock has to be valid for the TryToAcquire call. Device objects provide this facility b/c it is guaranteed a ref on the device is present when IoCallDriver is invoked on your pnp/power dispatch routine. Storing the remlock in a global also satisfies this requirement since the memory is always valid

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, February 13, 2015 6:32 PM