Hello,
First, thanks for all the great posts and answers. as a newbie driver writer, I have learned a lot in this forum.
I am writing a driver for virtual storage devices. I communicate with my driver through a DLL. I have been requested to find a way to clear all connected virtual devices if the app that loads the DLL happens to crash (if it crashes, the driver can be left with “zombie” virtual devices connected).
Now, the costumer is OK with manually doing disable-enable (it would solve my problem). but doing so after the app crashes prompts me to restart, and I don’t want that (doing so without the app running does not require a restart).
So, two questions:
When would disabling a device in the Device Manager (I mean right click->disable) ask you to restart your computer?
do you think there is a better solution for my problem? I mean, is there a way for the driver to “know” the app has crashed, without having to manually disable?
The driver will see a file close (EvtFileClose or IRP_MJ_CLOSE) on the on the file handle. If you are a storport miniport, you won’t see the close as storport handles it for you. The disable fails b/c the application which has a handle open on your device fails to close the handle, probably b/c it didn’t register for file handle notifications. Setupapi.dev.log will tell you exactly why the disable failed.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@tandemg.com
Sent: Monday, June 6, 2016 8:17 AM
To: Windows System Software Devs Interest List Subject: RE:[ntdev] Disabling a device in the Device Manager
That’s what I want to do, but how can the driver be notified about the application handle closing?
It fails because of an open file handle, like you said. how can I make sure the handle closes when the app crashes? what do you mean with “register for file handle notifications”?
Guys, I faced with same problem, but in my app I use SetupApi functions to disable usb webcam, but when it’s opened in Skype (for example) disable operation failed and in setupapi.app.log :
>> [DIF_PROPERTYCHANGE - USB\VID_0AC8&PID_3450&MI_00\8&30692CC7&0&0000]
>> Section start 2016/06/07 18:30:05.721
cmd: “C:\MyTestApp.exe”
! dvi: Device required reboot: Could not disable device for hardware profile.
<<< Section end 2016/06/07 18:30:10.732
<<< [Exit status: SUCCESS]
It’s possible in real world solve this problem and force to close handles by SetupApi or other system functions?
From: xxxxx@gmail.commailto:xxxxx Sent: Tuesday, June 7, 2016 8:36 AM To: Windows System Software Devs Interest Listmailto:xxxxx Subject: RE:[ntdev] Disabling a device in the Device Manager
Guys, I faced with same problem, but in my app I use SetupApi functions to disable usb webcam, but when it’s opened in Skype (for example) disable operation failed and in setupapi.app.log :
>>> [DIF_PROPERTYCHANGE - USB\VID_0AC8&PID_3450&MI_00\8&30692CC7&0&0000] >>> Section start 2016/06/07 18:30:05.721 cmd: “C:\MyTestApp.exe” ! dvi: Device required reboot: Could not disable device for hardware profile. <<< Section end 2016/06/07 18:30:10.732 <<< [Exit status: SUCCESS]
It’s possible in real world solve this problem and force to close handles by SetupApi or other system functions?
Guys, I faced with same problem, but in my app I use SetupApi functions to disable usb webcam, but when it’s opened in Skype (for example) disable operation failed and in setupapi.app.log :
…
It’s possible in real world solve this problem and force to close handles by SetupApi or other system functions?
How do you think that could possibly work? The application thinks he’s
talking to a device. If his handle is suddenly closed, what’s supposed
to happen to his outstanding I/O requests, or future I/O requests?
The contract is that the driver remains in memory until the last handle
closes. That’s just the way it is.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
From: Tim Robertsmailto:xxxxx Sent: June 7, 2016 1:18 PM To: Windows System Software Devs Interest Listmailto:xxxxx Subject: Re: [ntdev] Disabling a device in the Device Manager
xxxxx@gmail.com wrote: > Guys, I faced with same problem, but in my app I use SetupApi functions to disable usb webcam, but when it’s opened in Skype (for example) disable operation failed and in setupapi.app.log : > … > > It’s possible in real world solve this problem and force to close handles by SetupApi or other system functions?
How do you think that could possibly work? The application thinks he’s talking to a device. If his handle is suddenly closed, what’s supposed to happen to his outstanding I/O requests, or future I/O requests?
The contract is that the driver remains in memory until the last handle closes. That’s just the way it is.
– Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.