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?
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.
I have to do this as an answer to keep the links, not as a comment to Christopher.
thanks again. And thanks to this tutorial I may add another answer shortly. It is the naming eg. by
IoCreateSymbolicLink(&usDosDeviceName, &usDriverName);that I needed. (I recommend above tutorial for making a complex topic easily understood) Userland programs may then communicate with the driver by opening a filehandle:
CreateFile("\\\\.\\Example",
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.
On the book: "Developing Drivers with the Windows Driver Foundation" has been recommendet in an answer to learning to program drivers
The ready-to-build-and-execute WDK sample SIOCTL is your best bet. Just few hundred lines of code (mostly comment and spaces) will give you a quick start and understanding of Windows I/O model, which is the official way of user <==> kernel communication method.
Every Windows driver learner should start with this one.
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?
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.
I have to do this as an answer to keep the links, not as a comment to Christopher.
thanks again. And thanks to this tutorial I may add another answer shortly. It is the naming eg. by
IoCreateSymbolicLink(&usDosDeviceName, &usDriverName);that I needed. (I recommend above tutorial for making a complex topic easily understood) Userland programs may then communicate with the driver by opening a filehandle:
CreateFile("\\\\.\\Example",
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.
On the book: "Developing Drivers with the Windows Driver Foundation" has been recommendet in an answer to learning to program drivers
The ready-to-build-and-execute WDK sample SIOCTL is your best bet. Just few hundred lines of code (mostly comment and spaces) will give you a quick start and understanding of Windows I/O model, which is the official way of user <==> kernel communication method.
Every Windows driver learner should start with this one.
0 commentaires:
Enregistrer un commentaire