Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Easiest way is to create a Symbolic link in DriverEntry using <code>IoCreateSymbolicLink</code></p> <p>Then from the user mode program call <code>CreateFile</code> with the name of the symbolic link and use either <code>ReadFile</code>/<code>WriteFile</code> or <code>DeviceIoControl</code> to send/receive data to/from the driver.</p> <p>For <code>ReadFile</code>/<code>WriteFile</code> option you need to implement <code>IRP_MJ_READ</code>/<code>IRP_MJ_WRITE</code> processing in your driver. </p> <p>For <code>DeviceIoControl</code> you need to handle <code>IRP_MJ_DEVICE_CONTROL</code>.</p> <p>Here's a very nice <a href="http://www.codeproject.com/Articles/9504/Driver-Development-Part-1-Introduction-to-Drivers" rel="nofollow">article</a> demonstrating this technique, with sample code for both kernel and user mode. I copied main parts from it related to your question:</p> <pre><code>//how to create symbolic link NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath) { UNICODE_STRING usDriverName, usDosDeviceName; RtlInitUnicodeString(&amp;usDriverName, L"\\Device\\Example"); RtlInitUnicodeString(&amp;usDosDeviceName, L"\\DosDevices\\Example"); IoCreateDevice(pDriverObject, 0, &amp;usDriverName, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &amp;pDeviceObject); IoCreateSymbolicLink(&amp;usDosDeviceName, &amp;usDriverName); } //How to use from user mode int main() { hFile = CreateFile("\\\\.\\Example", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); //use ReadFile, WriteFile, or DeviceioControl here return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload