Disk Driver Upper Filter

Hello,

I have a hybrid driver that is also an upper filter for the disk drive class. In AddDevice functions I create the device object for the current device. At some point I want to unload my driver so I detach and delete all the devices that I created before. My driver is unloaded with success(status = stopped), but I am still receiving IRP_MJ_DEVICE_CONTROL for device object that I deleted previously. When I remove/eject the device the DispatchIo routine of my driver is not called anymore. Is this a normal behaviour?

Thank you.

If you are attaching to a disk device stack, you will not be able to unload
until that device is removed. The storage stack has a lot of things above
the disk driver and therefore your driver, so your device object is still
being referenced and is active.

It sounds like you have one or more control devices, and are treating
requests to remove them as an unload.

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Friday, September 26, 2014 10:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Disk Driver Upper Filter

Hello,

I have a hybrid driver that is also an upper filter for the disk drive
class. In AddDevice functions I create the device object for the current
device. At some point I want to unload my driver so I detach and delete all
the devices that I created before. My driver is unloaded with success(status
= stopped), but I am still receiving IRP_MJ_DEVICE_CONTROL for device
object that I deleted previously. When I remove/eject the device the
DispatchIo routine of my driver is not called anymore. Is this a normal
behaviour?

Thank you.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

You are doing this wrong; removes must happen in an orderly fashion orchestrated by windows. First thing to do is turn on driver verifier so you don’t do anything illegal like this. In order to unload your driver, you first need to cycle the device stack of the disk. There are programmatic ways of doing this and it is a normal way to get plug and play removal without the need for a system restart. You can do it manually by disable/enable in device manager.

Hi Eriksson,

What do you mean by cycle the device stack of the disk?

Thank you.