R – Connecting Windows Driver to Userland Service

driverwindows

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?

Best Solution

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.