public void CreateProcessWithTokenWTest() { using (var pTok = SafeHTOKEN.FromProcess(GetCurrentProcess())) using (var hTok = pTok.DuplicateImpersonate()) { var b = CreateProcessWithTokenW(hTok, 0, "notepad.exe", null, 0, default, default, STARTUPINFO.Default, out var pi);
/// <summary>Enables a specified system privilege on a process.</summary> /// <param name="process">The process on which to enable the privilege.</param> /// <param name="privilege">The privilege to enable.</param> public static void EnablePrivilege(this Process process, SystemPrivilege privilege) { using var hObj = SafeHTOKEN.FromProcess(process, TokenAccess.TOKEN_ADJUST_PRIVILEGES | TokenAccess.TOKEN_QUERY); hObj.AdjustPrivilege(privilege, PrivilegeAttributes.SE_PRIVILEGE_ENABLED); }