WdfDeviceAllocAndQueryProperty can I count on some properties to always exist?

Hi experts,
I am using WdfDeviceAllocAndQueryProperty as Mr. Scott suggested me to obtain some properties for the device to decide how to deal with it, since(if you remember my previous post) I install the same binary filter for different classes.
As I observed some values do not exist for some classes while the non-existent values change from class to class.
My question is can I count on these two properties to always exist?
DevicePropertyDeviceDescription
DevicePropertyClassName or DevicePropertyClassGuid
Or if you can specify all properties that can be counted on them to always have valid values.
I am talking about usual hardware that can be used as data storage(disk, usb flash, WPD, CD, …) in windows and do not need you to count third party or non-storage drivers in

I’m not sure.

The Device Class GUID is definitely required. I am not certain if you can have a Device Class GUID without a Device Class Name.

As I’m sure you’re aware, there are two names: FriendlyName and DeviceDescription. I am not sure which of these are required, or if they can change among device instances.

Peter

Can you please explicitly list all the REAUIRED ones?

As of friendly name I think I observed it did not exist for WPD device.

Can you please explicitly list all the REAUIRED ones?

I believe you are thinking about this in the wrong way. The property system is just a shortcut to collect information that is all available in other places.
Drivers do not create these properties. In that sense, none of them are “required”. Now, every device in WIndows belongs to a class with a name and a GUID, and because of that DevicePropertyClassName and DevicePropertyClassGuid will always have values. That’s pretty much the end of the guarantees. The other properties return whatever information is available.

The Windows device ecosystem is loose and fragmented. There are very, very few universal rules.

As of friendly name I think I observed it did not exist for WPD device.

At least, for the device you examined.

The property system is just a shortcut to collect information that is all available in other places.
Drivers do not create these properties.
By “other places” do you mean something like sending class specific ioctls to the function drivers to obtain information?
It does not mean anything specific. Does it?

No. It’s stuff from all over. Some is from the INF. Some is from the registry. Some is from the PDO. Some is from the bus. Some is from PnP. Some is from the device manager.

Ok. thanks for answering!

Just posting as information:
I am even getting different values for the same device:
The numbers are the enum values of DEVICE_REGISTRY_PROPERTY + 1

1- WPD FileSystem Volume Driver
2-
3- wpdbusenum\fs
6- WPD
7- {eec5ad98-8080-425f-922a-dabf3de3f69a}
8- {eec5ad98-8080-425f-922a-dabf3de3f69a}\0003
9- Microsoft
10-
11-
12- \Device\0000008a
16- SWD
23- {a90873d9-8f98-55eb-b837-fb1f5bfd3a6f}

and

1- Flash Disk
2-
3- wpdbusenum\fs
6- WPD
7- {eec5ad98-8080-425f-922a-dabf3de3f69a}
8- {eec5ad98-8080-425f-922a-dabf3de3f69a}\0003
9- Generic
10- F:
11-
12- \Device\00000090
16- SWD
23- {a90873d9-8f98-55eb-b837-fb1f5bfd3a6f}

As you can see DevicePropertyDeviceDescription has different value and the friendly name (f:) does not exist at the first query.

Well… yes. One of the above is apparently the file system instance on the volume, and the other is the device. Different DevNodes.

Peter

ETA: File system instance on the volume, not “volume”.

Still I can’t solve my question in the mind that why this happen for the same physical USB stick when I open it as a WPD device.

when I check the driver dtails tab in properties for WPd device in device manager I see the string “WPD FileSystem Volume Driver” as the driver description and “Flash Disk” as device description

In this case The information is obtained at the addDevice callback and sent later to the user mode when the first control IO occurs. I guess it is some WPD dependent mechanism that fill the device information with driver information at the first time attach since for some reason device info is not available yet and the latter attaches can use the device information since that is available at that point.

Well this shows such information is as unreliable as Mr. Roberts said.

This is bothering me since I have already filtered DiskDrives using an upper filter and I was hoping I could exclude USB sticks from being filtered by WPD upper filter by the means of device description which is showing different values now.

May I ask how you would implement excluding WPDfs from filtering and filter only MTP and PTP inside a WPD upper filter?

After 2 days of searching I found WdfFdoInitOpenRegistryKey!

May I ask how you would implement excluding WPDfs from filtering and filter only MTP and PTP inside a WPD upper filter?

Is it good enough for my purpose to use WdfFdoInitOpenRegistryKey with PLUGPLAY_REGKEY_DEVICE and obtain the value of PortableDeviceIsMassStorage to distinguish between WPDFS and MTP?