Is DevicePropertyPhysicalDeviceObjectName persistent across system restarts?

We have a filter driver and need a unique key that identifies each filtered device and will use this to store statistics about each device in our driver registry area. Note we need to access these statistics for “old” devices even if a device has not been present since the current system startup. Is the value returned from DevicePropertyPhysicalDeviceObjectName unique and persistent? Or is there something better to use?

Yes the PDO name is unique. The name is not persistent and changes on every boot. Are you reporting these statistics from a kernel driver or from a user mode application? If from user mode, you can store per device stats (assuming they are written by a filter) in the device node without explicitly knowing any unique identification for the device and the UM process reads the stats from both present and missing devices. The pnp device enumeration APIs will give you both with the right flags, although you may need to use the CM_Xxxx APIs

I want to explore this first. If we were to go the direction where the app uses CM_ instead of filter driver ioctl to get the statistics (which seems suitable for many designs), there are several questions on how to do this properly. At what point can the driver safely access the devnode registry area? It is a bus filter that gets notified of devices by QDR rather than AddDevice. Guessing at IRP_MN_DEVICE_ENUMERATED time. Also since a registry handle needs to stay open perpetually, at what point does a bus filter need to close the handle to assure proper pnp device removal? We only care about Win10 and later.

you can open the devnode when you have a PDO. IRP_MN_DEVICE_ENUMERATED tells you the reported device is now recognized as a PDO. Do you need the handle when the PDO is not running/in the started state? Open the handle in start device and close it surprise remove (only when reported missing) or remove device. If you are tracking outside of that state, you are already tracking the PDO’s state so you know when to detach/delete your filter DO. Close the handle at the same time.