![]() TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out hToken) OpenProcessToken(Process.GetCurrentProcess().Handle, using Ĭonst string SE_SHUTDOWN_NAME = "SeShutdownPrivilege" Ĭonst short TOKEN_ADJUST_PRIVILEGES = 32 Use the ExitWindowsEx function from the Win32 API. Ok = AdjustTokenPrivileges( htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero ) Ok = LookupPrivilegeValue( null, SE_SHUTDOWN_NAME, ref tp.Luid ) Ok = OpenProcessToken( hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok ) Internal const int EWX_FORCEIFHUNG = 0x00000010 Internal const int EWX_POWEROFF = 0x00000008 Internal const int EWX_FORCE = 0x00000004 Internal const int EWX_REBOOT = 0x00000002 Internal const int EWX_SHUTDOWN = 0x00000001 Internal const int EWX_LOGOFF = 0x00000000 Internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege" Internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020 Internal const int TOKEN_QUERY = 0x00000008 Internal const int SE_PRIVILEGE_ENABLED = 0x00000002 Internal static extern bool ExitWindowsEx( int flg, int rea ) Ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen ) ![]() Internal static extern bool AdjustTokenPrivileges( IntPtr htok, bool disall, Internal static extern bool LookupPrivilegeValue( string host, string name, Internal static extern bool OpenProcessToken( IntPtr h, int acc, ref IntPtr Internal static extern IntPtr GetCurrentProcess() This thread provides the code necessary: īut here's the relevant code: using ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |