Read HID serial number from lower filter driver

Hello driver developers out there,

I’m writing a driver for a HID device which can be connected via USB or Bluetooth (BTH).

I know that each device has a unique serial number (in addition the serial number is different for USB and BTH connection). I can read this serial numbers with an user app very easy via HidD_GetSerialNumberString().

I like to know this serial number in my driver for licensing reasons. My driver will be licensed to the device serial numbers so the driver needs to verify if a “licensed” device is connected.

I have a working lower HID filter driver.

How do I read the device serial number?. There is IOCTL_HID_GET_SERIALNUMBER_STRING but as far as I understand I can’t talk to “my” HID-Class driver as my lower filter driver can pass the IoControlCode only down the stack, not upwards.

I search a lot but couldn’t find any hint which pointed me to a workable direction.

  1. Is there a way to talk to “my” HID-Class driver instance from my lower filter driver to obtain the serial number the same way as the user app?

  2. If I can’t talk to my HID-Class driver, I know how to get the USB Serial number from the URB descriptor. But how on earth how do I get the serial number when connected via BTH?

Note: I am intercepting the device control via EvtIoDeviceControl and EvtIoInternalDeviceControl, so I can listen to all communication, but not sure if this helps.

Any hints would be highly appreciated.
Thanks

Answering 2)

HidD_GetSerialNumberString() returns not a special serial number but simply the Bluetooth devices address.

It is in the device descriptors, so somewhere with the VID/PID data. Grab those, there is a call that goes something like IoGetDeviceObjectProprtty() to get this kind of data off the PDO.

Thanks Matt,

I got the USB Serial from the device descriptor, my real issue was Bluetooth serial number.

There is somewhere an optional field, but I was after the same number “serial number” as the HID class provides. In my case, the Bluetooth serial it is just the Bluetooth address (not that optional field).

All good an solved.

> In my case, the Bluetooth serial it is just
the Bluetooth address (not that optional field).

All good an solved.

Just consider that MAC address of BT devices can be fake (randomly generated, to foil tracking). Thus, it is only so good as an “unique ID”.

– pa

>Just consider that MAC address of BT devices can be fake (randomly generated, to

foil tracking). Thus, it is only so good as an “unique ID”.

Thanks for this hint. But even the US President can be fake these days :frowning:

Almost all politicans are fake. Trump might actually be, in being a fake president, useful to the country. Time will tell.