tags:

views:

306

answers:

4

How do I communicate with a driver from the userland in Windows? (Vista if that makes a difference.) Can I, and how, communicate with the service from the driver site?

I am actually not very lazy and should probably get my boss to buy me a book, but I don't know which. And guessing commands and sections from the MSDN is kinda taking a lot of nerves and time without the right terms to search for. Can someone drop me some terms to look for in the documentation?

+2  A: 

OSR online is a good source of information on writing windows drivers.

How to name devices in kernel mode (with a link to access security).

The basic path is :

Name your device object with one of the naming functions (e.g. WdfDeviceInitAssignName).

In the service you do :

hDev = CreateFile( <obj name>, ..., OVERLAPPED )

DeviceIOControl( hDev, .. , OVERLAPPED);

while( !end )
   SleepEx( 100, true /*bAltertable*/ );

...

In the driver, you have an IRP queue, in which you queue requests from the service. When you want to call the service, you complete one of the IRPs.

NB: Its a bit complex ... and depends on the driver framework/model you are working with. I had to do this only once with in a NDIS filter driver. Ask again, if you need more info.

Christopher
thanks for the fast response, I am digging through the answer (testing). The link requires (yet another) web account to be created.
Don Johe
+1  A: 
Don Johe
+1  A: 

In addition to what's been said above, your question: "Can I, and how, communicate with the service from the driver site?"

This is typically done through what they refer to as an "inverted call". You'll send an IOCTL down and block until the driver fills it with the data requested.

Also, with regard to what books to order, I actually enjoyed the Greg Hoglund Rootkits book for basic driver writing (that is, Hello World driver). OSR Online is excellent. An old one but still great is Windows NT Device Driver Development. OSR has classic reprints of great books to get.

Really though, the examples that come with the WDK from Microsoft will probably answer many of your questions.

mrduclaw
A: 

On the book: "Developing Drivers with the Windows Driver Foundation" has been recommendet in an answer to learning to program drivers

Don Johe