I’m seeing an issue that is very similar to one brought up in this forum several years ago on Windows 2000 (http://www.osronline.com/showThread.cfm?link=29549).
Apparently that problem was fixed in XP, but now we see strange behavior in a very similar scenario:
- The user inserts the hardware, a pcmcia device, into the system. It is assigned resources of, for instance, IRQ 7 and I/O range FFE0-FFFF.
- The user starts a process that opens a handle to the device, and everything works great.
- The user ejects the device. Our driver handles the IRP_MN_SURPRISE_REMOVAL message and it is completed with a successful status, but no IRP_MN_REMOVE_DEVICE is sent yet, since the process still has an open handle to the device.
- The user re-inserts the device. The new device is assigned the same resources it got the first time(?!). Apparently on 2K it would have crashed here due to a bug in how pcmcia.sys handled the SURPRISE_REMOVAL.
- The user closes the process, which closes the handle that it had to the device. Our driver receives and handles the IRP_MN_REMOVE_DEVICE for the first device. After we forward the REMOVE to the next lower driver, the resources for the first device, which were also assigned to the second device, disappear(?!?!). They still show up as being assigned to the device in the Device Manager, but any attempt to access that I/O range now fails.
- Ejecting and reinserting the device a second time makes things work again.
I am pretty sure that we are handling all of the IRPs correctly, and the history of pcmcia.sys makes me think that this is another bug in the pcmcia bus driver, but I’d like to find out if anyone is familiar with this issue. Could we be doing something wrong here, or is there something that we can do in our driver to workaround this problem?
Thanks!
-phil