Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroups > Vista General

Vista - User mode to Kernel mode

Reply
 
Old 10-09-2007   #1 (permalink)
novice


 
 

User mode to Kernel mode

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.

My System SpecsSystem Spec
Old 10-09-2007   #2 (permalink)
Andrew McLaren


 
 

Re: User mode to Kernel mode

"novice" <novice@xxxxxx> wrote...
Quote:

> 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


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Kernel-mode driver error message Vista General
Kernel Mode Print Drivers - Unable to install Vista print fax & scan
Unable to install kernel-mode print driver Vista General
Unsigned Kernel Mode print drivers. Vista hardware & devices
kernel-mode drivers Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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