Visual C# Developer Center >
Visual C# Forums
>
Visual C# General
>
how can set a program mode to kernel mode
how can set a program mode to kernel mode
- i want write a program that it has some permission.
this program muse run in kernel mode that i can close it
i read in some site that i can do this work by API ... but i don't
known how can i do this ...
Answers
- You can't do this in C#. Portions of your code's interaction with the WinAPI will be run in Kernel Mode (graphics, some portions of networking, etc), but all of those calls are made through the Windows User mode APIs. The entire .NET Framework rests on the User-Mode Windows API, which in turn calls down to the kernel mode functions, but this means that .NET will always start out running in user mode. If you need something to run in Kernel Mode, you'll be better off writing in C or C++ and creating a simple, non-intrusive device driver that will feed data back up to a User-Mode application which will interact with it.
This is not a topic that can be fully discussed within the bounds of a forum thread. I'd suggest picking up a copy of Mark Russinovich's Windows Internals, and start reading. Also, get yourself a good C++ book. You'll need it.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki • LinkedIn • ForumsBrowser- Marked As Answer byChao KuoMSFT, ModeratorFriday, November 06, 2009 6:48 AM
- Proposed As Answer byChao KuoMSFT, ModeratorThursday, November 05, 2009 5:38 AM
All Replies
- You can't do this in C#. Portions of your code's interaction with the WinAPI will be run in Kernel Mode (graphics, some portions of networking, etc), but all of those calls are made through the Windows User mode APIs. The entire .NET Framework rests on the User-Mode Windows API, which in turn calls down to the kernel mode functions, but this means that .NET will always start out running in user mode. If you need something to run in Kernel Mode, you'll be better off writing in C or C++ and creating a simple, non-intrusive device driver that will feed data back up to a User-Mode application which will interact with it.
This is not a topic that can be fully discussed within the bounds of a forum thread. I'd suggest picking up a copy of Mark Russinovich's Windows Internals, and start reading. Also, get yourself a good C++ book. You'll need it.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki • LinkedIn • ForumsBrowser- Marked As Answer byChao KuoMSFT, ModeratorFriday, November 06, 2009 6:48 AM
- Proposed As Answer byChao KuoMSFT, ModeratorThursday, November 05, 2009 5:38 AM
- I just have one addition to David Morton's suggestion: get a good C book. C++ is not supported for kernel code.
(C++ is actually a flamable topic on kernel developer lists. It is possible to use, but you have to know the details of language/stdlib implementation, and not use certain things like exceptions, RTTI, new/delete/malloc/free, and the majority of the standard library).
-Steve
Programming blog: http://nitoprograms.blogspot.com/
Including my TCP/IP .NET Sockets FAQ
Microsoft Certified Professional Developer - Write a driver. Put your kernel-mode code in the driver. Install your driver. Call your driver with an IoCtl call.


