I'm reading a book on driver development, and the book has suggested I create an IO Device using IoCreateDevice, then communicate to the driver by having a handle to it collected by using the CreateFile API, and use read\write to communicate. Problem is, when I try to open a handle to the IO device, I can't have it open. Research on a forum tells me that I need to use NtCreateFile API, which is defined in Winternl.h, which is fine. But to use this method I need to call InitializeObjectAttributes, which is defined in Wdm.h or Ntddk.h. Thus this forces me to include the ddk headers, and because this application runs in usermode, it also makes use of the platform sdk, windows.h, etc. I can't use both headers(windiows platform SDK headers & DDK Headers) without getting a million redefinitions. So I was curious what I should be doing. I understand that VS was not designed to create drivers. But this isn't a driver, this is a user-mode application which communicates with the driver.
I have similar problem. It's not possible to guess which h files and in which order need to be included in your application.
If you have installed WinDDK, search for exe directories under src directory.
exe directories contain an windows (console) application. If there is an exe directory under the name of device that you are working on, you are lucky. use that application as your start point.
I’m looking into this issue but don’t have an answer available immediately. I’ll try to have someone respond by early next week.
The Windows Driver Kit (previously known as the DDK) has a forum on MSDN where you might get a faster response:
||Karin Meier||Windows SDK PM||Samples.Community||http://blogs.msdn.com/KarinM||
I don't believe there is any particular reason you should need to use NtCreateFile to access a device. I need more details about what's going on in order to help out more. What error is CreateFile returning? What type of device are you trying to access? Is this a driver that you've written or have source code for? Some code that shows what you're doing with IoCreateDevice and CreateFile would be useful as well.
Windows Driver Kit Developer