WDM USB driver not unloading

Hi All,

I am writing a functional driver for one USB adapter.
When my USB adapter is removed from system, I am
getting a SURPRISE REMOVAL. In that I am deleting the
device object created by me in the AddDevice()
rotuine. But I found that the system keeps my device
object alive. Next time when I plug the device, it is
calling the AddDevice() rotuine directly. I also noted
that my driver UnLoad() routine is also not calling

Everything works when Disable/Enable the device from
device manager. In this case my Driver Unload is
calling. What is the problem.

I am closing all driver handles with the
RegisterDeviceNotification() function in User Mode.

The real problem is am getting a bluescreen, when I
shutdown the system with my USB device surprise
removed. No bluescreen, if I shutdown the system with
the USB adapter plugged in…

How I can debug this problem??? Please help.

Thanks in adavance
Suja.


Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/

  1. If you are using a device interfaces
    (IoRegisterDeviceInterface/IoSetDeviceInterfaceState), you must set the
    device interface state to FALSE in the surprise remove path
  2. if you are registering for WMI, you must deregister from wmi in
    surprise remove path.
  3. Are you calling ObReferenceObject anywhere in your code? If so,
    make sure it is paried with a dereference call

For 1) & 2), you need to track state in the remove path perform the same
ctions as in surprise remove only if you are were not surprise removed.
In other words, you must only perform 1) & 2) once. If you get surprise
removed, do it there. If you get query removed & removed, you do it in
remove.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of SUJA JAMES
Sent: Saturday, May 29, 2004 6:35 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDM USB driver not unloading

Hi All,

I am writing a functional driver for one USB adapter.
When my USB adapter is removed from system, I am
getting a SURPRISE REMOVAL. In that I am deleting the
device object created by me in the AddDevice()
rotuine. But I found that the system keeps my device
object alive. Next time when I plug the device, it is
calling the AddDevice() rotuine directly. I also noted
that my driver UnLoad() routine is also not calling

Everything works when Disable/Enable the device from
device manager. In this case my Driver Unload is
calling. What is the problem.

I am closing all driver handles with the
RegisterDeviceNotification() function in User Mode.

The real problem is am getting a bluescreen, when I
shutdown the system with my USB device surprise
removed. No bluescreen, if I shutdown the system with
the USB adapter plugged in…

How I can debug this problem??? Please help.

Thanks in adavance
Suja.


Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.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