60 lines
2.4 KiB
C#
60 lines
2.4 KiB
C#
/*
|
|
* ThreadPilot - Advanced Windows Process and Power Plan Manager
|
|
* Copyright (C) 2025 Prime Build
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, version 3 only.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
namespace ThreadPilot.Services
|
|
{
|
|
using System.Threading.Tasks;
|
|
|
|
/// <summary>
|
|
/// Service for managing application elevation and administrator privileges.
|
|
/// </summary>
|
|
public interface IElevationService
|
|
{
|
|
/// <summary>
|
|
/// Checks if the current process is running with administrator privileges.
|
|
/// </summary>
|
|
/// <returns>True if running as administrator, false otherwise.</returns>
|
|
bool IsRunningAsAdministrator();
|
|
|
|
/// <summary>
|
|
/// Requests elevation if the current process is not running as administrator.
|
|
/// </summary>
|
|
/// <returns>True if already elevated or elevation was successful, false if elevation failed or was cancelled.</returns>
|
|
Task<bool> RequestElevationIfNeeded();
|
|
|
|
/// <summary>
|
|
/// Restarts the application with administrator privileges.
|
|
/// </summary>
|
|
/// <param name="arguments">Command line arguments to pass to the elevated process.</param>
|
|
/// <returns>True if restart was initiated successfully, false otherwise.</returns>
|
|
Task<bool> RestartWithElevation(string[]? arguments = null);
|
|
|
|
/// <summary>
|
|
/// Validates that the current process has the necessary privileges for the specified operation.
|
|
/// </summary>
|
|
/// <param name="operation">The operation that requires validation.</param>
|
|
/// <returns>True if the operation can be performed, false otherwise.</returns>
|
|
bool ValidateElevationForOperation(string operation);
|
|
|
|
/// <summary>
|
|
/// Gets the current elevation status as a user-friendly string.
|
|
/// </summary>
|
|
/// <returns>Elevation status description.</returns>
|
|
string GetElevationStatus();
|
|
}
|
|
}
|
|
|