Windows KMDF driver, Informing application of a change via a notification, is it possible

675 views Asked by At

I have built a simple PCI driver for reading and writing data to a PCI device. I have also added interrupt support, so when there is a PCI interrupt an ISR is called. This all seems to work.

I would like to inform an external application of the interrupt. So far I haven't found a suitable mechanism. The interrupt could come at any time, and is dependent on Sensors connected to the PCI device.

I have found the following:-

1 Event objects which can be passed to the KMDF driver via read, write, iocontrol commands (Overlapped object)

2 Plug and Play notifications, which can be use used by (Toaster example code) the driver to inform the app of PNP events.

A notification method would be ideal, however it doesn't look like one exists for my particular use case.

1

There are 1 answers

1
Anand On BEST ANSWER

There are at least 2 ways to achieve what you are looking for

  1. Inverted call model - send IOCTL(s) to the driver which the driver will keep pending and will complete them as and when it needs to notify the user mode about the occurrence of the event that it is interested in. You can read more about this approach here.
  2. Use shared event handles. A user mode application communicates the event handle(s) to kernel mode using an IOCTL. The kernel mode increments the reference count to ensure that the handle remains valid when it needs to use it and then signals the event when necessary. You can read more about this approach here.

The first approach is more preferred for various reasons that you will find while reading the linked articles. If your use case requires the kernel mode to not only indicate the occurrence of an event but also send some data back to user mode then the second approach is not suitable for your requirement and you should focus on the first approach alone.