static void adjustToken()
 {
     IntPtr processhandle = Kernel32.GetCurrentProcess();
     IntPtr tokenHandle;
     ADVAPI32.OpenProcessToken(processhandle, (TOKEN.ADJUST_PRIVILEGES | TOKEN.QUERY), out tokenHandle);
     var newState = new TOKEN_PRIVILEGES();
     newState.Privileges.Attributes = SE.PRIVILEGE_ENABLED;
     newState.PrivilegeCount = 1;
     ADVAPI32.LookupPrivilegeValue(null, SE.SHUTDOWN_NAME, out newState.Privileges.Luid);
     ADVAPI32.AdjustTokenPrivileges(tokenHandle, false, ref newState, 0, IntPtr.Zero, IntPtr.Zero);
     Kernel32.CloseHandle(tokenHandle);
 }
示例#2
0
 public static extern bool AdjustTokenPrivileges(IntPtr TokenHandle, bool DisableAllPrivileges, ref TOKEN_PRIVILEGES NewState, int BufferLength, IntPtr PreviousState, IntPtr ReturnLength);