Hi,

Greetings.

In the firefly example, the Fileobject handle of PDO was acquired using
ZwOpenFile() and ObReferenceObjectByHandle() for each Set Feature, and was
released immediately after every Set Feature.

But if I save the Fileobject handle in my device extension during the first
Set Feature and use it for all subsequent Set Feature calls, after which
Dereference it during my Remove Device, the mouse seems not to respond to
any physical movement. The Service_CallBack() routine in Firefly is never
triggered.

Anyone can enlighten me is it compulsory that the FileObject handle must be
released immediately after every set feature, and the reason behind it if it
is true?

Thanks in advance.

Regards,
Angela

Re: PDO FireObject of Firefly example by Eliyas

Eliyas
Thu Sep 08 01:58:43 CDT 2005

If you keep the file handle open then you have to register for PnP
device-change notification on the target device so that you can close the
handle when the device is being removed. If you don't close the handle at
the appropriate time, it will prevent the device from being removed.

Since you are basically opening your own PDO, you might be able to close the
handle in Query-remove and reopen it Cancel-remove irps sent to your stack -
and not deal with pnp device-change notificaion mess. I haven't tried that
so I can't say for sure that would work because it depends on whether the
PNP sends query-remove notification to the driver before checking for open
handles or after.

That aside I don't see any connection to the problem you are having.

Study the toastmon sample if you want to how to register for pnp
notification in kernel-mode.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx