The device object cannot be deleted until all references to it are released, including the user-mode handle to the file object (which has a reference to the device object). Your driver will still receive the IRP_MJ_DEVICE_CONTROL requests from the user-mode app. The app is responsible for listening for device-removal notifications, and closing the handle when it is informed that the device under the handle has been removed.
Your driver will need to maintain some state (usually in the device extension), so that it knows when the device has been removed, so that it can immediately fail any new IRP_MJ_DEVICE_CONTROL (or IRP_MJ_READ, WRITE, etc.) requests.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ajitabh Saxena
Sent: Friday, January 19, 2007 12:13 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device Removal Notificaiton.
I have a controller on which there is active DMA going on. These
operations are started by the application using the private interface. I
want to be able to handle the IOCTL at the time the device is removed
and don’t do any invalid operation. I think that after this information
I will be fine.
One more question. On device removal once the device is deleted what
happens to the DeviceIoControl call that the application makes using a
‘stale’ handle???
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@Microsoft.com
Sent: Thursday, January 18, 2007 4:15 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Device Removal Notificaiton.
The surprise removal irp travels down the stack to the PDO, it does not
originate in the PDO. AFAIK, the order in which the driver stack is
notified and the application is notified is not documented. You as the
driver writer have to defensively code for both situations regardless
(since the app can send i/o after it has been notified of the removal).
Are you curious or is there an underlying problem that you are trying to
solve?
thx
d
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer