WDM Programming Hints


This contains answers to questions many people have when doing WDM programming. If you know something that may help people, please email me. All information is Copyright 1998 by Lisa Patacchiola.

Last updated Aug 11, 1998


How to open a serial port with WDM drivers

The method is completely dependent on the operating system that you are planning to be running with.

If it is Windows NT 5.0, you can use driver layering and use the common serial port driver. The serial port can be reached by having your device be plug and play (during IoAttachDeviceToDeviceStack), or, get a handle with ZwCreateFile. After you have the handle, use IoCallDriver to send commands to the device. (Check NT Documentation, under Kernel Mode Drivers->Reference->Part 2->I/O Requests for Parallel and Serial Drivers.)

If it is Windows 98, a VxD layer will have to be written. The WDM driver sends all serial requests through the VxD layer to VCOMM.


Sending a special ioctl to a HID minidriver

Once a driver registers itself with the HID class driver, IoRegisterDeviceInterface doesn't work. Also, sending special ioctl's to the HID driver itself doesn't work, because it discards IOCTL's it isn't expecting. So, there are two methods that are suggested.
  1. If your device only expects reads, send a write request to the HID driver. This will be sent to the minidriver, which can do the appropriate function. This may cause problems down the line.
  2. Make a filter driver that is above the HID driver. This would allow changes to the data before applications receive it.

How to get device specific registry information

When there are move than one device using the same driver, device specific information can't use the same keys from DriverEntry. The call IoOpenDeviceInterfaceRegistryKey can be used to get the device specific key. An application (Win32) can also create/read/write this key. Look at the documentation for SetupDiCreateDeviceInterfaceKey and SetupDiOpenDeviceInterfaceKey.


Dynamic linking WDM drivers

For various different reasons, sometimes a WDM driver need to use a function in another driver. If a driver is exporting functions for another WDM driver, the exporter needs to be loaded first. Otherwise the importer waits for the other driver to load before functioning, or may crash. (I've seen both happen.)

Soon, How to export functions for a WDM driver, and why you would want to.


Go to driver annotation page