Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > User mode/Kernel Mode context question

Reply
Thread Tools Display Modes

User mode/Kernel Mode context question

 
 
finecats
Guest
Posts: n/a

 
      02-27-2005

There is article in the IFS called "take it to the limit" about switching
contexts. The point of the article is that as long as you are sure you are
in the correct user mode context, you can call a user mode function from
kernel mode.

In the article they show how to use DeviceIoControl() from User mode to call
the kernel mode and to be sure of the context. DeviceIoControl passes in a
pointer to a function, and that function be it a user mode or kernel mode
function can be called from the kernel, ... and it will work!

Following their suggestion, I've done I'm doing just what they suggest and
I'm getting hosed. Specifically this is the function I'm calling.


void TestFunc()

{MessageBox(NULL,L"ThisIsaTest",L"SeemsToWork",MB_ OK);

}


So I get a pointer to this function, and all is well initially. BUT
MessageBox works its way along, making a few calls and ends up executing
"sysenter" instruction. This is where it breaks.

The OSR article was probably written in the era of INT 2E. So is the OSR
article incorrect or obsolete, or perhaps have I missed something?


--
Gak -
Finecats
 
Reply With Quote
 
 
 
 
Don Burn
Guest
Posts: n/a

 
      02-27-2005
It is definitely obsolete, and even when it was written it could break with
recursion into the kernel, as well as the fact that you are blowing all the
security of the system out of the water. I've known and respected the folks
at OSR for 10 years, but I always thought that was a stupid article to
write.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



"finecats" <> wrote in message
news:73B9E906-617C-4ADF-976F-...
>
> There is article in the IFS called "take it to the limit" about switching
> contexts. The point of the article is that as long as you are sure you
> are
> in the correct user mode context, you can call a user mode function from
> kernel mode.
>
> In the article they show how to use DeviceIoControl() from User mode to
> call
> the kernel mode and to be sure of the context. DeviceIoControl passes in
> a
> pointer to a function, and that function be it a user mode or kernel mode
> function can be called from the kernel, ... and it will work!
>
> Following their suggestion, I've done I'm doing just what they suggest and
> I'm getting hosed. Specifically this is the function I'm calling.
>
>
> void TestFunc()
>
> {MessageBox(NULL,L"ThisIsaTest",L"SeemsToWork",MB_ OK);
>
> }
>
>
> So I get a pointer to this function, and all is well initially. BUT
> MessageBox works its way along, making a few calls and ends up executing
> "sysenter" instruction. This is where it breaks.
>
> The OSR article was probably written in the era of INT 2E. So is the OSR
> article incorrect or obsolete, or perhaps have I missed something?
>
>
> --
> Gak -
> Finecats



 
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
WinCE kernel-mode vs. user-mode driver max Windows Vista Drivers 1 12-22-2004 12:04 PM
Calling Win32 API User mode functions from Kernel Mode Manohara.K Windows Vista Drivers 2 08-11-2004 12:54 AM
share memory in kernel mode and user mode Vivek Gupta Windows Vista Drivers 2 07-21-2004 02:24 PM
Share memory between user mode and kernel mode Pascal Windows Vista Drivers 1 02-27-2004 09:07 PM
Re: How detect USER Mode Application is loaded in kernel mode driver William Ingle Windows Vista Drivers 5 07-02-2003 01:14 AM



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