IoReportTargetDeviceChangeAsynchronous custom notification best practices - PnP driver only?

I wanted to get custom notifications working from KM to UM over the weekend,
so I had a look at:

http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

Which says:

“A driver can define custom events, which don’t necessarily have to relate
to hardware”

Then I looked at the event sample src in the ddk, comments in that say:

" 4) Using PNP custom notification scheme. Walter Oney’s book describes
this.
Can be used only in PNP drivers."

And Walters book says that he couldn’t get it to work.

So I’ve started shoeing a sample, but I wanted to ask before I go any
further, in terms of best practice and “correctness”, if my driver is a
virtual device driver, and doesn’t really have anything to do with PnP,
should I be using this mechanism at all? (just because I can - does it mean
I should?)

Which then begs the question, if it is ok to use this method - what other
caveats are there? i.e. do I need to support or “manage” any standard PnP
routines/scenarios, or god forbid - any power management “bits”, because if
thats the case, then i’ll stick to some of the more generic methods from
here:

http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx

cheers

Crispin

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3918 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

That would be a resounding ‘no,’ in my opinion, if I understand you correctly. If you’re writing
something more like ‘kernel mode software,’ then I would personally stick with a legacy/nt4 style
driver.

Good luck,

mm

Crispin Wright wrote:

I wanted to get custom notifications working from KM to UM over the weekend,
so I had a look at:

http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

Which says:

“A driver can define custom events, which don’t necessarily have to relate
to hardware”

Then I looked at the event sample src in the ddk, comments in that say:

" 4) Using PNP custom notification scheme. Walter Oney’s book describes
this.
Can be used only in PNP drivers."

And Walters book says that he couldn’t get it to work.

So I’ve started shoeing a sample, but I wanted to ask before I go any
further, in terms of best practice and “correctness”, if my driver is a
virtual device driver, and doesn’t really have anything to do with PnP,
should I be using this mechanism at all? (just because I can - does it mean
I should?)

Which then begs the question, if it is ok to use this method - what other
caveats are there? i.e. do I need to support or “manage” any standard PnP
routines/scenarios, or god forbid - any power management “bits”, because if
thats the case, then i’ll stick to some of the more generic methods from
here:

http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx

cheers

Crispin

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3918 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

You need a physical device object to be able to call IoReportTargetDeviceChangeAsynchronous. This means you must be a pnp driver which means that even though you can be root enumerated, you must still fully implement pnp and power (unless it is a KMDF driver :slight_smile: ). There are 2 caveats around IoReportTargetDeviceChangeAsynchronous.

  1. it is lossy. It requires at leat one allocation within the kernel to deliver the message, and I think each target sink needs an alloc as well
  2. there are no timing guarantees. So while there are no PIRP compoletion timing guarantees, notifications through this API have to travel through more components across more IPC boundaries

With that said, notifications through this api have their uses, esp if you can tolerate the occasional memory alloc failure. For instance, when I was writing the bth stack, we would use these notifications to broadcast when a connection was made or lost, when a remote name was retrieved, etc etc. The in box UI used these notifications to asynchronously update itself based off of these state changes.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Crispin Wright
Sent: Monday, March 09, 2009 12:28 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IoReportTargetDeviceChangeAsynchronous custom notification best practices - PnP driver only?

I wanted to get custom notifications working from KM to UM over the weekend,
so I had a look at:

http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

Which says:

“A driver can define custom events, which don’t necessarily have to relate
to hardware”

Then I looked at the event sample src in the ddk, comments in that say:

" 4) Using PNP custom notification scheme. Walter Oney’s book describes
this.
Can be used only in PNP drivers."

And Walters book says that he couldn’t get it to work.

So I’ve started shoeing a sample, but I wanted to ask before I go any
further, in terms of best practice and “correctness”, if my driver is a
virtual device driver, and doesn’t really have anything to do with PnP,
should I be using this mechanism at all? (just because I can - does it mean
I should?)

Which then begs the question, if it is ok to use this method - what other
caveats are there? i.e. do I need to support or “manage” any standard PnP
routines/scenarios, or god forbid - any power management “bits”, because if
thats the case, then i’ll stick to some of the more generic methods from
here:

http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx

cheers

Crispin

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3918 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Any particular reasons why a “resounding” no Martin? I’d like to know if
there are, to satisfy my own curiosity more than anything.

And yes it is “Kernel mode software” (WDM).

