Hi all!

How can I send a windows message to an application from a WDM driver?

Several years ago I wrote a VxD driver for an ISA device used in our
equipment. Through an IOCTL message, our application would pass its handle
and the VxD would store it. When the VxD had something ready for us it
would use the handle to send the app a windows message at which time we
might have to do some sort of IOCTL to the driver or more commonly read a
message in dualported memory. Good or bad programming practice it worked
quite well. We are migrating to XPe and I'm trying to translate this
possibly dubious practice from VxD to WDM. I have all the tools. XP DDK,
Walter Oneys book and Compuware Driverworks. I used VtoolsD for the last
driver.

Thanks in advance,

Dave

dskok@LOVELYSPAMlehighdim.com take out LOVELY and SPAM

Re: Sending a WM_ message from WDM to app by David

David
Wed Dec 10 15:28:54 CST 2003

Guess what? XP is an operating system and not just a hack on MS-DOS.
Search the web, Microsoft, OSR, codeproject, etc. and look for ways for
drivers and applications to interact. A user created event is my preferred
solution and it works on 9x as well with only a small code variation that
can be done at runtime.

"Dave Skok" <dskok@IDONTLIKESPAMlehighdim.com> wrote in message
news:vtf1und8f2gp20@corp.supernews.com...
> Hi all!
>
> How can I send a windows message to an application from a WDM driver?
>
> Several years ago I wrote a VxD driver for an ISA device used in our
> equipment. Through an IOCTL message, our application would pass its
handle
> and the VxD would store it. When the VxD had something ready for us it
> would use the handle to send the app a windows message at which time we
> might have to do some sort of IOCTL to the driver or more commonly read a
> message in dualported memory. Good or bad programming practice it worked
> quite well. We are migrating to XPe and I'm trying to translate this
> possibly dubious practice from VxD to WDM. I have all the tools. XP DDK,
> Walter Oneys book and Compuware Driverworks. I used VtoolsD for the last
> driver.
>
> Thanks in advance,
>
> Dave
>
> dskok@LOVELYSPAMlehighdim.com take out LOVELY and SPAM
>
>



Re: Sending a WM_ message from WDM to app by Ray

Ray
Wed Dec 10 15:51:59 CST 2003

There are numerous ways for a WDM driver to communicate with an app, but
I can think of 2 in particular that map reasonably well to your existing
model:

1) Asynchronous (overlapped) I/O. Issue a read/write/ioctl request in
overlapped mode, with another thread waiting on the event. The driver
pends the request when it's received and then completes it when ready.
This is a more "canonical" way of doing things, but may or may not fit
your existing model quite as well. This is a bit more complicated than
the next suggestion, because you have to deal with pended/canceled
requests correctly, but the advantage is that the driver can return
information about each request directly.

2) Roll your own event-based triggering. This is somewhat easier to use
in the case where the driver just wants to send a stream of
notifications about something. A separate thread creates an event and
passes it down to the driver in an IOCtl, which does an
ObReferenceObjectByHandle on it. The thread then waits on this event in
a loop. The driver triggers it when it's ready. The thread can do
whatever it wants when the event triggers, including sending a windows
message to some window. However, you only get 1 bit of information using
this mechanism, i.e. the driver wants attention. Further IOCTLs could be
used to queue notifications, etc., if needed, though option 1 might be
easier in that case, depending on what you need.

Speaking of canonical, BTW, the suggested way to connect to the driver
is via a device interface, registered with IoRegisterDeviceInterface,
rather than just creating a plain symbolic link that apps open (which
also works, but you might as well do it right if you're starting
afresh). See the docs for details.

Dave Skok wrote:

> Hi all!
>
> How can I send a windows message to an application from a WDM driver?
>
> Several years ago I wrote a VxD driver for an ISA device used in our
> equipment. Through an IOCTL message, our application would pass its handle
> and the VxD would store it. When the VxD had something ready for us it
> would use the handle to send the app a windows message at which time we
> might have to do some sort of IOCTL to the driver or more commonly read a
> message in dualported memory. Good or bad programming practice it worked
> quite well. We are migrating to XPe and I'm trying to translate this
> possibly dubious practice from VxD to WDM. I have all the tools. XP DDK,
> Walter Oneys book and Compuware Driverworks. I used VtoolsD for the last
> driver.
>
> Thanks in advance,
>
> Dave
>
> dskok@LOVELYSPAMlehighdim.com take out LOVELY and SPAM
>
>

--
../ray\..

Re: Sending a WM_ message from WDM to app by Maxim

Maxim
Sat Dec 13 03:48:51 CST 2003

WMI is also the way, and the _good_ way BTW.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Ray Trent" <rat@synaptics.com.spamblock> wrote in message
news:u9XxXf2vDHA.1764@TK2MSFTNGP10.phx.gbl...
> There are numerous ways for a WDM driver to communicate with an app, but
> I can think of 2 in particular that map reasonably well to your existing
> model:
>
> 1) Asynchronous (overlapped) I/O. Issue a read/write/ioctl request in
> overlapped mode, with another thread waiting on the event. The driver
> pends the request when it's received and then completes it when ready.
> This is a more "canonical" way of doing things, but may or may not fit
> your existing model quite as well. This is a bit more complicated than
> the next suggestion, because you have to deal with pended/canceled
> requests correctly, but the advantage is that the driver can return
> information about each request directly.
>
> 2) Roll your own event-based triggering. This is somewhat easier to use
> in the case where the driver just wants to send a stream of
> notifications about something. A separate thread creates an event and
> passes it down to the driver in an IOCtl, which does an
> ObReferenceObjectByHandle on it. The thread then waits on this event in
> a loop. The driver triggers it when it's ready. The thread can do
> whatever it wants when the event triggers, including sending a windows
> message to some window. However, you only get 1 bit of information using
> this mechanism, i.e. the driver wants attention. Further IOCTLs could be
> used to queue notifications, etc., if needed, though option 1 might be
> easier in that case, depending on what you need.
>
> Speaking of canonical, BTW, the suggested way to connect to the driver
> is via a device interface, registered with IoRegisterDeviceInterface,
> rather than just creating a plain symbolic link that apps open (which
> also works, but you might as well do it right if you're starting
> afresh). See the docs for details.
>
> Dave Skok wrote:
>
> > Hi all!
> >
> > How can I send a windows message to an application from a WDM driver?
> >
> > Several years ago I wrote a VxD driver for an ISA device used in our
> > equipment. Through an IOCTL message, our application would pass its handle
> > and the VxD would store it. When the VxD had something ready for us it
> > would use the handle to send the app a windows message at which time we
> > might have to do some sort of IOCTL to the driver or more commonly read a
> > message in dualported memory. Good or bad programming practice it worked
> > quite well. We are migrating to XPe and I'm trying to translate this
> > possibly dubious practice from VxD to WDM. I have all the tools. XP DDK,
> > Walter Oneys book and Compuware Driverworks. I used VtoolsD for the last
> > driver.
> >
> > Thanks in advance,
> >
> > Dave
> >
> > dskok@LOVELYSPAMlehighdim.com take out LOVELY and SPAM
> >
> >
>
> --
> ../ray\..



Re: Sending a WM_ message from WDM to app by Mark

Mark
Sat Dec 13 08:17:47 CST 2003

On Sat, 13 Dec 2003 12:48:51 +0300, "Maxim S. Shatskih"
<maxim@storagecraft.com> wrote:

> WMI is also the way, and the _good_ way BTW.

Ugh. I suppose it is the good way, but the programming mechanisms are
massively complicated compared to a simple private ioctl interface. Oh
and the docs are all oriented towards VB programmers, which in general
is a disjoint subset from kernel programmers.



=====================
Mark Roddy
Windows XP/2000/NT Consulting, Microsoft DDK MVP
Hollis Technology Solutions 603-321-1032
www.hollistech.com
markr@hollistech.com
For Windows Device Driver Training: see www.azius.com

Re: Sending a WM_ message from WDM to app by James

James
Sun Dec 14 22:42:10 CST 2003

Then you'll be interested in my sample WDM driver (see
http://home.mindspring.com/~antognini/), which I updated just today. The updates
include 2 user-space programs to get and set driver data via WMI. One of them
shows how to do those things across systems. Something else is how to use the
WMI data inside PerfMon. (The forthcoming WD-3 article by Thomas Divine and me
on extending PassThru will also show the use of WMI in an NDIS IM driver, with
similar user-space applications.)

Further, although most of the updates are in the user-space code, in the kernel
code I corrected an unpleasant bug flushed out by driver verifier.

Mark Roddy wrote:

> Ugh. I suppose it is the good way, but the programming mechanisms are
> massively complicated compared to a simple private ioctl interface. Oh
> and the docs are all oriented towards VB programmers, which in general
> is a disjoint subset from kernel programmers.

--
If replying by e-mail, please remove "nospam." from the address.

James Antognini
Windows DDK MVP