I am new to driver development. I have a query regarding communication between driver and application. My application creates an event and passes to driver through IOCTL. The driver signals the event at different points of time with a status value. This Status value is handled through another IOCTL. My applcation runs as daemon wating for the event to set.
My problem is whenever driver is disabled from device manager, the system asks for re-boot. I assume that this is because my driver handle is opened and application is waiting on WaitForSingleObject(). I want to close my application whenever driver is disabled or uninstalled. My driver and application are for WINXP. The driver is for removable media storage device.
Is there any way to properly close the application without asking for re-boot.
Thanks and Regards,
Sush.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
You don’t need to pass an event in your design. Instead, open the driver as overlapped so you can send multiple I/Os at once. Send an IOCTL down to the driver. The driver will pend the PIRP until the condition in which you are interested in occurs and then the driver just completes the I/o back to the driver.
To prevent the reboot request, you must register for notifications on the open handle (which requires a window or a service handle). See the API RegisterDeviceNotification() on how to register notifications on the handle. When you get a query for removal, you cancel the i/o you send, unblock all waiting threads (which means if you are waiting for i/o to complete, you wait on 2 events, one for the i/o, the other signaling an abort), and then close the handle. This will only work if your driver is a PNP driver, this will not work for an NT4 style legacy driver.
d
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella
Sent: Wednesday, August 31, 2005 10:23 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Event Handling - Driver and Application
Hello All,
?
I am new to driver development. I have a query regarding communication between driver and application. My application creates an event and passes to driver through IOCTL. The driver signals the event at different points of time with a status value. This Status value is handled through another IOCTL. My applcation runs as daemon wating for the event to set.
?
My problem is whenever driver is disabled from device manager, the system asks for re-boot. I assume that this is because my driver handle is opened and application is waiting on WaitForSingleObject(). I want to close my application whenever driver is disabled or uninstalled. My driver and application are for WINXP. The driver is for removable media storage device.
?
Is there any way to properly close the application without asking for re-boot.
?
Thanks and Regards,
Sush.
Thanks Doron for the reply. I did few changes to the driver. In my application i want to capture the current device (or driver) state, whether the driver is disabled or driver is enabled. Depending upon the state i would like to perform some actions.
I tried out with Setup… functions, but could not get it solved. Can any one suggest what functions can i use to get the current device state.
Thanks & Regards
Sush
Doron Holan wrote: You don’t need to pass an event in your design. Instead, open the driver as overlapped so you can send multiple I/Os at once. Send an IOCTL down to the driver. The driver will pend the PIRP until the condition in which you are interested in occurs and then the driver just completes the I/o back to the driver.
To prevent the reboot request, you must register for notifications on the open handle (which requires a window or a service handle). See the API RegisterDeviceNotification() on how to register notifications on the handle. When you get a query for removal, you cancel the i/o you send, unblock all waiting threads (which means if you are waiting for i/o to complete, you wait on 2 events, one for the i/o, the other signaling an abort), and then close the handle. This will only work if your driver is a PNP driver, this will not work for an NT4 style legacy driver.
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Wednesday, August 31, 2005 10:23 PM To: Windows System Software Devs Interest List Subject: [ntdev] Event Handling - Driver and Application
Hello All,
I am new to driver development. I have a query regarding communication between driver and application. My application creates an event and passes to driver through IOCTL. The driver signals the event at different points of time with a status value. This Status value is handled through another IOCTL. My applcation runs as daemon wating for the event to set.
My problem is whenever driver is disabled from device manager, the system asks for re-boot. I assume that this is because my driver handle is opened and application is waiting on WaitForSingleObject(). I want to close my application whenever driver is disabled or uninstalled. My driver and application are for WINXP. The driver is for removable media storage device.
Is there any way to properly close the application without asking for re-boot.
Devices are enabled/disabled, not drivers. The SetupDi functions include a
notification mechanism that allows a service or application to be notified
of PnP state changes for devices that they are interested in. As Doron noted
you must implement RegisterDeviceNotification in your application so that
you can close open handles on device remove. If this is not working for you
then you have a bug in your code that you need to fix.
=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032 www.hollistech.com
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella
Sent: Thursday, September 01, 2005 7:18 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks Doron for the reply. I did few changes to the driver. In my
application i want to capture the current device (or driver) state, whether
the driver is disabled or driver is enabled. Depending upon the state i
would like to perform some actions.
I tried out with Setup… functions, but could not get it solved. Can any one
suggest what functions can i use to get the current device state.
Thanks & Regards
Sush
Doron Holan wrote:
You don’t need to pass an event in your design. Instead, open the driver as overlapped so you can send multiple I/Os at once. Send an IOCTL down to the driver. The driver will pend the PIRP until the condition in which you are interested in occurs and then the driver just completes the I/o back to the driver.
To prevent the reboot request, you must register for notifications on the open handle (which requires a window or a service handle). See the API RegisterDeviceNotification() on how to register notifications on the handle. When you get a query for removal, you cancel the i/o you send, unblock all waiting threads (which means if you are waiting for i/o to complete, you wait on 2 events, one for the i/o, the other signaling an abort), and then close the handle. This will only work if your driver is a PNP driver, this will not work for an NT4 style legacy driver.
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Wednesday, August 31, 2005 10:23 PM To: Windows System Software Devs Interest List Subject: [ntdev] Event Handling - Driver and Application
Hello All,
I am new to driver development. I have a query regarding communication between driver and application. My application creates an event and passes to driver through IOCTL. The driver signals the event at different points of time with a status value. This Status value is handled through another IOCTL. My applcation runs as daemon wating for the event to set.
My problem is whenever driver is disabled from device manager, the system asks for re-boot. I assume that this is because my driver handle is opened and application is waiting on WaitForSingleObject(). I want to close my application whenever driver is disabled or uninstalled. My driver and application are for WINXP. The driver is for removable media storage device.
Is there any way to properly close the application without asking for re-boot.
If the device is disabled (e.g. you go to device manager and disable it), there is nothing you can talk to b/c your driver is unloaded. Are you talking about a different disabled state?
d
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella
Sent: Thursday, September 01, 2005 4:18 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks Doron for the reply. I did few changes to the driver. In my application i want to capture the current device (or driver) state, whether the driver is disabled or driver is enabled. Depending upon the state i would like to perform some actions.
?
I tried out with Setup… functions, but could not get it solved. Can any one suggest what functions can i use to get the current device state.
?
Thanks & Regards
Sush
Doron Holan wrote: You don’t need to pass an event in your design. Instead, open the driver as overlapped so you can send multiple I/Os at once. Send an IOCTL down to the driver. The driver will pend the PIRP until the condition in which you are interested in occurs and then the driver just completes the I/o back to the driver.
To prevent the reboot request, you must register for notifications on the open handle (which requires a window or a service handle). See the API RegisterDeviceNotification() on how to register notifications on the handle. When you get a query for removal, you cancel the i/o you send, unblock all waiting threads (which means if you are waiting for i/o to complete, you wait on 2 events, one for the i/o, the other signaling an abort), and then close the handle. This will only work if your driver is a PNP driver, this will not work for an NT4 style legacy driver.
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Wednesday, August 31, 2005 10:23 PM To: Windows System Software Devs Interest List Subject: [ntdev] Event Handling - Driver and Application
Hello All, ? I am new to driver development. I have a query regarding communication between driver and application. My application creates an event and passes to driver through IOCTL. The driver signals the event at different points of time with a status value. This Status value is handled through another IOCTL. My applcation runs as daemon wating for the event to set. ? My problem is whenever driver is disabled from device manager, the system asks for re-boot. I assume that this is because my driver handle is opened and application is waiting on WaitForSingleObject(). I want to close my application whenever driver is disabled or uninstalled. My driver and application are for WINXP. The driver is for removable media storage device. ? Is there any way to properly close the application without asking for re-boot. ? Thanks and Regards, Sush. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com
Thanks for the reply. I have implemented RegisterDeviceNotification(), where my application will receive the notifications. I found various events DBT_XXX which are to be handled in WndProc of my application. But i did not find any event which will notify driver is disabled/uninstalled.
I want to close driver handle and terminate the application only when driver is disabled or uninstalled. Which event will get this notification.
Thanks,
Best Regards,
Sushma
Doron Holan wrote: If the device is disabled (e.g. you go to device manager and disable it), there is nothing you can talk to b/c your driver is unloaded. Are you talking about a different disabled state?
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Thursday, September 01, 2005 4:18 AM To: Windows System Software Devs Interest List Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks Doron for the reply. I did few changes to the driver. In my application i want to capture the current device (or driver) state, whether the driver is disabled or driver is enabled. Depending upon the state i would like to perform some actions.
I tried out with Setup… functions, but could not get it solved. Can any one suggest what functions can i use to get the current device state.
Thanks & Regards Sush
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Your terminology is confusing. Driver’s control DeviceObjects which in turn
can have related FileObjects which in turn can have associated handles. Your
application has a handle that is associated with a FileObject that is
related to a specific DeviceObject that is in turn associated with your
Driver. Your application does not have a handle to a driver, it has a handle
to a device.
It is devices that are enabled/disabled by PnP management operations, and it
is device PnP state changes that you are notified of when you register for
device notification. Your driver is NOT enabled/disabled if it is a PnP
driver, its devices are enabled/disabled. Your correctly implemented PnP
driver will be unloaded when its last device is removed.
=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032 www.hollistech.com
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella
Sent: Friday, September 02, 2005 4:38 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks for the reply. I have implemented
RegisterDeviceNotification(), where my application will receive the
notifications. I found various events DBT_XXX which are to be handled in
WndProc of my application. But i did not find any event which will notify
driver is disabled/uninstalled.
I want to close driver handle and terminate the application only
when driver is disabled or uninstalled. Which event will get this
notification.
Thanks,
Best Regards,
Sushma
Doron Holan wrote:
If the device is disabled (e.g. you go to device manager and disable it), there is nothing you can talk to b/c your driver is unloaded. Are you talking about a different disabled state?
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Thursday, September 01, 2005 4:18 AM To: Windows System Software Devs Interest List Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks Doron for the reply. I did few changes to the driver. In my application i want to capture the current device (or driver) state, whether the driver is disabled or driver is enabled. Depending upon the state i would like to perform some actions.
I tried out with Setup… functions, but could not get it solved. Can any one suggest what functions can i use to get the current device state.
Open the handle, and register for handle-based removal notification. In the notification routine, close the handle.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation xxxxx@storagecraft.com http://www.storagecraft.com
----- Original Message -----
From: Sushma Yella
To: Windows System Software Devs Interest List
Sent: Friday, September 02, 2005 12:38 PM
Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks for the reply. I have implemented RegisterDeviceNotification(), where my application will receive the notifications. I found various events DBT_XXX which are to be handled in WndProc of my application. But i did not find any event which will notify driver is disabled/uninstalled.
I want to close driver handle and terminate the application only when driver is disabled or uninstalled. Which event will get this notification.
Thanks,
Best Regards,
Sushma
Doron Holan wrote: If the device is disabled (e.g. you go to device manager and disable it), there is nothing you can talk to b/c your driver is unloaded. Are you talking about a different disabled state?
d
________________________________________ From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Sushma Yella Sent: Thursday, September 01, 2005 4:18 AM To: Windows System Software Devs Interest List Subject: RE: [ntdev] Event Handling - Driver and Application
Thanks Doron for the reply. I did few changes to the driver. In my application i want to capture the current device (or driver) state, whether the driver is disabled or driver is enabled. Depending upon the state i would like to perform some actions.
I tried out with Setup… functions, but could not get it solved. Can any one suggest what functions can i use to get the current device state.