コード例 #1
0
 public static bool ChangeProcessPrivilege(Process process, string privilege, bool enable)
 {
     SafeTokenHandle handle;
     if (!OpenProcessToken(process.Handle, TOKEN.TOKEN_ADJUST_PRIVILEGES | TOKEN.TOKEN_QUERY, out handle))
     {
         return false;
     }
     try
     {
         LUID lpLuid = new LUID();
         if (!LookupPrivilegeValue(null, privilege, out lpLuid))
         {
             return false;
         }
         TOKEN_PRIVILEGES newState = new TOKEN_PRIVILEGES {
             PrivilegeCount = 1,
             Privileges = new LUID_AND_ATTRIBUTES[1]
         };
         newState.Privileges[0].Luid = lpLuid;
         newState.Privileges[0].Attributes = enable ? 2 : 0;
         if (!AdjustTokenPrivileges(handle, false, ref newState, (uint) Marshal.SizeOf(newState), IntPtr.Zero, IntPtr.Zero))
         {
             return false;
         }
     }
     finally
     {
         handle.Close();
     }
     return true;
 }
コード例 #2
0
ファイル: Luid.cs プロジェクト: nuxleus/flexwikicore
 public Luid(LUID luid)
 {
     _luid = luid;
 }
コード例 #3
0
		public static extern BOOL LookupPrivilegeValue(string lpSystemName, string lpName, out LUID Luid);
コード例 #4
0
 public static extern bool LookupPrivilegeValue([MarshalAs(UnmanagedType.LPTStr)] string lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid);