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/
So I have a keyboard identifier (UnitID from KEYBOARD_INPUT_DATA, which I think it should be unique per connected devices on the system) that I store for later use and I need to get the WdfDevice associated with it. What I thought is to loop through every device, check if it is of type keyboard and if so, get it's UnitId and compare with the one that I have.
So, I tried to loop through every device that the driver registered, however, I found no function to loop through devices using pure Wdf (WDFDRIVER object), I had to get a POBJECT_DRIVER from the WDFDRIVER with WdfDriverWdmGetDriverObject and using NextDevice on the first DeviceObject. But now I'm stuck in converting the POBJECT_DEVICE back to WdfDevice, I only found a function to convert POBJECT_DEVICE to WdfDevice (WdfDeviceWdmGetDeviceObject). What should I use to convert it back? Is identifying a device by UnitId safe or should I identify it by the entire HID? Is there a better (in terms of efficiency) internal method to get a device from hid/unitid than looping through them myself? There is also a KeyboardIdentifier (made of 2 CHARs, Type and Subtype) in KEYBOARD_ATTRIBUTES, is that Unique?
Edit: Found how to convert the Wdm object back to a wdf object (WdfWdmDeviceGetWdfDeviceHandle). Looking at the docs, UnitId should be unique per plugged keyboard as it is the number in the device name ("\Device\KeyboardPortN"). My question about a more efficient method is still present tho.
|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|