Connecting Windows Driver to Userland Service

后端 未结 5 1891
轮回少年
轮回少年 2020-12-17 06:03

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?

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 06:44

    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( , ..., 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.

提交回复
热议问题