Cheers

Crispin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: 09 March 2009 14:31
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] IoReportTargetDeviceChangeAsynchronous custom
notification best practices - PnP driver only?

That would be a resounding ‘no,’ in my opinion, if I understand you
correctly. If you’re writing
something more like ‘kernel mode software,’ then I would personally stick
with a legacy/nt4 style
driver.

Good luck,

mm

Crispin Wright wrote:

I wanted to get custom notifications working from KM to UM over the
weekend,
so I had a look at:

http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

Which says:

“A driver can define custom events, which don’t necessarily have to relate
to hardware”

Then I looked at the event sample src in the ddk, comments in that say:

" 4) Using PNP custom notification scheme. Walter Oney’s book describes
this.
Can be used only in PNP drivers."

And Walters book says that he couldn’t get it to work.

So I’ve started shoeing a sample, but I wanted to ask before I go any
further, in terms of best practice and “correctness”, if my driver is a
virtual device driver, and doesn’t really have anything to do with PnP,
should I be using this mechanism at all? (just because I can - does it
mean
I should?)

Which then begs the question, if it is ok to use this method - what other
caveats are there? i.e. do I need to support or “manage” any standard PnP
routines/scenarios, or god forbid - any power management “bits”, because
if
thats the case, then i’ll stick to some of the more generic methods from
here:

http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx

cheers

Crispin

__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3918 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3920 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

I think I made it sound like I had more in mind than I did. All I mean is that if all you’re doing
‘device’ wise is sending and handling IOCTL codes, then I personally think that using the nonpnp
KMDF model doesn’t add anything that you’re going to use and just makes it harder to understand
what’s going on, not that’s really hard. Don’t get me wrong - I love KMDF, just not for this.

That being said, your citing ‘WDM’ makes me think that I missed something about what you’re doing.
If you’re using any part of WDM by necessity, then what I said wouldn’t apply, and I would look hard
at using KMDF instead.

Good luck,

mm

Crispin Wright wrote:

Any particular reasons why a “resounding” no Martin? I’d like to know if
there are, to satisfy my own curiosity more than anything.

And yes it is “Kernel mode software” (WDM).

Cheers

Crispin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: 09 March 2009 14:31
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] IoReportTargetDeviceChangeAsynchronous custom
notification best practices - PnP driver only?

That would be a resounding ‘no,’ in my opinion, if I understand you
correctly. If you’re writing
something more like ‘kernel mode software,’ then I would personally stick
with a legacy/nt4 style
driver.

Good luck,

mm

Crispin Wright wrote:
> I wanted to get custom notifications working from KM to UM over the
weekend,
> so I had a look at:
>
> http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx
>
> Which says:
>
> “A driver can define custom events, which don’t necessarily have to relate
> to hardware”
>
> Then I looked at the event sample src in the ddk, comments in that say:
>
> " 4) Using PNP custom notification scheme. Walter Oney’s book describes
> this.
> Can be used only in PNP drivers."
>
> And Walters book says that he couldn’t get it to work.
>
> So I’ve started shoeing a sample, but I wanted to ask before I go any
> further, in terms of best practice and “correctness”, if my driver is a
> virtual device driver, and doesn’t really have anything to do with PnP,
> should I be using this mechanism at all? (just because I can - does it
mean
> I should?)
>
> Which then begs the question, if it is ok to use this method - what other
> caveats are there? i.e. do I need to support or “manage” any standard PnP
> routines/scenarios, or god forbid - any power management “bits”, because
if
> thats the case, then i’ll stick to some of the more generic methods from
> here:
>
> http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx
>
> cheers
>
> Crispin
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
signature
> database 3918 (20090309) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3920 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Thanks Doron - thats covered it.

Cheers,

Crispin

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: 09 March 2009 17:29
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] IoReportTargetDeviceChangeAsynchronous custom
notification best practices - PnP driver only?

You need a physical device object to be able to call
IoReportTargetDeviceChangeAsynchronous. This means you must be a pnp driver
which means that even though you can be root enumerated, you must still
fully implement pnp and power (unless it is a KMDF driver :slight_smile: ). There are 2
caveats around IoReportTargetDeviceChangeAsynchronous.

  1. it is lossy. It requires at leat one allocation within the kernel to
    deliver the message, and I think each target sink needs an alloc as well
  2. there are no timing guarantees. So while there are no PIRP compoletion
    timing guarantees, notifications through this API have to travel through
    more components across more IPC boundaries

