Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unsafe USB Memory stick removal

0 views
Skip to first unread message

Shane Bush

unread,
Aug 22, 2005, 7:45:47 AM8/22/05
to
For background information, WIN2K behaves differently than WINXP with regard
to unexpected USB memory stick removal. Both platforms provide a manual
tool tray icon/service to "remove" the device cleanly. In the case of Win2K
if the tool is not used then it will generate a pop-up dialog informing the
user that something bad may happen. WinXP does not do this. What I am
looking for is the functions to call to provide the same service and the
tool tray app so that the user is not bothered in Win2K.

So far I have been able to find the low level interfaces in the kernal
driver domain for this capability. From the MSDN documentation there is
kernal mode interface to the driver to handle removal,
IRP_MN_QUERY_REMOVE_DEVICE. This of course is only one a couple of IRP's
that must be used to remove the device. What I have not found yet is the
application interface to call into either the PNP manager or to the device
directly. Please advice. Thanks.


Martin Borve [MSFT]

unread,
Aug 22, 2005, 8:14:19 PM8/22/05
to
The "Unsafe Removal of Device" was removed from Windows XP entirely. You
will not see this dialog for surprise removal of any device.

There is no API to enable or disable this behavior in Win2K. The only
thing that determines if this dialog appears is whether or not the device
indicated that it supports surprise removal. This is done by setting the
DEVICE_CAPABILITIES SurpriseRemovalOK field to TRUE when handling
IRP_MN_QUERY_CAPABILITIES.

To change this behavior you would need to write a filter driver that
installs on top of the device you are interested in, and then modifies the
SurpriseRemovalOK field when IRP_MN_QUERY_CAPABILITIES is being completed.

Martin Borve
Windows DDK Support
This posting is provided "AS IS" with no warranties, and confers no rights.


Shane Bush

unread,
Aug 23, 2005, 2:11:10 PM8/23/05
to
I don't think I was being clear with the original question. So here is a
second try at asking the question.

What I am looking for is a method to provide the same capability as the Tool
Tray app that provides the safe method of "Eject or unplug hardware". In
our application we want to be able to cleanly handle USB device removal such
that the user does not need to use the provided Tool Tray application. I
have read through several MSDN pages that discuss the pnp Manager and its
ability to performs these operations on devices, however most of the
discussion is based on the kernal side of writing device drivers. We are
not trying to write a custom device driver merely trying to use the services
that exist within Windows.

Thanks.

""Martin Borve [MSFT]"" <mart...@online.microsoft.com> wrote in message
news:MIu%23de3p...@TK2MSFTNGXA01.phx.gbl...

Maxim S. Shatskih

unread,
Aug 23, 2005, 2:23:07 PM8/23/05
to
In the kernel-mode driver, set DEVICE_CAPABILITIES::SurpriseRemovalOK to
TRUE.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"Shane Bush" <sh...@online.nospam> wrote in message
news:O0JKS4Aq...@TK2MSFTNGP12.phx.gbl...

Scott Noone

unread,
Aug 23, 2005, 2:41:50 PM8/23/05
to
If you just want to mimic the safely remove hardware wizard look at the
CM_Xxx and SetupDiXxx APIs in the DDK (probably also in the SDK). I think
that CM_Request_Device_Eject is the call that you ultimately want to make..

-scott

--
Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

"Shane Bush" <sh...@online.nospam> wrote in message
news:O0JKS4Aq...@TK2MSFTNGP12.phx.gbl...

0 new messages