Microsoft 开发人员网络 > 论坛主页 > Visual C# General > how can set a program mode to kernel mode
提出问题提出问题
 

已答复how can set a program mode to kernel mode

  • 2009年11月2日 6:19iman62 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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 ...

答案

  • 2009年11月4日 12:47David M MortonMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    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 WikiLinkedInForumsBrowser

全部回复

  • 2009年11月4日 12:47David M MortonMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    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 WikiLinkedInForumsBrowser
  • 2009年11月4日 13:28Stephen Cleary 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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
  • 2009年11月4日 15:09Wyck 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Write a driver.  Put your kernel-mode code in the driver.  Install your driver.  Call your driver with an IoCtl call.