private static void SetProcessPermissions(IntPtr rawHandle, bool allowTermination) { ProcessAccessRights noAccess = ProcessAccessRights.Terminate | ProcessAccessRights.SuspendResume; SafeHandle handle = new SafeHandleWrapper(rawHandle); ProcessSecurity sec = new ProcessSecurity(handle); ProcessAccessRule noTerminateSuspend = new ProcessAccessRule(Everyone, noAccess, false, InheritanceFlags.None, PropagationFlags.NoPropagateInherit, (AccessControlType)Convert.ToInt32(!allowTermination)); sec.AddAccessRule(noTerminateSuspend); sec.SaveChanges(handle); }
public void AddAccessRule(ProcessAccessRule rule) { base.AddAccessRule(rule); }