Sometime ago I wrote 2 length articles on writing device drivers, using the new Kernel Mode Driver Framework that is the bees-knees when it comes to kernel mode programming.
Of course, I had to have a demo application to interact with the device drivers to control and monitor the USB device through the driver. I whipped together an MFC dialog application and a user mode API.
Since those were not the main point of my articles, I took some shortcuts to get working demo ASAP. Within the context of my demo, these shortcuts are safe enough. However, they are not an example of how to write user mode APIs.
In fact, they might encourage bad programming style if you would not understand that some things are only valid in a particular context. That is why I have not released the source code of the application and the API.
The problem is that every month, I get at least one and sometimes more requests for the code because there are very few examples on how to interact with device drivers.
I still don’t want to release the code because it is not an example of good programming.
I am writing a series of articles on how to write user mode APIs, but that is far from finished. That is why I extracted that portion of the code, since it is clean enough. It is available for download under the MIT license.
If there is anything you can learn for this, is that you should not take shortcuts if you create tutorial articles. Even it some piece of code is only there for support purposes, some people will need it to understand the whole picture.
Now then, when you look at those sources, you’ll see that all the win32 functions have a __ prefix. Those functions are wrappers around the true win32 function that throw exceptions instead of returning an error status. I have not included those wrappers because they contain macro magic that made my life easier, but is not how I would program production code.
This means that you cannot directly compile it, but it should be easy enough to adapt it and use it for interacting with my demo USB driver.
Good luck, and let me know if you have specific questions.