IoRegisterPlugPlayNotification For KMDF PCIe Function Driver

Hi All,
I am a little unclear about the operation of IoRegisterPlugPlayNotification function and how it behaves. The API takes input

  1. DriverObject that implements the "CallBack"
  2. The "CallBack" Function
  3. a "Context" which is passed to the "CallBack" when invoked.

For a function driver the FDO is created in AddDevice and when the driver is ready for handling the PNP notifications, it will call IoRegisterPlugPlayNotification with the pointer to Device Extension which is valid for the FDO.

The Scenario:-

For a multiple controller on a server the AddDevice will be called multiple times. So there will be multiple FDOs and IoRegisterPlugPlayNotification will be called multiple times, each invocation with its own DeviceExtension pointer. But all the invocations will have the SAME DriverObject.

Questions:-

  1. When I call IoRegisterPlugPlayNotification multiple times with same driver object, same callback function but different context will the registration work? Will the callback get invoked with the context I specified?

My understanding it that it should work for multiple registrations because the API returns a PVOID which is the handle to the registration. But I can be wrong.

Thanks
Aj

The driver object is for external reference counting to make sure your image is still in memory when the callback is invoked. Each registration is distinct, the returned NotificationEntry is clear indicator of this as you need to pass this for each call to IoUnregisterPlugPlayNotificationEx

Thanks. This is what my understanding was too. Thanks a bunch @Doron_Holan appreciate the clarification.