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 MSI installer /// public class ConsentUIDataMsi : ConsentUIData { /// /// The action being performed, such as Install, Uninstall or Repair /// public ConsentUIMsiAction Action { get; set; } /// /// The name of the product being installed /// public string ProductName { get; } /// /// The version of the product being installed /// public string Version { get; } /// /// The locale of the product being installed /// public string Locale { get; } /// /// The publisher of the product being installed /// public string Publisher { get; } /// /// The path to the MSI installer /// public string ExecutionPath { get; } /// /// The path to the original MSI file launched by the user /// public string OriginalMsi { get; } internal ConsentUIDataMsi(IntPtr pData, int expectedSize) : base(pData, expectedSize) { if (this.header.Type != ConsentUIType.Msi) { throw new InvalidOperationException("The data structure is not of type MSI"); } var s = Marshal.PtrToStructure(pData + HeaderSize); this.Action = s.MsiAction; this.ProductName = this.GetStringValueIfValid(pData, (int)s.oProductName); this.Version = this.GetStringValueIfValid(pData, (int)s.oVersion); this.Locale = this.GetStringValueIfValid(pData, (int)s.oLocale); this.Publisher = this.GetStringValueIfValid(pData, (int)s.oPublisher); this.ExecutionPath = this.GetStringValueIfValid(pData, (int)s.oExecutionPath); this.OriginalMsi = this.GetStringValueIfValid(pData, (int)s.oOriginalMsi); } } }