Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


WdfDeviceAllocAndQueryProperty can I count on some properties to always exist?

Ehsan_TaheriEhsan_Taheri Member Posts: 188

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

Comments

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,090

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

    Can you please explicitly list all the REAUIRED ones?

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

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

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627
    edited September 21

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

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

    At least, for the device you examined.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188
    edited September 21

    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?

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

    Ok. thanks for answering!

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

    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.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,090
    edited September 21

    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”.

    Peter Viscarola
    OSR
    @OSRDrivers

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

    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?

  • Ehsan_TaheriEhsan_Taheri Member Posts: 188

    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?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE