i want to set a user event from kernel mode driver. how do i do it?
try this…
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q262947
amitr0
On 12/5/06, A P wrote:
>
> i want to set a user event from kernel mode driver. how do i do it? —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List
> Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
–
- amitr0
First pass in the handle to the event from user application via such way
as “DeviceIoCtrl”, the driver will then convert the handle to the
pointer and use that to set event when the needs arises.
Best regards,
Cody
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of A P
Sent: Tuesday, December 05, 2006 3:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] events
i want to set a user event from kernel mode driver. how do i do it? —
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
If ur event is named and ur driver is not boot/system start driver, u can open the event handle(and get the pointer) by its name in “\BaseNamedObjects” directory.
I would not recommend this. First, naming depends on Windows version (can
be changed in Vista). Second, it depends on whether Remote Desktop is in use.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From:
To: “Windows System Software Devs Interest List”
Sent: Tuesday, December 05, 2006 1:18 PM
Subject: RE:[ntdev] events
> If ur event is named and ur driver is not boot/system start driver, u can
open the event handle(and get the pointer) by its name in “\BaseNamedObjects”
directory.
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
The real question is why do you want to do this. Unless you want to signal
something happened with no data, no input from the user program in
response, and you are not worried if you miss a signal then an event is a
poor design. In most cases when someone asks this question, they want to
indicate that some data is available, but then you have to get the data!
As soon as you are getting, data or responding to the signal, then you are
better off with the inverted call model and not using an event.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
“A P” wrote in message news:xxxxx@ntdev…
>i want to set a user event from kernel mode driver. how do i do it?
>
Hi Don
Would it be helpful for some driver to use event to notify the
application when the data is ready at the hardware? The application can
then use DeviceIoCtrl to get the data instead of doing polling all the
time. Is there a better (and maybe more graceful) solution to this
scenario? Thanks!
Best regards,
Cody
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Tuesday, December 05, 2006 9:23 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] events
The real question is why do you want to do this. Unless you want to
signal
something happened with no data, no input from the user program in
response, and you are not worried if you miss a signal then an event is
a
poor design. In most cases when someone asks this question, they want
to
indicate that some data is available, but then you have to get the data!
As soon as you are getting, data or responding to the signal, then you
are
better off with the inverted call model and not using an event.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
“A P” wrote in message news:xxxxx@ntdev…
>i want to set a user event from kernel mode driver. how do i do it?
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Using the event in this case is a waste. It is simpler to have an
OVERLAPPED DeviceIoControl call with the buffer for the data. Then the
driver does not have to worry about events, and the code is simpler.
I am not ruling out that there may be a good use for events signaled from
the kernel, I just have not ever seen any since every case I have seen
involves either getting or setting state, at which point the I/O call can
be the event also.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
“Wu, Cody” wrote in message news:xxxxx@ntdev…
Hi Don
Would it be helpful for some driver to use event to notify the
application when the data is ready at the hardware? The application can
then use DeviceIoCtrl to get the data instead of doing polling all the
time. Is there a better (and maybe more graceful) solution to this
scenario? Thanks!
Best regards,
Cody
I found this OSR article to be rather helpful when dealing with user-mode to kernel-mode events. It discusses some of the issues in this thread:
http://www.osronline.com/article.cfm?id=108
Bill
Complete an IRP.
–
The personal opinion of
Gary G. Little
“A P” wrote in message news:xxxxx@ntdev…
i want to set a user event from kernel mode driver. how do i do it?
I have a driver and app that work together. The driver always returns
pending to the IoCtl used for communications, though the app may not use
overlapped except when needed. The return of pending to the app tells it
that the driver has not rejected the IoCtl for some reason. The app then
waits on an event until the driver signals it. The app then does some
activity that must be user mode based while the driver looks for the
activity to occur. This may continue for several different actions.
Timeouts must be used on waits to handle the cases where the activity is not
detected whether from programming error in the test or in another
driver/app. Here is one case where no data other than the signal is needed
and it works fine.
“Don Burn” wrote in message news:xxxxx@ntdev…
> Using the event in this case is a waste. It is simpler to have an
> OVERLAPPED DeviceIoControl call with the buffer for the data. Then the
> driver does not have to worry about events, and the code is simpler.
>
> I am not ruling out that there may be a good use for events signaled from
> the kernel, I just have not ever seen any since every case I have seen
> involves either getting or setting state, at which point the I/O call can
> be the event also.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> http://www.windrvr.com
> Remove StopSpam from the email to reply
>
>
> “Wu, Cody” wrote in message news:xxxxx@ntdev…
> Hi Don
>
> Would it be helpful for some driver to use event to notify the
> application when the data is ready at the hardware? The application can
> then use DeviceIoCtrl to get the data instead of doing polling all the
> time. Is there a better (and maybe more graceful) solution to this
> scenario? Thanks!
>
> Best regards,
> Cody
>
>
>
David J. Craig wrote:
I have a driver and app that work together. The driver always returns
pending to the IoCtl used for communications, though the app may not use
overlapped except when needed. The return of pending to the app tells it
that the driver has not rejected the IoCtl for some reason. The app then
waits on an event until the driver signals it. The app then does some
activity that must be user mode based while the driver looks for the
activity to occur.
The extra event here is completely extraneous. If you aren’t using
overlapped I/O, then DeviceIoControl won’t return until the IRP is
completed, so you don’t need the event. If you ARE using overlapped
I/O, then you already have an event in your OVERLAPPED structure that
will be signaled when the IRP is completed.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Yes you pend an IOCTL instead of polling. You use asynchronous IO and
have the driver complete the request, with the data, when the data is
available. You can of course pend more than one IO request, so your
application and driver can create a queue of pended IO requests to
efficiently deliver the data from the hardware to the application
without any need for polling at all. This was what Don Burn was
referring to when he mentioned the ‘inverted call model’. Your
application waits on io completion events rather than this event you
think you need to signal that the application should send an io request.
When the application wakes up it has the data in the completed request.
It feeds the driver another async request and processes the data.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Wu, Cody
Sent: Tuesday, December 05, 2006 9:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] events
Hi Don
Would it be helpful for some driver to use event to notify the
application when the data is ready at the hardware? The application can
then use DeviceIoCtrl to get the data instead of doing polling all the
time. Is there a better (and maybe more graceful) solution to this
scenario? Thanks!
Best regards,
Cody
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Tuesday, December 05, 2006 9:23 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] events
The real question is why do you want to do this. Unless you want to
signal
something happened with no data, no input from the user program in
response, and you are not worried if you miss a signal then an event is
a
poor design. In most cases when someone asks this question, they want
to
indicate that some data is available, but then you have to get the data!
As soon as you are getting, data or responding to the signal, then you
are
better off with the inverted call model and not using an event.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
“A P” wrote in message news:xxxxx@ntdev…
>i want to set a user event from kernel mode driver. how do i do it?
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
If the IRP was completed as a signal how does the driver then communicate
the results of that looking for user activity back to the user program? I
didn’t go into complete detail, but there might be several activities being
looked for in order with the driver notifying the app that it is time for a
particular activity to occur. The driver returns pending to all requests,
but the user app only has pending activated on those sequences that require
it. The driver is not ready for that activity to occur until preparation
has been done so the return of pending to the app is not the appropriate
trigger. The app and driver have many different options so some of it has
to be generic so that all types can work. Many of the sequences are done
only in the driver with the app involved only to send the IoCtl and display
results from the IoCtl’s output buffer.
“Tim Roberts” wrote in message news:xxxxx@ntdev…
> David J. Craig wrote:
>> I have a driver and app that work together. The driver always returns
>> pending to the IoCtl used for communications, though the app may not use
>> overlapped except when needed. The return of pending to the app tells it
>> that the driver has not rejected the IoCtl for some reason. The app then
>> waits on an event until the driver signals it. The app then does some
>> activity that must be user mode based while the driver looks for the
>> activity to occur.
>
> The extra event here is completely extraneous. If you aren’t using
> overlapped I/O, then DeviceIoControl won’t return until the IRP is
> completed, so you don’t need the event. If you ARE using overlapped
> I/O, then you already have an event in your OVERLAPPED structure that
> will be signaled when the IRP is completed.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>