With that said, notifications through this api have their uses, esp if you
can tolerate the occasional memory alloc failure. For instance, when I was
writing the bth stack, we would use these notifications to broadcast when a
connection was made or lost, when a remote name was retrieved, etc etc. The
in box UI used these notifications to asynchronously update itself based off
of these state changes.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Crispin Wright
Sent: Monday, March 09, 2009 12:28 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IoReportTargetDeviceChangeAsynchronous custom notification
best practices - PnP driver only?

I wanted to get custom notifications working from KM to UM over the weekend,
so I had a look at:

http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

Which says:

“A driver can define custom events, which don’t necessarily have to relate
to hardware”

Then I looked at the event sample src in the ddk, comments in that say:

" 4) Using PNP custom notification scheme. Walter Oney’s book describes
this.
Can be used only in PNP drivers."

And Walters book says that he couldn’t get it to work.

So I’ve started shoeing a sample, but I wanted to ask before I go any
further, in terms of best practice and “correctness”, if my driver is a
virtual device driver, and doesn’t really have anything to do with PnP,
should I be using this mechanism at all? (just because I can - does it mean
I should?)

Which then begs the question, if it is ok to use this method - what other
caveats are there? i.e. do I need to support or “manage” any standard PnP
routines/scenarios, or god forbid - any power management “bits”, because if
thats the case, then i’ll stick to some of the more generic methods from
here:

http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx

cheers

Crispin

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3918 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

No worries, I was hoping for some tech gem of wisdom that would make me go
WOW! But never mind… :slight_smile:

We’ve got a lot of hours invested in the WDM version already so we’ll
continue down that road, but I’ve read a fair bit about the reasons for
KMDF, and what it provides, and if I thought I could have used it for this
project then I really would have.

Cheers,

Crispin

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: 09 March 2009 18:15
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] IoReportTargetDeviceChangeAsynchronous custom
notification best practices - PnP driver only?

I think I made it sound like I had more in mind than I did. All I mean is
that if all you’re doing
‘device’ wise is sending and handling IOCTL codes, then I personally think
that using the nonpnp
KMDF model doesn’t add anything that you’re going to use and just makes it
harder to understand
what’s going on, not that’s really hard. Don’t get me wrong - I love KMDF,
just not for this.

That being said, your citing ‘WDM’ makes me think that I missed something
about what you’re doing.
If you’re using any part of WDM by necessity, then what I said wouldn’t
apply, and I would look hard
at using KMDF instead.

Good luck,

mm

Crispin Wright wrote:

Any particular reasons why a “resounding” no Martin? I’d like to know if
there are, to satisfy my own curiosity more than anything.

And yes it is “Kernel mode software” (WDM).

Cheers

Crispin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: 09 March 2009 14:31
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] IoReportTargetDeviceChangeAsynchronous custom
notification best practices - PnP driver only?

That would be a resounding ‘no,’ in my opinion, if I understand you
correctly. If you’re writing
something more like ‘kernel mode software,’ then I would personally stick
with a legacy/nt4 style
driver.

Good luck,

mm

Crispin Wright wrote:
> I wanted to get custom notifications working from KM to UM over the
weekend,
> so I had a look at:
>
> http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx
>
> Which says:
>
> “A driver can define custom events, which don’t necessarily have to
relate
> to hardware”
>
> Then I looked at the event sample src in the ddk, comments in that say:
>
> " 4) Using PNP custom notification scheme. Walter Oney’s book
describes
> this.
> Can be used only in PNP drivers."
>
> And Walters book says that he couldn’t get it to work.
>
> So I’ve started shoeing a sample, but I wanted to ask before I go any
> further, in terms of best practice and “correctness”, if my driver is a
> virtual device driver, and doesn’t really have anything to do with PnP,
> should I be using this mechanism at all? (just because I can - does it
mean
> I should?)
>
> Which then begs the question, if it is ok to use this method - what other
> caveats are there? i.e. do I need to support or “manage” any standard
PnP
> routines/scenarios, or god forbid - any power management “bits”, because
if
> thats the case, then i’ll stick to some of the more generic methods from
> here:
>
> http://www.microsoft.com/msj/0799/nerd/nerd0799.aspx
>
> cheers
>
> Crispin
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
signature
> database 3918 (20090309) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3920 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3921 (20090309) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com