using System; using System.Runtime.InteropServices; using Lithnet.CredentialProvider.Interop; namespace Lithnet.CredentialProvider { /// /// Represents the data structure passed to consent UI when a user is trying to elevate an executable /// public class ConsentUIDataExe : ConsentUIData { private IntPtr hFile; /// /// The path to the process that the user has requested to be launched as an administrator /// public string ExecutablePath { get; } /// /// A currently unknown value. In most cases it seems to be the same as /// public string Unknown1 { get; } /// /// The full command line, including arguments that will be used to launch the executable /// public string CommandLine { get; } /// /// A currently unknown parameter /// public string Unknown2 { get; } /// /// Gets a handle to the executable that the user has requested to be launched as an administrator /// /// A handle to the executable public SafeHandle GetExecutableHandle() { return DuplicateHandleInternal(this.hFile); } internal ConsentUIDataExe(IntPtr pData, int expectedSize) : base(pData, expectedSize) { if (this.header.Type != ConsentUIType.Exe) { throw new InvalidOperationException("The data structure is not of type EXE"); } var s = Marshal.PtrToStructure(pData); this.hFile = s.hFile; this.ExecutablePath = this.GetStringValueIfValid(pData, (int)s.oExecutablePath1); this.Unknown1 = this.GetStringValueIfValid(pData, (int)s.oExecutablePath2); this.CommandLine = this.GetStringValueIfValid(pData, (int)s.oCommandLine); this.Unknown2 = this.GetStringValueIfValid(pData, (int)s.oUnknown0); } } }