Exemplo n.º 1
0
 private void Revert()
 {
     if (disposed || prev == null)
     {
         return;
     }
     lock (prev)
     {
         RuntimeHelpers.PrepareConstrainedRegions();
         hObj.AdjustPrivileges(prev);
     }
     disposed = true;
 }
Exemplo n.º 2
0
 private void Revert()
 {
     if (disposed)
     {
         return;
     }
     lock (hObj)
     {
         RuntimeHelpers.PrepareConstrainedRegions();
         hObj.AdjustPrivileges(prev);
     }
     hObj.Dispose();
     disposed = true;
 }
Exemplo n.º 3
0
 public PrivilegedCodeBlock(Process process, params SystemPrivilege[] systemPrivileges)
 {
     if (systemPrivileges == null || systemPrivileges.Length == 0)
     {
         return;
     }
     RuntimeHelpers.PrepareConstrainedRegions();
     hObj = SafeHTOKEN.FromProcess(process, TokenAccess.TOKEN_ADJUST_PRIVILEGES | TokenAccess.TOKEN_QUERY);
     if (systemPrivileges.Length == 1)
     {
         prev = hObj.AdjustPrivilege(systemPrivileges[0], PrivilegeAttributes.SE_PRIVILEGE_ENABLED);
     }
     else
     {
         prev = hObj.AdjustPrivileges(systemPrivileges.Select(p => new PrivilegeAndAttributes(p, PrivilegeAttributes.SE_PRIVILEGE_ENABLED)).ToArray());
     }
 }