Rescaning disk devices in an upper filter driver

Hello all,

I am working on an upper level filter driver. The driver properly handles plug and play control codes - including start, stop, and remove device - based on which a list of pointers to the device objects is maintained. Assume device list is an array of pointers where each valid element refers to an existing device object.

Is it possible that the filter driver misses (does not receive) some of the p&p events such as remove device? If yes, I can potentially end-up with one or more invalid pointers in my device list. Is there a way of (re)scanning disk devices (in addition to responding to p&p signals) to make sure of the validity of the objects my device list is pointing?

Thank you,
Hossein

xxxxx@datagardens.com wrote:

I am working on an upper level filter driver. The driver properly handles plug and play control codes - including start, stop, and remove device - based on which a list of pointers to the device objects is maintained. Assume device list is an array of pointers where each valid element refers to an existing device object.

Is it possible that the filter driver misses (does not receive) some of the p&p events such as remove device? If yes, I can potentially end-up with one or more invalid pointers in my device list. Is there a way of (re)scanning disk devices (in addition to responding to p&p signals) to make sure of the validity of the objects my device list is pointing?

What device objects are you holding, exactly? You shouldn’t be able to
see any device objects except your own and the device below you, and you
are guaranteed that you will not be unloaded before the device(s) below you.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I maintain a list of pointers, pointing to the device extensions, through which I get access to lower-level device objects. I properly maintain the list upon Add/Start/Stop/Remove of the device, and it works fine. It just happened to us recently a case where my device-list seemingly points to an invalid device. I did not have the chance to inspect the incidence closely, and am not sure of the exact source of error either. I just thought it would be good if I could rescan the device objects time to time make sure of validity of the objects.

xxxxx@datagardens.com wrote:

I maintain a list of pointers, pointing to the device extensions, through which I get access to lower-level device objects. I properly maintain the list upon Add/Start/Stop/Remove of the device, and it works fine. It just happened to us recently a case where my device-list seemingly points to an invalid device. I did not have the chance to inspect the incidence closely, and am not sure of the exact source of error either.

So, you have a filter that gets loaded in multiple device instances, and
you are somehow keeping a global list of the devices you are filtering?
Why? Good design practice dictates that each instance should be
entirely independent.

I just thought it would be good if I could rescan the device objects time to time make sure of validity of the objects.

There is no way to do that. You can’t look at an arbitrary section of
memory and answer the question “is this really a DEVICE_OBJECT?” The
only way to track the transitions is to monitor the PnP exchanges, as
you are doing.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.