Correctly document 'ConsentUIElevationReason' based on ELEVATION_REASON enum from Windows headers. Update tests to match

This commit is contained in:
James Spencer
2024-09-01 18:52:42 +10:00
parent e4ddea5267
commit 97fb10713f
8 changed files with 90 additions and 43 deletions
@@ -36,7 +36,8 @@ namespace Lithnet.CredentialProvider
public ConsentUIType Type => this.header.Type;
/// <summary>
/// Gets a value indicating the consent prompt type
/// Gets a value indicating how UAC has been told to fetch approval.
/// In the case where a Credential Provider is initialised, this should always be `Credentials`.
/// </summary>
public ConsentUIPromptType PromptType => this.header.PromptType;
@@ -46,13 +47,13 @@ namespace Lithnet.CredentialProvider
public IntPtr HWnd => this.header.hWindow;
/// <summary>
/// Gets the method that ConsentUI has been told to fetch approval.
/// In the case where a Credential Provider is initialised, this should always be `Credentials`.
/// Gets the reason why `consent.exe` was started in the first place. In other words,
/// the type of action that led to an elevation request.
/// </summary>
public ConsentUIElevationType ElevationType => this.header.ElevationType;
public ConsentUIElevationReason ElevationReason => this.header.ElevationReason;
/// <summary>
/// A series of flags that AppInfo passes to ConsentUI to signifiy actions that need to
/// A series of flags that AppInfo passes to ConsentUI to signify actions that need to
/// take place on the UI side.
/// This includes specifics around the UI that should be presented & signature verification settings.
/// </summary>
@@ -0,0 +1,70 @@
namespace Lithnet.CredentialProvider
{
public enum ConsentUIElevationReason
{
/// <summary>
/// Application Compatibility
/// e.g. "Run this program as an Administrator" explicitly configured
///
/// > "The AppCompat database stores information in the application
/// > compatibility fix entries for an application."
/// </summary>
AppCompatExplicit = 0,
/// <summary>
/// Application Compatibility
/// e.g. "Run this program as an Administrator" set via Windows heuristics
///
/// > "The AppCompat database stores information in the application
/// > compatibility fix entries for an application."
/// </summary>
AppCompatHeuristic = 1,
/// <summary>
/// Application manifest
/// > "The Fusion database stores information from application
/// > manifests that describe the applications. The manifest schema
/// > is updated to add a new requested execution level field."
///
/// See also: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#trustinfo
/// </summary>
Fusion = 2,
/// <summary>
/// Automatically detected Windows Installer package (e.g. an EXE installer)
/// > "Installer detection detects setup files, which helps prevent installations
/// > from being run without the user's knowledge and consent."
/// </summary>
Installer = 3,
/// <summary>
/// COM elevation action
/// </summary>
CLSID = 4,
/// <summary>
/// Windows Installer package installation (MSI)
/// </summary>
Msi = 5,
/// <summary>
/// "Run as Administrator..." (e.g. manual UAC)
/// </summary>
Request = 6,
/// <summary>
/// ActiveX Installer Service (AXIS)
/// </summary>
AxIS = 7,
/// <summary>
/// Packaged Applications (MSIX / APPX)
/// </summary>
PackagedApp = 8,
/// <summary>
/// Unknown
/// </summary>
NumReasons = 9,
}
}
@@ -1,24 +0,0 @@
namespace Lithnet.CredentialProvider
{
public enum ConsentUIElevationType
{
Unknown = 0,
/// <summary>
/// Automatic Admin Mode.
/// This seems to be an instance where UAC creates a local, secondary
/// account called '%username%_admin' which is used to elevate a process.
/// </summary>
AutomaticAdmin = 1,
/// <summary>
/// Prompt the user for consent (i.e. Yes or No)
/// </summary>
Consent = 2,
/// <summary>
/// Prompt the user for credentials
/// </summary>
Credentials = 3
}
}
@@ -62,7 +62,7 @@ namespace Lithnet.CredentialProvider
BlockElevation = 0x1000,
/// <summary>
/// Corresponds to `ConsentUIElevationType.AutomaticAdmin`
/// Corresponds to `ConsentUIPromptType.AutomaticAdmin`
/// This seems to be an instance where UAC creates a local, secondary
/// account called '%username%_admin' which is used to elevate a process.
/// </summary>
@@ -18,7 +18,7 @@ namespace Lithnet.CredentialProvider.Interop
// 32
public ConsentUIElevationType ElevationType; // 4
public ConsentUIElevationReason ElevationReason; // 4
public int sessionId; // 4
public IntPtr hMutex; // 8