multiple interfaces of one device

Some keyboards have more than one device interfaces. Is it possible to find out which interfaces belong to a physical device?
I tried
PDEVICE_OBJECT pDevice = WdfDeviceWdmGetPhysicalDevice(device);
but I can’t find information which I can use.
I want to group the the interface under one name.
Is there a method of doing this?

I think you are confusing device interfaces with HID top level collections and their associated usage page. When a keyboard has multiple top level collections, each collection will enumerate as a separate child device. Each child device will enable an instance of the hid device interface (except for the keyboard usage itself as it will enable the keyboard device interface).

The notion of physical device is not at the device interface layer, but rather it is expressed in pnp as a removable device. Removable can be set on your device or one of the ancestors up the tree. In a hid keyboard case, it will definitely not be your hid device but further up the tree. It is not documented how to walk the tree in kernel mode, you can do it in user mode.

What bigger problem are you trying to solve?

d

Bent from my phone


From: Mak
Sent: Wednesday, November 21, 2018 8:49:17 AM
To: Doron Holan
Subject: [NTDEV] multiple interfaces of one device

OSR https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.osr.com%2F&data=02|01|doron.holan%40microsoft.com|bbbbaef5728c45d9f35408d64fd14770|72f988bf86f141af91ab2d7cd011db47|1|1|636784157604469277&sdata=iCz9213JhvIGcIE2s7rFouWmrZBPe31rm%2BoTD%2Bvd758%3D&reserved=0
Mak started a new discussion: multiple interfaces of one device

Some keyboards have more than one device interfaces. Is it possible to find out which interfaces belong to a physical device?

I tried

PDEVICE_OBJECT pDevice = WdfDeviceWdmGetPhysicalDevice(device);

but I can’t find information which I can use.

I want to group the the interface under one name.

Is there a method of doing this?

I work on a Keyboard upper filter driver.
I wanted to add an information at the device that I have this information on the user mode. With this information I want to group the devices in an gui application.
This is this special keyboard:
HID\VID_258A&PID_001A&MI_00\8&19d51533&0&0000
HID\VID_258A&PID_001A&MI_01&Col04\8&a02288f&0&0003
HID\VID_258A&PID_001A&MI_01&Col05\8&a02288f&0&0004
HID\VID_258A&PID_001A&MI_01&Col06\8&a02288f&0&0005
A further question on that. I get all this devices in the add routine at the driver but I know only the “…MI_00…” is relevant for me because with this device I can manipulate the keys. Is there a way to get this information inside the routine? I think to do somehting if in the string is “MI_00” is not a good solution.

The app UI can group these devices without the drivers help. From the device interface instance you can get the DEVINST. With the DEVINST you can get the parent. Find the common parent from all the device interfaces and you have grouping in your UI. You should not be reaching across device stacks and looking at the instance ID string for clues. Assuming you are device upper filter (and not a class upper filter), you are explicitly adding your filter with an INF and matching on a hardware ID. You can match on a different HWID with a different install section and set properties in this new section to tell your driver it is on a different type of device.

d

Thanks, I done it with SetupDiEnumDeviceInfo, CM_Get_Device_ID and CM_Get_Parent