Register software driver(FILE_DEVICE_UNKNOWN) with PNP

Hello,

Reference:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn613933(v=vs.85).aspx

Question:
How can I register a software driver with device type FILE_DEVICE_UNKNOWN
with PNP and then send notifications to usermode application?

Note: I have already implemented Inverted Call Model.

I want to explore this communication mode using software driver.

> How can I register a software driver with device type FILE_DEVICE_UNKNOWN
with PNP and then send notifications to usermode application?

A template KMDF driver provided by VisualStudio 2015 and WDK10 is what you need. This kind of project provides a PNP root enumerated KMDF device and a WDF queue.

You also need WdfDeviceInitSetDeviceType. You typically call this routine in the EvtDriverDeviceAdd callback routine before WdfDeviceCreate is called. Remember to use WdfDeviceWdmGetPhysicalDevice to obtain the PDO because IoReportTargetDeviceChangeAsynchronous uses a PDO and not an FDO.

You also need a custom GUID for the event (PNP event). Use UUIDGEN.EXE (Within a VisualStudio 2015 CMD.EXE console). The program can copy the DEFINE_GUID macro invocation to the clipboard so you just need to paste the code in your header file. A GUID is already defined in the project for the device interface, so you already have an example.

Once you have all these things, you just need to decide where to fire the PNP event in your driver code with IoReportTargetDeviceChangeAsynchronous.

Sent from my phone

xxxxx@gmail.com wrote:

Reference:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn613933(v=vs.85).aspx

Question:
How can I register a software driver with device type FILE_DEVICE_UNKNOWN
with PNP and then send notifications to usermode application?

Is your driver already PnP compliant? If you call IoCreateDevice (or
WdfDeviceCreate) during your DriverEntry, then you are not PnP, and you
can’t use the notification scheme. If you call
IoCreateDevice/WdfDeviceCreate during an AddDevice call, then you are
PnP, and this is fully available to you.

Note: I have already implemented Inverted Call Model.

I want to explore this communication mode using software driver.

What led you to this? I suspect you will find that the
RegisterDeviceNotification path is not any simpler than the
well-understood inverted call model.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The device type is inconsequential for what you want to do. Any device type will do. It is the IoReportxxx API that is key

Bent from my phone


From: xxxxx@lists.osr.com on behalf of Tim Roberts
Sent: Thursday, April 20, 2017 8:37:15 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Register software driver(FILE_DEVICE_UNKNOWN) with PNP

xxxxx@gmail.com wrote:
> Reference:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fwindows%2Fhardware%2Fdn613933(v%3Dvs.85).aspx&data=02|01|Doron.Holan%40microsoft.com|1a39ac506bfd47b348a908d488033193|72f988bf86f141af91ab2d7cd011db47|1|0|636282994707333477&sdata=YR6apfk4uJqDJPNMEAsv0Hj%2F9kNHDLwAh9X0nWafiD4%3D&reserved=0
>
> Question:
> How can I register a software driver with device type FILE_DEVICE_UNKNOWN
> with PNP and then send notifications to usermode application?

Is your driver already PnP compliant? If you call IoCreateDevice (or
WdfDeviceCreate) during your DriverEntry, then you are not PnP, and you
can’t use the notification scheme. If you call
IoCreateDevice/WdfDeviceCreate during an AddDevice call, then you are
PnP, and this is fully available to you.

> Note: I have already implemented Inverted Call Model.
>
> I want to explore this communication mode using software driver.

What led you to this? I suspect you will find that the
RegisterDeviceNotification path is not any simpler than the
well-understood inverted call model.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

>> What led you to this?
I have implemented inverted call model for the purpose of constructing an
event provider.
On reading Microsoft published “km-umguide.doc” I identified PnP
notifications method.
One difference from inverted call model which attracted my attention was,
there wasn’t
any need to keep an inventory on clients those would register with my event
provider.
Instead respective event guids is needed to be published. Hence, I wanted
to try the method
and check if it really applies to my case.

On Thu, Apr 20, 2017 at 9:07 PM, Tim Roberts wrote:

> xxxxx@gmail.com wrote:
> > Reference:
> > https://msdn.microsoft.com/en-us/library/windows/hardware/
> dn613933(v=vs.85).aspx
> >
> > Question:
> > How can I register a software driver with device type FILE_DEVICE_UNKNOWN
> > with PNP and then send notifications to usermode application?
>
> Is your driver already PnP compliant? If you call IoCreateDevice (or
> WdfDeviceCreate) during your DriverEntry, then you are not PnP, and you
> can’t use the notification scheme. If you call
> IoCreateDevice/WdfDeviceCreate during an AddDevice call, then you are
> PnP, and this is fully available to you.
>
>
> > Note: I have already implemented Inverted Call Model.
> >
> > I want to explore this communication mode using software driver.
>
> What led you to this? I suspect you will find that the
> RegisterDeviceNotification path is not any simpler than the
> well-understood inverted call model.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

There is a downside: notifications may not be delivered if there are memory allocation failures at the time of reporting the notifications. With the inverted call model, all resources are allocated up front.

Bent from my phone


From: xxxxx@lists.osr.com on behalf of rohan kumbhar
Sent: Sunday, April 23, 2017 9:12:44 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Register software driver(FILE_DEVICE_UNKNOWN) with PNP

>> What led you to this?
I have implemented inverted call model for the purpose of constructing an event provider.
On reading Microsoft published “km-umguide.doc” I identified PnP notifications method.
One difference from inverted call model which attracted my attention was, there wasn’t
any need to keep an inventory on clients those would register with my event provider.
Instead respective event guids is needed to be published. Hence, I wanted to try the method
and check if it really applies to my case.

On Thu, Apr 20, 2017 at 9:07 PM, Tim Roberts > wrote:
xxxxx@gmail.commailto:xxxxx wrote:
> Reference:
> https://msdn.microsoft.com/en-us/library/windows/hardware/dn613933(v=vs.85).aspxhttps:
>
> Question:
> How can I register a software driver with device type FILE_DEVICE_UNKNOWN
> with PNP and then send notifications to usermode application?

Is your driver already PnP compliant? If you call IoCreateDevice (or
WdfDeviceCreate) during your DriverEntry, then you are not PnP, and you
can’t use the notification scheme. If you call
IoCreateDevice/WdfDeviceCreate during an AddDevice call, then you are
PnP, and this is fully available to you.

> Note: I have already implemented Inverted Call Model.
>
> I want to explore this communication mode using software driver.

What led you to this? I suspect you will find that the
RegisterDeviceNotification path is not any simpler than the
well-understood inverted call model.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list online at: http:>

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:>

To unsubscribe, visit the List Server section of OSR Online at http:>

— NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at To unsubscribe, visit the List Server section of OSR Online at</http:></http:></http:></mailto:xxxxx></https:></mailto:xxxxx>