Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > User mode to Kernel mode

Reply
Thread Tools Display Modes

User mode to Kernel mode

 
 
novice
Guest
Posts: n/a

 
      10-09-2007
Can a handle to an event created using CreateEvent() in user mode be passed
to Kernel mode and if so, is there anything special that we need to do
anything driver to use that handle in kernel mode?

Thank you for your reply.
 
Reply With Quote
 
 
 
 
Andrew McLaren
Guest
Posts: n/a

 
      10-09-2007
"novice" <> wrote...
> Can a handle to an event created using CreateEvent() in user mode be
> passed
> to Kernel mode and if so, is there anything special that we need to do
> anything driver to use that handle in kernel mode?


You'll get better results asking in a group like
"microsoft.public.development.device.drivers". This group
"microsoft.public.windows.vista.general" is oriented towards end-users.

You can pass a user-mode handle to kernel mode, by using an IOCTL. But, a
handle is a pointer into a handle table, which is per-process. So you need
to make sure that the context in which the handle is referenced is always
consistent. If your driver is in the middle of a stack of other drivers
(such as a filter driver; or any non-monolithic driver, really), you can't
really be sure of the context in which it will be running. Also if you call
IoRegisterDeviceInterface() (which you should) then IRPs will go on top of
the stack holding your device object, not direct to your driver. So, by the
time the IOCTL arrives, you might be in any arbitrary context. Basically,
using Event handles is possible; but it is a very fragile and easily broken
mechanism.

A much more robust mechanism will be to create a named event in user mode;
and then share the *name* of the event, rather than the handle. In your user
mode process, just call CreateEvent(NULL, TRUE, FALSE, "MyEvent"). Your
driver can then reference the event by name, by passing the event name
"MyEvent" as a parameter to KeSetEvent(). This will avoid the many possible
pitfalls (and blue-screens) of trying to use a user-mode handle in kernel
mode.

Hope it helps,
--
Andrew McLaren
amclar (at) optusnet dot com dot au


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel Mode Print Drivers - Unable to install jereviscious Windows Vista Printing / Faxing / Scanning 4 01-20-2009 07:39 PM
Unable to install kernel-mode print driver BkStCrawler Windows Vista General Discussion 2 07-30-2007 06:39 PM
Unsigned Kernel Mode print drivers. jereviscious Windows Vista Hardware 5 07-23-2007 01:15 PM
"can't Open kernel mode driver service" error please help! Adam4x4x Windows Vista Hardware 3 04-19-2007 11:42 AM
Re: kernel-mode drivers Chad Harris Windows Vista General Discussion 1 01-31-2007 06:09 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59