From e3bed19e79b537b7861e16931fb4e509c8281097 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 2 Mar 2021 13:09:15 -0800 Subject: [PATCH] Import WixToolset code as external --- BurnOutSharp/BurnOutSharp.csproj | 10 +- .../ColumnCollection.cs | 333 +++++ .../ColumnEnums.cs | 689 ++++++++++ .../ColumnInfo.cs | 297 +++++ .../ComponentInfo.cs | 276 ++++ .../ComponentInstallation.cs | 382 ++++++ .../CustomActionAttribute.cs | 55 + .../CustomActionProxy.cs | 321 +++++ .../Database.cs | 933 +++++++++++++ .../DatabaseQuery.cs | 412 ++++++ .../DatabaseTransform.cs | 278 ++++ .../EmbeddedUIProxy.cs | 231 ++++ .../WixToolset.Dtf.WindowsInstaller/Enums.cs | 909 +++++++++++++ .../Errors.resources | Bin 0 -> 31461 bytes .../Errors.txt | 404 ++++++ .../Exceptions.cs | 576 ++++++++ .../ExternalUIHandler.cs | 223 ++++ .../FeatureInfo.cs | 497 +++++++ .../FeatureInstallation.cs | 174 +++ .../WixToolset.Dtf.WindowsInstaller/Handle.cs | 154 +++ .../IEmbeddedUI.cs | 67 + .../InstallCost.cs | 67 + .../Installation.cs | 100 ++ .../InstallationPart.cs | 82 ++ .../Installer.cs | 890 +++++++++++++ .../InstallerAdvertise.cs | 270 ++++ .../InstallerUtils.cs | 472 +++++++ .../MediaDisk.cs | 58 + .../NativeMethods.cs | 311 +++++ .../PatchInstallation.cs | 413 ++++++ .../ProductInstallation.cs | 801 +++++++++++ .../WixToolset.Dtf.WindowsInstaller/Record.cs | 1048 +++++++++++++++ .../RecordStream.cs | 92 ++ .../RemotableNativeMethods.cs | 1171 +++++++++++++++++ .../Session.cs | 946 +++++++++++++ .../ShortcutTarget.cs | 104 ++ .../SourceList.cs | 525 ++++++++ .../SourceMediaList.cs | 229 ++++ .../SummaryInfo.cs | 612 +++++++++ .../TableCollection.cs | 192 +++ .../TableInfo.cs | 264 ++++ .../Transaction.cs | 201 +++ .../ValidationErrorInfo.cs | 46 + .../WixToolset.Dtf.WindowsInstaller/View.cs | 625 +++++++++ .../WindowsInstaller.cd | 943 +++++++++++++ .../customactiondata.cs | 469 +++++++ BurnOutSharp/FileType/MSI.cs | 8 +- BurnOutSharp/FileType/MicrosoftCAB.cs | 6 - README.md | 4 +- 49 files changed, 18147 insertions(+), 23 deletions(-) create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnCollection.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnEnums.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInstallation.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionAttribute.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Database.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseQuery.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseTransform.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/EmbeddedUIProxy.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Enums.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.resources create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.txt create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Exceptions.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ExternalUIHandler.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInstallation.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Handle.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/IEmbeddedUI.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallCost.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installation.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallationPart.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installer.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerAdvertise.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerUtils.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/MediaDisk.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/NativeMethods.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/PatchInstallation.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ProductInstallation.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Record.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RecordStream.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RemotableNativeMethods.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Session.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceList.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceMediaList.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SummaryInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableCollection.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Transaction.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ValidationErrorInfo.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/View.cs create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/WindowsInstaller.cd create mode 100644 BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/customactiondata.cs diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index ff308869..69283086 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -1,7 +1,7 @@  - net472;net48;netcoreapp3.1;net5.0 + net472;net48;netcoreapp3.1;net5.0-windows x86 BurnOutSharp BurnOutSharp @@ -21,16 +21,11 @@ true - - - NET_FRAMEWORK - - @@ -48,7 +43,6 @@ Always true - - + diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnCollection.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnCollection.cs new file mode 100644 index 00000000..9a452da1 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnCollection.cs @@ -0,0 +1,333 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Collections; + using System.Collections.Generic; + using System.Text; + using System.Diagnostics.CodeAnalysis; + + /// + /// Collection of column information related to a or + /// . + /// + public sealed class ColumnCollection : ICollection + { + private IList columns; + private string formatString; + + /// + /// Creates a new ColumnCollection based on a specified list of columns. + /// + /// columns to be added to the new collection + public ColumnCollection(ICollection columns) + { + if (columns == null) + { + throw new ArgumentNullException("columns"); + } + + this.columns = new List(columns); + } + + /// + /// Creates a new ColumnCollection that is associated with a database table. + /// + /// view that contains the columns + internal ColumnCollection(View view) + { + if (view == null) + { + throw new ArgumentNullException("view"); + } + + this.columns = ColumnCollection.GetViewColumns(view); + } + + /// + /// Gets the number of columns in the collection. + /// + /// number of columns in the collection + public int Count + { + get + { + return this.columns.Count; + } + } + + /// + /// Gets a boolean value indicating whether the collection is read-only. + /// A ColumnCollection is read-only if it is associated with a + /// or a read-only . + /// + /// read-only status of the collection + public bool IsReadOnly + { + get + { + return true; + } + } + + /// + /// Gets information about a specific column in the collection. + /// + /// 1-based index into the column collection + /// is less + /// than 1 or greater than the number of columns in the collection + public ColumnInfo this[int columnIndex] + { + get + { + if (columnIndex >= 0 && columnIndex < this.columns.Count) + { + return this.columns[columnIndex]; + } + else + { + throw new ArgumentOutOfRangeException("columnIndex"); + } + } + } + + /// + /// Gets information about a specific column in the collection. + /// + /// case-sensitive name of a column collection + /// does + /// not exist in the collection + public ColumnInfo this[string columnName] + { + get + { + if (String.IsNullOrEmpty(columnName)) + { + throw new ArgumentNullException("columnName"); + } + + foreach (ColumnInfo colInfo in this.columns) + { + if (colInfo.Name == columnName) + { + return colInfo; + } + } + + throw new ArgumentOutOfRangeException("columnName"); + } + } + + /// + /// Not supported because the collection is read-only. + /// + /// information about the column being added + /// the collection is read-only + public void Add(ColumnInfo item) + { + throw new InvalidOperationException(); + } + + /// + /// Not supported because the collection is read-only. + /// + /// the collection is read-only + public void Clear() + { + throw new InvalidOperationException(); + } + + /// + /// Checks if a column with a given name exists in the collection. + /// + /// case-sensitive name of the column to look for + /// true if the column exists in the collection, false otherwise + public bool Contains(string columnName) + { + return this.IndexOf(columnName) >= 0; + } + + /// + /// Checks if a column with a given name exists in the collection. + /// + /// column to look for, with case-sensitive name + /// true if the column exists in the collection, false otherwise + bool ICollection.Contains(ColumnInfo column) + { + return this.Contains(column.Name); + } + + /// + /// Gets the index of a column within the collection. + /// + /// case-sensitive name of the column to look for + /// 0-based index of the column, or -1 if not found + public int IndexOf(string columnName) + { + if (String.IsNullOrEmpty(columnName)) + { + throw new ArgumentNullException("columnName"); + } + + for (int index = 0; index < this.columns.Count; index++) + { + if (this.columns[index].Name == columnName) + { + return index; + } + } + return -1; + } + + /// + /// Copies the columns from this collection into an array. + /// + /// destination array to be filed + /// offset into the destination array where copying begins + public void CopyTo(ColumnInfo[] array, int arrayIndex) + { + if (array == null) + { + throw new ArgumentNullException("array"); + } + + this.columns.CopyTo(array, arrayIndex); + } + + /// + /// Not supported because the collection is read-only. + /// + /// column to remove + /// true if the column was removed, false if it was not found + /// the collection is read-only + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "column")] + [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] + bool ICollection.Remove(ColumnInfo column) + { + throw new InvalidOperationException(); + } + + /// + /// Gets an enumerator over the columns in the collection. + /// + /// An enumerator of ColumnInfo objects. + public IEnumerator GetEnumerator() + { + return this.columns.GetEnumerator(); + } + + /// + /// Gets a string suitable for printing all the values of a record containing these columns. + /// + public string FormatString + { + get + { + if (this.formatString == null) + { + this.formatString = CreateFormatString(this.columns); + } + return this.formatString; + } + } + + private static string CreateFormatString(IList columns) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < columns.Count; i++) + { + if (columns[i].Type == typeof(Stream)) + { + sb.AppendFormat("{0} = [Binary Data]", columns[i].Name); + } + else + { + sb.AppendFormat("{0} = [{1}]", columns[i].Name, i + 1); + } + + if (i < columns.Count - 1) + { + sb.Append(", "); + } + } + return sb.ToString(); + } + + /// + /// Gets an enumerator over the columns in the collection. + /// + /// An enumerator of ColumnInfo objects. + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + /// + /// Creates ColumnInfo objects for the associated view. + /// + /// dynamically-generated list of columns + private static IList GetViewColumns(View view) + { + IList columnNames = ColumnCollection.GetViewColumns(view, false); + IList columnTypes = ColumnCollection.GetViewColumns(view, true); + + int count = columnNames.Count; + if (columnTypes[count - 1] == "O0") + { + // Weird.. the "_Tables" table returns a second column with type "O0" -- ignore it. + count--; + } + + IList columnsList = new List(count); + for (int i = 0; i < count; i++) + { + columnsList.Add(new ColumnInfo(columnNames[i], columnTypes[i])); + } + + return columnsList; + } + + /// + /// Gets a list of column names or column-definition-strings for the + /// associated view. + /// + /// the view to that defines the columns + /// true to return types (column definition strings), + /// false to return names + /// list of column names or types + private static IList GetViewColumns(View view, bool types) + { + int recordHandle; + int typesFlag = types ? 1 : 0; + uint ret = RemotableNativeMethods.MsiViewGetColumnInfo( + (int) view.Handle, (uint) typesFlag, out recordHandle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + using (Record rec = new Record((IntPtr) recordHandle, true, null)) + { + int count = rec.FieldCount; + IList columnsList = new List(count); + + // Since we must be getting all strings of limited length, + // this code is faster than calling rec.GetString(field). + for (int field = 1; field <= count; field++) + { + uint bufSize = 256; + StringBuilder buf = new StringBuilder((int) bufSize); + ret = RemotableNativeMethods.MsiRecordGetString((int) rec.Handle, (uint) field, buf, ref bufSize); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + columnsList.Add(buf.ToString()); + } + return columnsList; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnEnums.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnEnums.cs new file mode 100644 index 00000000..ad0a945b --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnEnums.cs @@ -0,0 +1,689 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Diagnostics.CodeAnalysis; + + // Enumerations are in alphabetical order. + + /// + /// Available values for the Attributes column of the Component table. + /// + [Flags] + public enum ComponentAttributes : int + { + /// + /// Local only - Component cannot be run from source. + /// + ///

+ /// Set this value for all components belonging to a feature to prevent the feature from being run-from-network or + /// run-from-source. Note that if a feature has no components, the feature always shows run-from-source and + /// run-from-my-computer as valid options. + ///

+ None = 0x0000, + + /// + /// Component can only be run from source. + /// + ///

+ /// Set this bit for all components belonging to a feature to prevent the feature from being run-from-my-computer. + /// Note that if a feature has no components, the feature always shows run-from-source and run-from-my-computer + /// as valid options. + ///

+ SourceOnly = 0x0001, + + /// + /// Component can run locally or from source. + /// + Optional = 0x0002, + + /// + /// If this bit is set, the value in the KeyPath column is used as a key into the Registry table. + /// + ///

+ /// If the Value field of the corresponding record in the Registry table is null, the Name field in that record + /// must not contain "+", "-", or "*". For more information, see the description of the Name field in Registry + /// table. + ///

Setting this bit is recommended for registry entries written to the HKCU hive. This ensures the installer + /// writes the necessary HKCU registry entries when there are multiple users on the same machine.

+ ///

+ RegistryKeyPath = 0x0004, + + /// + /// If this bit is set, the installer increments the reference count in the shared DLL registry of the component's + /// key file. If this bit is not set, the installer increments the reference count only if the reference count + /// already exists. + /// + SharedDllRefCount = 0x0008, + + /// + /// If this bit is set, the installer does not remove the component during an uninstall. The installer registers + /// an extra system client for the component in the Windows Installer registry settings. + /// + Permanent = 0x0010, + + /// + /// If this bit is set, the value in the KeyPath column is a key into the ODBCDataSource table. + /// + OdbcDataSource = 0x0020, + + /// + /// If this bit is set, the installer reevaluates the value of the statement in the Condition column upon a reinstall. + /// If the value was previously False and has changed to true, the installer installs the component. If the value + /// was previously true and has changed to false, the installer removes the component even if the component has + /// other products as clients. + /// + Transitive = 0x0040, + + /// + /// If this bit is set, the installer does not install or reinstall the component if a key path file or a key path + /// registry entry for the component already exists. The application does register itself as a client of the component. + /// + ///

+ /// Use this flag only for components that are being registered by the Registry table. Do not use this flag for + /// components registered by the AppId, Class, Extension, ProgId, MIME, and Verb tables. + ///

+ NeverOverwrite = 0x0080, + + /// + /// Set this bit to mark this as a 64-bit component. This attribute facilitates the installation of packages that + /// include both 32-bit and 64-bit components. If this bit is not set, the component is registered as a 32-bit component. + /// + ///

+ /// If this is a 64-bit component replacing a 32-bit component, set this bit and assign a new GUID in the + /// ComponentId column. + ///

+ SixtyFourBit = 0x0100, + + /// + /// Set this bit to disable registry reflection on all existing and new registry keys affected by this component. + /// + ///

+ /// If this bit is set, the Windows Installer calls the RegDisableReflectionKey on each key being accessed by the component. + /// This bit is available with Windows Installer version 4.0 and is ignored on 32-bit systems. + ///

+ DisableRegistryReflection = 0x0200, + + /// + /// [MSI 4.5] Set this bit for a component in a patch package to prevent leaving orphan components on the computer. + /// + ///

+ /// If a subsequent patch is installed, marked with the SupersedeEarlier flag in its MsiPatchSequence + /// table to supersede the first patch, Windows Installer 4.5 can unregister and uninstall components marked with the + /// UninstallOnSupersedence value. If the component is not marked with this bit, installation of a superseding patch can leave + /// behind an unused component on the computer. + ///

+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Supersedence")] + UninstallOnSupersedence = 0x0400, + + /// + /// [MSI 4.5] If a component is marked with this attribute value in at least one package installed on the system, + /// the installer treats the component as marked in all packages. If a package that shares the marked component + /// is uninstalled, Windows Installer 4.5 can continue to share the highest version of the component on the system, + /// even if that highest version was installed by the package that is being uninstalled. + /// + Shared = 0x0800, + } + + /// + /// Defines flags for the Attributes column of the Control table. + /// + [Flags] + public enum ControlAttributes : int + { + /// If this bit is set, the control is visible on the dialog box. + Visible = 0x00000001, + + /// specifies if the given control is enabled or disabled. Most controls appear gray when disabled. + Enabled = 0x00000002, + + /// If this bit is set, the control is displayed with a sunken, three dimensional look. + Sunken = 0x00000004, + + /// The Indirect control attribute specifies whether the value displayed or changed by this control is referenced indirectly. + Indirect = 0x00000008, + + /// If this bit is set on a control, the associated property specified in the Property column of the Control table is an integer. + Integer = 0x00000010, + + /// If this bit is set the text in the control is displayed in a right-to-left reading order. + RightToLeftReadingOrder = 0x00000020, + + /// If this style bit is set, text in the control is aligned to the right. + RightAligned = 0x00000040, + + /// If this bit is set, the scroll bar is located on the left side of the control, otherwise it is on the right. + LeftScroll = 0x00000080, + + /// This is a combination of the RightToLeftReadingOrder, RightAligned, and LeftScroll attributes. + Bidirectional = RightToLeftReadingOrder | RightAligned | LeftScroll, + + /// If this bit is set on a text control, the control is displayed transparently with the background showing through the control where there are no characters. + Transparent = 0x00010000, + + /// If this bit is set on a text control, the occurrence of the character "&" in a text string is displayed as itself. + NoPrefix = 0x00020000, + + /// If this bit is set the text in the control is displayed on a single line. + NoWrap = 0x00040000, + + /// If this bit is set for a text control, the control will automatically attempt to format the displayed text as a number representing a count of bytes. + FormatSize = 0x00080000, + + /// If this bit is set, fonts are created using the user's default UI code page. Otherwise it is created using the database code page. + UsersLanguage = 0x00100000, + + /// If this bit is set on an Edit control, the installer creates a multiple line edit control with a vertical scroll bar. + Multiline = 0x00010000, + + /// This attribute creates an edit control for entering passwords. The control displays each character as an asterisk (*) as they are typed into the control. + PasswordInput = 0x00200000, + + /// If this bit is set on a ProgressBar control, the bar is drawn as a series of small rectangles in Microsoft Windows 95-style. Otherwise it is drawn as a single continuous rectangle. + Progress95 = 0x00010000, + + /// If this bit is set, the control shows removable volumes. + RemovableVolume = 0x00010000, + + /// If this bit is set, the control shows fixed internal hard drives. + FixedVolume = 0x00020000, + + /// If this bit is set, the control shows remote volumes. + RemoteVolume = 0x00040000, + + /// If this bit is set, the control shows CD-ROM volumes. + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cdrom")] + CdromVolume = 0x00080000, + + /// If this bit is set, the control shows RAM disk volumes. + RamDiskVolume = 0x00100000, + + /// If this bit is set, the control shows floppy volumes. + FloppyVolume = 0x00200000, + + /// Specifies whether or not the rollback backup files are included in the costs displayed by the VolumeCostList control. + ShowRollbackCost = 0x00400000, + + /// If this bit is set, the items listed in the control are displayed in a specified order. Otherwise, items are displayed in alphabetical order. + Sorted = 0x00010000, + + /// If this bit is set on a combo box, the edit field is replaced by a static text field. This prevents a user from entering a new value and requires the user to choose only one of the predefined values. + ComboList = 0x00020000, + + //ImageHandle = 0x00010000, + + /// If this bit is set on a check box or a radio button group, the button is drawn with the appearance of a push button, but its logic stays the same. + PushLike = 0x00020000, + + /// If this bit is set, the text in the control is replaced by a bitmap image. The Text column in the Control table is a foreign key into the Binary table. + Bitmap = 0x00040000, + + /// If this bit is set, text is replaced by an icon image and the Text column in the Control table is a foreign key into the Binary table. + Icon = 0x00080000, + + /// If this bit is set, the picture is cropped or centered in the control without changing its shape or size. + FixedSize = 0x00100000, + + /// Specifies which size of the icon image to load. If none of the bits are set, the first image is loaded. + IconSize16 = 0x00200000, + + /// Specifies which size of the icon image to load. If none of the bits are set, the first image is loaded. + IconSize32 = 0x00400000, + + /// Specifies which size of the icon image to load. If none of the bits are set, the first image is loaded. + IconSize48 = 0x00600000, + + /// If this bit is set, and the installation is not yet running with elevated privileges, the control is created with a UAC icon. + ElevationShield = 0x00800000, + + /// If this bit is set, the RadioButtonGroup has text and a border displayed around it. + HasBorder = 0x01000000, + } + + /// + /// Defines flags for the Type column of the CustomAction table. + /// + [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")] + [Flags] + public enum CustomActionTypes : int + { + /// Unspecified custom action type. + None = 0x0000, + + /// Target = entry point name + Dll = 0x0001, + + /// Target = command line args + Exe = 0x0002, + + /// Target = text string to be formatted and set into property + TextData = 0x0003, + + /// Target = entry point name, null if none to call + JScript = 0x0005, + + /// Target = entry point name, null if none to call + VBScript = 0x0006, + + /// Target = property list for nested engine initialization + Install = 0x0007, + + /// Source = File.File, file part of installation + SourceFile = 0x0010, + + /// Source = Directory.Directory, folder containing existing file + Directory = 0x0020, + + /// Source = Property.Property, full path to executable + Property = 0x0030, + + /// Ignore action return status, continue running + Continue = 0x0040, + + /// Run asynchronously + Async = 0x0080, + + /// Skip if UI sequence already run + FirstSequence = 0x0100, + + /// Skip if UI sequence already run in same process + OncePerProcess = 0x0200, + + /// Run on client only if UI already run on client + ClientRepeat = 0x0300, + + /// Queue for execution within script + InScript = 0x0400, + + /// In conjunction with InScript: queue in Rollback script + Rollback = 0x0100, + + /// In conjunction with InScript: run Commit ops from script on success + Commit = 0x0200, + + /// No impersonation, run in system context + NoImpersonate = 0x0800, + + /// Impersonate for per-machine installs on TS machines + TSAware = 0x4000, + + /// Script requires 64bit process + SixtyFourBitScript = 0x1000, + + /// Don't record the contents of the Target field in the log file + HideTarget = 0x2000, + + /// The custom action runs only when a patch is being uninstalled + PatchUninstall = 0x8000, + } + + /// + /// Defines flags for the Attributes column of the Dialog table. + /// + [Flags] + public enum DialogAttributes : int + { + /// If this bit is set, the dialog is originally created as visible, otherwise it is hidden. + Visible = 0x00000001, + + /// If this bit is set, the dialog box is modal, other dialogs of the same application cannot be put on top of it, and the dialog keeps the control while it is running. + Modal = 0x00000002, + + /// If this bit is set, the dialog box can be minimized. This bit is ignored for modal dialog boxes, which cannot be minimized. + Minimize = 0x00000004, + + /// If this style bit is set, the dialog box will stop all other applications and no other applications can take the focus. + SysModal = 0x00000008, + + /// If this bit is set, the other dialogs stay alive when this dialog box is created. + KeepModeless = 0x00000010, + + /// If this bit is set, the dialog box periodically calls the installer. If the property changes, it notifies the controls on the dialog. + TrackDiskSpace = 0x00000020, + + /// If this bit is set, the pictures on the dialog box are created with the custom palette (one per dialog received from the first control created). + UseCustomPalette = 0x00000040, + + /// If this style bit is set the text in the dialog box is displayed in right-to-left-reading order. + RightToLeftReadingOrder = 0x00000080, + + /// If this style bit is set, the text is aligned on the right side of the dialog box. + RightAligned = 0x00000100, + + /// If this style bit is set, the scroll bar is located on the left side of the dialog box. + LeftScroll = 0x00000200, + + /// This is a combination of the RightToLeftReadingOrder, RightAligned, and the LeftScroll dialog style bits. + Bidirectional = RightToLeftReadingOrder | RightAligned | LeftScroll, + + /// If this bit is set, the dialog box is an error dialog. + Error = 0x00010000, + } + + /// + /// Available values for the Attributes column of the Feature table. + /// + [Flags] + public enum FeatureAttributes : int + { + /// + /// Favor local - Components of this feature that are not marked for installation from source are installed locally. + /// + ///

+ /// A component shared by two or more features, some of which are set to FavorLocal and some to FavorSource, + /// is installed locally. Components marked in the Component + /// table are always run from the source CD/server. The bits FavorLocal and FavorSource work with features not + /// listed by the ADVERTISE property. + ///

+ None = 0x0000, + + /// + /// Components of this feature not marked for local installation are installed to run from the source + /// CD-ROM or server. + /// + ///

+ /// A component shared by two or more features, some of which are set to FavorLocal and some to FavorSource, + /// is installed to run locally. Components marked (local-only) in the + /// Component table are always installed locally. The bits FavorLocal and FavorSource work with features + /// not listed by the ADVERTISE property. + ///

+ FavorSource = 0x0001, + + /// + /// Set this attribute and the state of the feature is the same as the state of the feature's parent. + /// You cannot use this option if the feature is located at the root of a feature tree. + /// + ///

+ /// Omit this attribute and the feature state is determined according to DisallowAdvertise and + /// FavorLocal and FavorSource. + ///

To guarantee that the child feature's state always follows the state of its parent, even when the + /// child and parent are initially set to absent in the SelectionTree control, you must include both + /// FollowParent and UIDisallowAbsent in the attributes of the child feature.

+ ///

Note that if you set FollowParent without setting UIDisallowAbsent, the installer cannot force + /// the child feature out of the absent state. In this case, the child feature matches the parent's + /// installation state only if the child is set to something other than absent.

+ ///

Set FollowParent and UIDisallowAbsent to ensure a child feature follows the state of the parent feature.

+ ///

+ FollowParent = 0x0002, + + /// + /// Set this attribute and the feature state is Advertise. + /// + ///

+ /// If the feature is listed by the ADDDEFAULT property this bit is ignored and the feature state is determined + /// according to FavorLocal and FavorSource. + ///

Omit this attribute and the feature state is determined according to DisallowAdvertise and FavorLocal + /// and FavorSource.

+ ///

+ FavorAdvertise = 0x0004, + + /// + /// Set this attribute to prevent the feature from being advertised. + /// + ///

+ /// Note that this bit works only with features that are listed by the ADVERTISE property. + ///

Set this attribute and if the listed feature is not a parent or child, the feature is installed according to + /// FavorLocal and FavorSource.

+ ///

Set this attribute for the parent of a listed feature and the parent is installed.

+ ///

Set this attribute for the child of a listed feature and the state of the child is Absent.

+ ///

Omit this attribute and if the listed feature is not a parent or child, the feature state is Advertise.

+ ///

Omit this attribute and if the listed feature is a parent or child, the state of both features is Advertise.

+ ///

+ DisallowAdvertise = 0x0008, + + /// + /// Set this attribute and the user interface does not display an option to change the feature state + /// to Absent. Setting this attribute forces the feature to the installation state, whether or not the + /// feature is visible in the UI. + /// + ///

+ /// Omit this attribute and the user interface displays an option to change the feature state to Absent. + ///

Set FollowParent and UIDisallowAbsent to ensure a child feature follows the state of the parent feature.

+ ///

Setting this attribute not only affects the UI, but also forces the feature to the install state whether + /// the feature is visible in the UI or not.

+ ///

+ UIDisallowAbsent = 0x0010, + + /// + /// Set this attribute and advertising is disabled for the feature if the operating system shell does not + /// support Windows Installer descriptors. + /// + NoUnsupportedAdvertise = 0x0020, + } + + /// + /// Available values for the Attributes column of the File table. + /// + [Flags] + public enum FileAttributes : int + { + /// No attributes. + None = 0x0000, + + /// Read-only. + ReadOnly = 0x0001, + + /// Hidden. + Hidden = 0x0002, + + /// System. + System = 0x0004, + + /// The file is vital for the proper operation of the component to which it belongs. + Vital = 0x0200, + + /// The file contains a valid checksum. A checksum is required to repair a file that has become corrupted. + Checksum = 0x0400, + + /// This bit must only be added by a patch and if the file is being added by the patch. + PatchAdded = 0x1000, + + /// + /// The file's source type is uncompressed. If set, ignore the WordCount summary information property. If neither + /// Noncompressed nor Compressed are set, the compression state of the file is specified by the WordCount summary + /// information property. Do not set both Noncompressed and Compressed. + /// + NonCompressed = 0x2000, + + /// + /// The file's source type is compressed. If set, ignore the WordCount summary information property. If neither + /// Noncompressed or Compressed are set, the compression state of the file is specified by the WordCount summary + /// information property. Do not set both Noncompressed and Compressed. + /// + Compressed = 0x4000, + } + + /// + /// Defines values for the Action column of the IniFile and RemoveIniFile tables. + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ini")] + public enum IniFileAction : int + { + /// Creates or updates a .ini entry. + AddLine = 0, + + /// Creates a .ini entry only if the entry does not already exist. + CreateLine = 1, + + /// Deletes .ini entry. + RemoveLine = 2, + + /// Creates a new entry or appends a new comma-separated value to an existing entry. + AddTag = 3, + + /// Deletes a tag from a .ini entry. + RemoveTag = 4, + } + + /// + /// Defines values for the Type column of the CompLocator, IniLocator, and RegLocator tables. + /// + [Flags] + [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] + public enum LocatorTypes : int + { + /// Key path is a directory. + Directory = 0x00000000, + + /// Key path is a file name. + FileName = 0x00000001, + + /// Key path is a registry value. + RawValue = 0x00000002, + + /// Set this bit to have the installer search the 64-bit portion of the registry. + SixtyFourBit = 0x00000010, + } + + /// + /// Defines values for the Root column of the Registry, RemoveRegistry, and RegLocator tables. + /// + public enum RegistryRoot : int + { + /// HKEY_CURRENT_USER for a per-user installation, + /// or HKEY_LOCAL_MACHINE for a per-machine installation. + UserOrMachine = -1, + + /// HKEY_CLASSES_ROOT + ClassesRoot = 0, + + /// HKEY_CURRENT_USER + CurrentUser = 1, + + /// HKEY_LOCAL_MACHINE + LocalMachine = 2, + + /// HKEY_USERS + Users = 3, + } + + /// + /// Defines values for the InstallMode column of the RemoveFile table. + /// + [Flags] + public enum RemoveFileModes : int + { + /// Never remove. + None = 0, + + /// Remove when the associated component is being installed (install state = local or source). + OnInstall = 1, + + /// Remove when the associated component is being removed (install state = absent). + OnRemove = 2, + } + + /// + /// Defines values for the ServiceType, StartType, and ErrorControl columns of the ServiceInstall table. + /// + [Flags] + public enum ServiceAttributes : int + { + /// No flags. + None = 0, + + /// A Win32 service that runs its own process. + OwnProcess = 0x0010, + + /// A Win32 service that shares a process. + ShareProcess = 0x0020, + + /// A Win32 service that interacts with the desktop. + /// This value cannot be used alone and must be added to either + /// or . + Interactive = 0x0100, + + /// Service starts during startup of the system. + AutoStart = 0x0002, + + /// Service starts when the service control manager calls the StartService function. + DemandStart = 0x0003, + + /// Specifies a service that can no longer be started. + Disabled = 0x0004, + + /// Logs the error, displays a message box and continues the startup operation. + ErrorMessage = 0x0001, + + /// Logs the error if it is possible and the system is restarted with the last configuration + /// known to be good. If the last-known-good configuration is being started, the startup operation fails. + ErrorCritical = 0x0003, + + /// When combined with other error flags, specifies that the overall install should fail if + /// the service cannot be installed into the system. + ErrorControlVital = 0x8000, + } + + /// + /// Defines values for the Event column of the ServiceControl table. + /// + [Flags] + public enum ServiceControlEvents : int + { + /// No control events. + None = 0x0000, + + /// During an install, starts the service during the StartServices action. + Start = 0x0001, + + /// During an install, stops the service during the StopServices action. + Stop = 0x0002, + + /// During an install, deletes the service during the DeleteServices action. + Delete = 0x0008, + + /// During an uninstall, starts the service during the StartServices action. + UninstallStart = 0x0010, + + /// During an uninstall, stops the service during the StopServices action. + UninstallStop = 0x0020, + + /// During an uninstall, deletes the service during the DeleteServices action. + UninstallDelete = 0x0080, + } + + /// + /// Defines values for the StyleBits column of the TextStyle table. + /// + [Flags] + public enum TextStyles : int + { + /// Bold + Bold = 0x0001, + + /// Italic + Italic = 0x0002, + + /// Underline + Underline = 0x0004, + + /// Strike out + Strike = 0x0008, + } + + /// + /// Defines values for the Attributes column of the Upgrade table. + /// + [Flags] + public enum UpgradeAttributes : int + { + /// Migrates feature states by enabling the logic in the MigrateFeatureStates action. + MigrateFeatures = 0x0001, + + /// Detects products and applications but does not remove. + OnlyDetect = 0x0002, + + /// Continues installation upon failure to remove a product or application. + IgnoreRemoveFailure = 0x0004, + + /// Detects the range of versions including the value in VersionMin. + VersionMinInclusive = 0x0100, + + /// Dectects the range of versions including the value in VersionMax. + VersionMaxInclusive = 0x0200, + + /// Detects all languages, excluding the languages listed in the Language column. + LanguagesExclusive = 0x0400, + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnInfo.cs new file mode 100644 index 00000000..43363230 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ColumnInfo.cs @@ -0,0 +1,297 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// Defines a single column of a table in an installer database. + /// + /// Once created, a ColumnInfo object is immutable. + public class ColumnInfo + { + private string name; + private Type type; + private int size; + private bool isRequired; + private bool isTemporary; + private bool isLocalizable; + + /// + /// Creates a new ColumnInfo object from a column definition. + /// + /// name of the column + /// column definition string + /// + public ColumnInfo(string name, string columnDefinition) + : this(name, typeof(String), 0, false, false, false) + { + if (name == null) + { + throw new ArgumentNullException("name"); + } + + if (columnDefinition == null) + { + throw new ArgumentNullException("columnDefinition"); + } + + switch (Char.ToLower(columnDefinition[0], CultureInfo.InvariantCulture)) + { + case 'i': this.type = typeof(Int32); + break; + case 'j': this.type = typeof(Int32); this.isTemporary = true; + break; + case 'g': this.type = typeof(String); this.isTemporary = true; + break; + case 'l': this.type = typeof(String); this.isLocalizable = true; + break; + case 'o': this.type = typeof(Stream); this.isTemporary = true; + break; + case 's': this.type = typeof(String); + break; + case 'v': this.type = typeof(Stream); + break; + default: throw new InstallerException(); + } + + this.isRequired = Char.IsLower(columnDefinition[0]); + this.size = Int32.Parse( + columnDefinition.Substring(1), + CultureInfo.InvariantCulture.NumberFormat); + if (this.type == typeof(Int32) && this.size <= 2) + { + this.type = typeof(Int16); + } + } + + /// + /// Creates a new ColumnInfo object from a list of parameters. + /// + /// name of the column + /// type of the column; must be one of the following: + /// Int16, Int32, String, or Stream + /// the maximum number of characters for String columns; + /// ignored for other column types + /// true if the column is required to have a non-null value + public ColumnInfo(string name, Type type, int size, bool isRequired) + : this(name, type, size, isRequired, false, false) + { + } + + /// + /// Creates a new ColumnInfo object from a list of parameters. + /// + /// name of the column + /// type of the column; must be one of the following: + /// Int16, Int32, String, or Stream + /// the maximum number of characters for String columns; + /// ignored for other column types + /// true if the column is required to have a non-null value + /// true to if the column is only in-memory and + /// not persisted with the database + /// for String columns, indicates the column + /// is localizable; ignored for other column types + public ColumnInfo(string name, Type type, int size, bool isRequired, bool isTemporary, bool isLocalizable) + { + if (name == null) + { + throw new ArgumentNullException("name"); + } + + if (type == typeof(Int32)) + { + size = 4; + isLocalizable = false; + } + else if (type == typeof(Int16)) + { + size = 2; + isLocalizable = false; + } + else if (type == typeof(String)) + { + } + else if (type == typeof(Stream)) + { + isLocalizable = false; + } + else + { + throw new ArgumentOutOfRangeException("type"); + } + + this.name = name; + this.type = type; + this.size = size; + this.isRequired = isRequired; + this.isTemporary = isTemporary; + this.isLocalizable = isLocalizable; + } + + /// + /// Gets the name of the column. + /// + /// name of the column + public string Name + { + get { return this.name; } + } + + /// + /// Gets the type of the column as a System.Type. This is one of the following: Int16, Int32, String, or Stream + /// + /// type of the column + [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] + public Type Type + { + get { return this.type; } + } + + /// + /// Gets the type of the column as an integer that can be cast to a System.Data.DbType. This is one of the following: Int16, Int32, String, or Binary + /// + /// equivalent DbType of the column as an integer + public int DBType + { + get + { + if (this.type == typeof(Int16)) return 10; + else if (this.type == typeof(Int32)) return 11; + else if (this.type == typeof(Stream)) return 1; + else return 16; + } + } + + /// + /// Gets the size of the column. + /// + /// The size of integer columns this is either 2 or 4. For string columns this is the maximum + /// recommended length of the string, or 0 for unlimited length. For stream columns, 0 is returned. + public int Size + { + get { return this.size; } + } + + /// + /// Gets a value indicating whether the column must be non-null when inserting a record. + /// + /// required status of the column + public bool IsRequired + { + get { return this.isRequired; } + } + + /// + /// Gets a value indicating whether the column is temporary. Temporary columns are not persisted + /// when the database is saved to disk. + /// + /// temporary status of the column + public bool IsTemporary + { + get { return this.isTemporary; } + } + + /// + /// Gets a value indicating whether the column is a string column that is localizable. + /// + /// localizable status of the column + public bool IsLocalizable + { + get { return this.isLocalizable; } + } + + /// + /// Gets an SQL fragment that can be used to create this column within a CREATE TABLE statement. + /// + /// SQL fragment to be used for creating the column + ///

+ /// Examples: + /// + /// LONG + /// SHORT TEMPORARY + /// CHAR(0) LOCALIZABLE + /// CHAR(72) NOT NULL LOCALIZABLE + /// OBJECT + /// + ///

+ public string SqlCreateString + { + get + { + StringBuilder s = new StringBuilder(); + s.AppendFormat("`{0}` ", this.name); + if (this.type == typeof(Int16)) s.Append("SHORT"); + else if (this.type == typeof(Int32)) s.Append("LONG"); + else if (this.type == typeof(String)) s.AppendFormat("CHAR({0})", this.size); + else s.Append("OBJECT"); + if (this.isRequired) s.Append(" NOT NULL"); + if (this.isTemporary) s.Append(" TEMPORARY"); + if (this.isLocalizable) s.Append(" LOCALIZABLE"); + return s.ToString(); + } + } + + /// + /// Gets a short string defining the type and size of the column. + /// + /// + /// The definition string consists + /// of a single letter representing the data type followed by the width of the column (in characters + /// when applicable, bytes otherwise). A width of zero designates an unbounded width (for example, + /// long text fields and streams). An uppercase letter indicates that null values are allowed in + /// the column. + /// + ///

+ /// + /// s? - String, variable length (?=1-255) + /// s0 - String, variable length + /// i2 - Short integer + /// i4 - Long integer + /// v0 - Binary Stream + /// g? - Temporary string (?=0-255) + /// j? - Temporary integer (?=0,1,2,4) + /// O0 - Temporary object (stream) + /// l? - Localizable string, variable length (?=1-255) + /// l0 - Localizable string, variable length + /// + ///

+ public string ColumnDefinitionString + { + get + { + char t; + if (this.type == typeof(Int16) || this.type == typeof(Int32)) + { + t = (this.isTemporary ? 'j' : 'i'); + } + else if (this.type == typeof(String)) + { + t = (this.isTemporary ? 'g' : this.isLocalizable ? 'l' : 's'); + } + else + { + t = (this.isTemporary ? 'O' : 'v'); + } + return String.Format( + CultureInfo.InvariantCulture, + "{0}{1}", + (this.isRequired ? t : Char.ToUpper(t, CultureInfo.InvariantCulture)), + this.size); + } + } + + /// + /// Gets the name of the column. + /// + /// Name of the column. + public override string ToString() + { + return this.Name; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInfo.cs new file mode 100644 index 00000000..af27fd1d --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInfo.cs @@ -0,0 +1,276 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections; + using System.Collections.Generic; + + /// + /// Accessor for information about components within the context of an installation session. + /// + public sealed class ComponentInfoCollection : ICollection + { + private Session session; + + internal ComponentInfoCollection(Session session) + { + this.session = session; + } + + /// + /// Gets information about a component within the context of an installation session. + /// + /// name of the component + /// component object + public ComponentInfo this[string component] + { + get + { + return new ComponentInfo(this.session, component); + } + } + + void ICollection.Add(ComponentInfo item) + { + throw new InvalidOperationException(); + } + + void ICollection.Clear() + { + throw new InvalidOperationException(); + } + + /// + /// Checks if the collection contains a component. + /// + /// name of the component + /// true if the component is in the collection, else false + public bool Contains(string component) + { + return this.session.Database.CountRows( + "Component", "`Component` = '" + component + "'") == 1; + } + + bool ICollection.Contains(ComponentInfo item) + { + return item != null && this.Contains(item.Name); + } + + /// + /// Copies the features into an array. + /// + /// array that receives the features + /// offset into the array + public void CopyTo(ComponentInfo[] array, int arrayIndex) + { + foreach (ComponentInfo component in this) + { + array[arrayIndex++] = component; + } + } + + /// + /// Gets the number of components defined for the product. + /// + public int Count + { + get + { + return this.session.Database.CountRows("Component"); + } + } + + bool ICollection.IsReadOnly + { + get + { + return true; + } + } + + bool ICollection.Remove(ComponentInfo item) + { + throw new InvalidOperationException(); + } + + /// + /// Enumerates the components in the collection. + /// + /// an enumerator over all features in the collection + public IEnumerator GetEnumerator() + { + using (View compView = this.session.Database.OpenView( + "SELECT `Component` FROM `Component`")) + { + compView.Execute(); + + foreach (Record compRec in compView) using (compRec) + { + string comp = compRec.GetString(1); + yield return new ComponentInfo(this.session, comp); + } + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } + + /// + /// Provides access to information about a component within the context of an installation session. + /// + public class ComponentInfo + { + private Session session; + private string name; + + internal ComponentInfo(Session session, string name) + { + this.session = session; + this.name = name; + } + + /// + /// Gets the name of the component (primary key in the Component table). + /// + public string Name + { + get + { + return this.name; + } + } + + /// + /// Gets the current install state of the designated Component. + /// + /// the Session handle is invalid + /// an unknown Component was requested + ///

+ /// Win32 MSI API: + /// MsiGetComponentState + ///

+ public InstallState CurrentState + { + get + { + int installedState, actionState; + uint ret = RemotableNativeMethods.MsiGetComponentState((int) this.session.Handle, this.name, out installedState, out actionState); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_COMPONENT) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return (InstallState) installedState; + } + } + + /// + /// Gets or sets the action state of the designated Component. + /// + /// the Session handle is invalid + /// an unknown Component was requested + /// the user exited the installation + ///

+ /// Win32 MSI APIs: + /// MsiGetComponentState, + /// MsiSetComponentState + ///

+ public InstallState RequestState + { + get + { + int installedState, actionState; + uint ret = RemotableNativeMethods.MsiGetComponentState((int) this.session.Handle, this.name, out installedState, out actionState); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_COMPONENT) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return (InstallState) actionState; + } + + set + { + uint ret = RemotableNativeMethods.MsiSetComponentState((int) this.session.Handle, this.name, (int) value); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_COMPONENT) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + } + + /// + /// Gets disk space per drive required to install a component. + /// + /// Requested component state + /// A list of InstallCost structures, specifying the cost for each drive for the component + ///

+ /// Win32 MSI API: + /// MsiEnumComponentCosts + ///

+ public IList GetCost(InstallState installState) + { + IList costs = new List(); + StringBuilder driveBuf = new StringBuilder(20); + for (uint i = 0; true; i++) + { + int cost, tempCost; + uint driveBufSize = (uint) driveBuf.Capacity; + uint ret = RemotableNativeMethods.MsiEnumComponentCosts( + (int) this.session.Handle, + this.name, + i, + (int) installState, + driveBuf, + ref driveBufSize, + out cost, + out tempCost); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + driveBuf.Capacity = (int) ++driveBufSize; + ret = RemotableNativeMethods.MsiEnumComponentCosts( + (int) this.session.Handle, + this.name, + i, + (int) installState, + driveBuf, + ref driveBufSize, + out cost, + out tempCost); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + costs.Add(new InstallCost(driveBuf.ToString(), cost * 512L, tempCost * 512L)); + } + return costs; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInstallation.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInstallation.cs new file mode 100644 index 00000000..6d368899 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ComponentInstallation.cs @@ -0,0 +1,382 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + + /// + /// Represents an instance of a registered component. + /// + public class ComponentInstallation : InstallationPart + { + /// + /// Gets the set of installed components for all products. + /// + /// The installer configuration data is corrupt + ///

+ /// Win32 MSI API: + /// MsiEnumComponents + ///

+ public static IEnumerable AllComponents + { + get + { + StringBuilder buf = new StringBuilder(40); + for (uint i = 0; true; i++) + { + uint ret = NativeMethods.MsiEnumComponents(i, buf); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + yield return new ComponentInstallation(buf.ToString()); + } + } + } + + /// + /// Gets the set of installed components for products in the indicated context. + /// + /// The installer configuration data is corrupt + ///

+ /// Win32 MSI API: + /// MsiEnumComponentsEx + ///

+ public static IEnumerable Components(string szUserSid, UserContexts dwContext) + { + uint pcchSid = 32; + StringBuilder szSid = new StringBuilder((int)pcchSid); + StringBuilder buf = new StringBuilder(40); + UserContexts installedContext; + for (uint i = 0; true; i++) + { + uint ret = NativeMethods.MsiEnumComponentsEx(szUserSid, dwContext, i, buf, out installedContext, szSid, ref pcchSid); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + szSid.EnsureCapacity((int) ++pcchSid); + ret = NativeMethods.MsiEnumComponentsEx(szUserSid, dwContext, i, buf, out installedContext, szSid, ref pcchSid); + } + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + yield return new ComponentInstallation(buf.ToString(), szSid.ToString(), installedContext); + } + } + private static string GetProductCode(string component) + { + StringBuilder buf = new StringBuilder(40); + uint ret = NativeMethods.MsiGetProductCode(component, buf); + if (ret != 0) + { + return null; + } + + return buf.ToString(); + } + + private static string GetProductCode(string component, string szUserSid, UserContexts dwContext) + { + // TODO: We really need what would be MsiGetProductCodeEx, or at least a reasonable facimile thereof (something that restricts the search to the context defined by szUserSid & dwContext) + return GetProductCode(component); + } + + /// + /// Creates a new ComponentInstallation, automatically detecting the + /// product that the component is a part of. + /// + /// component GUID + ///

+ /// Win32 MSI API: + /// MsiGetProductCode + ///

+ public ComponentInstallation(string componentCode) + : this(componentCode, ComponentInstallation.GetProductCode(componentCode)) + { + } + + /// + /// Creates a new ComponentInstallation, automatically detecting the + /// product that the component is a part of. + /// + /// component GUID + /// context user SID + /// user contexts + public ComponentInstallation(string componentCode, string szUserSid, UserContexts dwContext) + : this(componentCode, ComponentInstallation.GetProductCode(componentCode, szUserSid, dwContext), szUserSid, dwContext) + { + } + + /// + /// Creates a new ComponentInstallation for a component installed by a + /// specific product. + /// + /// component GUID + /// ProductCode GUID + public ComponentInstallation(string componentCode, string productCode) + : this(componentCode, productCode, null, UserContexts.None) + { + } + + /// + /// Creates a new ComponentInstallation for a component installed by a + /// specific product. + /// + /// component GUID + /// ProductCode GUID + /// context user SID + /// user contexts + public ComponentInstallation(string componentCode, string productCode, string szUserSid, UserContexts dwContext) + : base(componentCode, productCode, szUserSid, dwContext) + { + if (string.IsNullOrEmpty(componentCode)) + { + throw new ArgumentNullException("componentCode"); + } + } + + /// + /// Gets the component code (GUID) of the component. + /// + public string ComponentCode + { + get + { + return this.Id; + } + } + + /// + /// Gets all client products of a specified component. + /// + /// enumeration over all client products of the component + /// The installer configuration data is corrupt + ///

+ /// Because clients are not ordered, any new component has an arbitrary index. + /// This means that the property may return clients in any order. + ///

+ /// Win32 MSI API: + /// MsiEnumClients, + /// MsiEnumClientsEx + ///

+ public IEnumerable ClientProducts + { + get + { + StringBuilder buf = new StringBuilder(40); + for (uint i = 0; true; i++) + { + uint chSid = 0; + UserContexts installedContext; + uint ret = this.Context == UserContexts.None ? + NativeMethods.MsiEnumClients(this.ComponentCode, i, buf) : + NativeMethods.MsiEnumClientsEx(this.ComponentCode, this.UserSid, this.Context, i, buf, out installedContext, null, ref chSid); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + else if (ret == (uint) NativeMethods.Error.UNKNOWN_COMPONENT) break; + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + yield return new ProductInstallation(buf.ToString()); + } + } + } + + /// + /// Gets the installed state of a component. + /// + /// the installed state of the component, or InstallState.Unknown + /// if this component is not part of a product + ///

+ /// Win32 MSI API: + /// MsiGetComponentPath, + /// MsiGetComponentPathEx + ///

+ public override InstallState State + { + get + { + if (this.ProductCode != null) + { + uint bufSize = 0; + int installState = this.Context == UserContexts.None ? + NativeMethods.MsiGetComponentPath( + this.ProductCode, this.ComponentCode, null, ref bufSize) : + NativeMethods.MsiGetComponentPathEx( + this.ProductCode, this.ComponentCode, this.UserSid, this.Context, null, ref bufSize); + return (InstallState) installState; + } + else + { + return InstallState.Unknown; + } + } + } + + /// + /// Gets the full path to an installed component. If the key path for the component is a + /// registry key then the registry key is returned. + /// + /// The file or registry keypath to the component, or null if the component is not available. + /// An unknown product or component was specified + /// The installer configuration data is corrupt + ///

+ /// If the component is a registry key, the registry roots are represented numerically. + /// For example, a registry path of "HKEY_CURRENT_USER\SOFTWARE\Microsoft" would be returned + /// as "01:\SOFTWARE\Microsoft". The registry roots returned are defined as follows: + /// HKEY_CLASSES_ROOT=00, HKEY_CURRENT_USER=01, HKEY_LOCAL_MACHINE=02, HKEY_USERS=03, + /// HKEY_PERFORMANCE_DATA=04 + ///

+ /// Win32 MSI APIs: + /// MsiGetComponentPath, + /// MsiGetComponentPathEx, + /// MsiLocateComponent + ///

+ public string Path + { + get + { + StringBuilder buf = new StringBuilder(256); + uint bufSize = (uint) buf.Capacity; + InstallState installState; + + if (this.ProductCode != null) + { + installState = (this.Context == UserContexts.None) ? + (InstallState) NativeMethods.MsiGetComponentPath( + this.ProductCode, this.ComponentCode, buf, ref bufSize) : + (InstallState) NativeMethods.MsiGetComponentPathEx( + this.ProductCode, this.ComponentCode, this.UserSid, this.Context, buf, ref bufSize); + if (installState == InstallState.MoreData) + { + buf.Capacity = (int) ++bufSize; + installState = (this.Context == UserContexts.None) ? + (InstallState) NativeMethods.MsiGetComponentPath( + this.ProductCode, this.ComponentCode, buf, ref bufSize) : + (InstallState) NativeMethods.MsiGetComponentPathEx( + this.ProductCode, this.ComponentCode, this.UserSid, this.Context, buf, ref bufSize); + } + } + else + { + installState = (InstallState) NativeMethods.MsiLocateComponent( + this.ComponentCode, buf, ref bufSize); + if (installState == InstallState.MoreData) + { + buf.Capacity = (int) ++bufSize; + installState = (InstallState) NativeMethods.MsiLocateComponent( + this.ComponentCode, buf, ref bufSize); + } + } + + switch (installState) + { + case InstallState.Local: + case InstallState.Source: + case InstallState.SourceAbsent: + return buf.ToString(); + + default: + return null; + } + } + } + + /// + /// Gets the set of registered qualifiers for the component. + /// + /// Enumeration of the qulifiers for the component. + /// The installer configuration data is corrupt + ///

+ /// Because qualifiers are not ordered, any new qualifier has an arbitrary index, + /// meaning the function can return qualifiers in any order. + ///

+ /// Win32 MSI API: + /// MsiEnumComponentQualifiers + ///

+ public IEnumerable Qualifiers + { + get + { + StringBuilder qualBuf = new StringBuilder(255); + StringBuilder dataBuf = new StringBuilder(255); + for (uint i = 0; ; i++) + { + uint qualBufSize = (uint) qualBuf.Capacity; + uint dataBufSize = (uint) dataBuf.Capacity; + uint ret = NativeMethods.MsiEnumComponentQualifiers( + this.ComponentCode, i, qualBuf, ref qualBufSize, dataBuf, ref dataBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + qualBuf.Capacity = (int) ++qualBufSize; + dataBuf.Capacity = (int) ++dataBufSize; + ret = NativeMethods.MsiEnumComponentQualifiers( + this.ComponentCode, i, qualBuf, ref qualBufSize, dataBuf, ref dataBufSize); + } + + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS || + ret == (uint) NativeMethods.Error.UNKNOWN_COMPONENT) + { + break; + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + yield return new ComponentInstallation.Qualifier( + qualBuf.ToString(), dataBuf.ToString()); + } + } + } + + /// + /// Holds data about a component qualifier. + /// + ///

+ /// Win32 MSI API: + /// MsiEnumComponentQualifiers + ///

+ [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + public struct Qualifier + { + private string qualifierCode; + private string data; + + internal Qualifier(string qualifierCode, string data) + { + this.qualifierCode = qualifierCode; + this.data = data; + } + + /// + /// Gets the qualifier code. + /// + public string QualifierCode + { + get + { + return this.qualifierCode; + } + } + + /// + /// Gets the qualifier data. + /// + public string Data + { + get + { + return this.data; + } + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionAttribute.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionAttribute.cs new file mode 100644 index 00000000..d9bdb71b --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionAttribute.cs @@ -0,0 +1,55 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Reflection; + + /// + /// Marks a method as a custom action entry point. + /// + ///

+ /// A custom action method must be defined as public and static, + /// take a single object as a parameter, + /// and return an enumeration value. + ///

+ [Serializable, AttributeUsage(AttributeTargets.Method)] + public sealed class CustomActionAttribute : Attribute + { + /// + /// Name of the custom action entrypoint, or null if the same as the method name. + /// + private string name; + + /// + /// Marks a method as a custom action entry point. + /// + public CustomActionAttribute() + : this(null) + { + } + + /// + /// Marks a method as a custom action entry point. + /// + /// Name of the function to be exported, + /// defaults to the name of this method + public CustomActionAttribute(string name) + { + this.name = name; + } + + /// + /// Gets or sets the name of the custom action entrypoint. A null + /// value defaults to the name of the method. + /// + /// name of the custom action entrypoint, or null if none was specified + public string Name + { + get + { + return this.name; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs new file mode 100644 index 00000000..d3fd7d1b --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/CustomActionProxy.cs @@ -0,0 +1,321 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Security; + using System.Reflection; + using System.Collections; + using System.Configuration; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + /// + /// Managed-code portion of the custom action proxy. + /// + internal static class CustomActionProxy + { + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static int InvokeCustomAction32(int sessionHandle, string entryPoint, + int remotingDelegatePtr) + { + return CustomActionProxy.InvokeCustomAction(sessionHandle, entryPoint, new IntPtr(remotingDelegatePtr)); + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static int InvokeCustomAction64(int sessionHandle, string entryPoint, + long remotingDelegatePtr) + { + return CustomActionProxy.InvokeCustomAction(sessionHandle, entryPoint, new IntPtr(remotingDelegatePtr)); + } + + /// + /// Invokes a managed custom action method. + /// + /// Integer handle to the installer session. + /// Name of the custom action entrypoint. This must + /// either map to an entrypoint definition in the customActions + /// config section, or be an explicit entrypoint of the form: + /// "AssemblyName!Namespace.Class.Method" + /// Pointer to a delegate used to + /// make remote API calls, if this custom action is running out-of-proc. + /// The value returned by the custom action method, + /// or ERROR_INSTALL_FAILURE if the custom action could not be invoked. + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static int InvokeCustomAction(int sessionHandle, string entryPoint, + IntPtr remotingDelegatePtr) + { + Session session = null; + string assemblyName, className, methodName; + MethodInfo method; + + try + { + MsiRemoteInvoke remotingDelegate = (MsiRemoteInvoke) + Marshal.GetDelegateForFunctionPointer( + remotingDelegatePtr, typeof(MsiRemoteInvoke)); + RemotableNativeMethods.RemotingDelegate = remotingDelegate; + + sessionHandle = RemotableNativeMethods.MakeRemoteHandle(sessionHandle); + session = new Session((IntPtr) sessionHandle, false); + if (String.IsNullOrEmpty(entryPoint)) + { + throw new ArgumentNullException("entryPoint"); + } + + if (!CustomActionProxy.FindEntryPoint( + session, + entryPoint, + out assemblyName, + out className, + out methodName)) + { + return (int) ActionResult.Failure; + } + session.Log("Calling custom action {0}!{1}.{2}", assemblyName, className, methodName); + + method = CustomActionProxy.GetCustomActionMethod( + session, + assemblyName, + className, + methodName); + if (method == null) + { + return (int) ActionResult.Failure; + } + } + catch (Exception ex) + { + if (session != null) + { + try + { + session.Log("Exception while loading custom action:"); + session.Log(ex.ToString()); + } + catch (Exception) { } + } + return (int) ActionResult.Failure; + } + + try + { + // Set the current directory to the location of the extracted files. + Environment.CurrentDirectory = + AppDomain.CurrentDomain.BaseDirectory; + + object[] args = new object[] { session }; + if (DebugBreakEnabled(new string[] { entryPoint, methodName })) + { + string message = String.Format( + "To debug your custom action, attach to process ID {0} (0x{0:x}) and click OK; otherwise, click Cancel to fail the custom action.", + System.Diagnostics.Process.GetCurrentProcess().Id + ); + + MessageResult button = NativeMethods.MessageBox( + IntPtr.Zero, + message, + "Custom Action Breakpoint", + (int)MessageButtons.OKCancel | (int)MessageIcon.Asterisk | (int)(MessageBoxStyles.TopMost | MessageBoxStyles.ServiceNotification) + ); + + if (MessageResult.Cancel == button) + { + return (int)ActionResult.UserExit; + } + } + + ActionResult result = (ActionResult) method.Invoke(null, args); + session.Close(); + return (int) result; + } + catch (InstallCanceledException) + { + return (int) ActionResult.UserExit; + } + catch (Exception ex) + { + session.Log("Exception thrown by custom action:"); + session.Log(ex.ToString()); + return (int) ActionResult.Failure; + } + } + + /// + /// Checks the "MMsiBreak" environment variable for any matching custom action names. + /// + /// List of names to search for in the environment + /// variable string. + /// True if a match was found, else false. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal static bool DebugBreakEnabled(string[] names) + { + string mmsibreak = Environment.GetEnvironmentVariable("MMsiBreak"); + if (mmsibreak != null) + { + foreach (string breakName in mmsibreak.Split(',', ';')) + { + foreach (string name in names) + { + if (breakName == name) + { + return true; + } + } + } + } + return false; + } + + /// + /// Locates and parses an entrypoint mapping in CustomAction.config. + /// + /// Installer session handle, just used for logging. + /// Custom action entrypoint name: the key value + /// in an item in the customActions section of the config file. + /// Returned display name of the assembly from + /// the entrypoint mapping. + /// Returned class name of the entrypoint mapping. + /// Returned method name of the entrypoint mapping. + /// True if the entrypoint was found, false if not or if some error + /// occurred. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + private static bool FindEntryPoint( + Session session, + string entryPoint, + out string assemblyName, + out string className, + out string methodName) + { + assemblyName = null; + className = null; + methodName = null; + + string fullEntryPoint; + if (entryPoint.IndexOf('!') > 0) + { + fullEntryPoint = entryPoint; + } + else + { +#if NET20 + IDictionary config; + try + { + config = (IDictionary) ConfigurationManager.GetSection("customActions"); + } + catch (ConfigurationException cex) + { + session.Log("Error: missing or invalid customActions config section."); + session.Log(cex.ToString()); + return false; + } + fullEntryPoint = (string) config[entryPoint]; + if (fullEntryPoint == null) + { + session.Log( + "Error: custom action entry point '{0}' not found " + + "in customActions config section.", + entryPoint); + return false; + } +#else + throw new NotImplementedException(); +#endif + } + + int assemblySplit = fullEntryPoint.IndexOf('!'); + int methodSplit = fullEntryPoint.LastIndexOf('.'); + if (assemblySplit < 0 || methodSplit < 0 || methodSplit < assemblySplit) + { + session.Log("Error: invalid custom action entry point:" + entryPoint); + return false; + } + + assemblyName = fullEntryPoint.Substring(0, assemblySplit); + className = fullEntryPoint.Substring(assemblySplit + 1, methodSplit - assemblySplit - 1); + methodName = fullEntryPoint.Substring(methodSplit + 1); + return true; + } + + /// + /// Uses reflection to load the assembly and class and find the method. + /// + /// Installer session handle, just used for logging. + /// Display name of the assembly containing the + /// custom action method. + /// Fully-qualified name of the class containing the + /// custom action method. + /// Name of the custom action method. + /// The method, or null if not found. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + private static MethodInfo GetCustomActionMethod( + Session session, + string assemblyName, + string className, + string methodName) + { + Assembly customActionAssembly; + Type customActionClass = null; + Exception caughtEx = null; + try + { + customActionAssembly = AppDomain.CurrentDomain.Load(assemblyName); + customActionClass = customActionAssembly.GetType(className, true, true); + } + catch (IOException ex) { caughtEx = ex; } + catch (BadImageFormatException ex) { caughtEx = ex; } + catch (TypeLoadException ex) { caughtEx = ex; } + catch (ReflectionTypeLoadException ex) { caughtEx = ex; } + catch (SecurityException ex) { caughtEx = ex; } + if (caughtEx != null) + { + session.Log("Error: could not load custom action class " + className + " from assembly: " + assemblyName); + session.Log(caughtEx.ToString()); + return null; + } + + MethodInfo[] methods = customActionClass.GetMethods( + BindingFlags.Public | BindingFlags.Static); + foreach (MethodInfo method in methods) + { + if (method.Name == methodName && + CustomActionProxy.MethodHasCustomActionSignature(method)) + { + return method; + } + } + session.Log("Error: custom action method \"" + methodName + + "\" is missing or has the wrong signature."); + return null; + } + + /// + /// Checks if a method has the right return and paramater types + /// for a custom action, and that it is marked by a CustomActionAttribute. + /// + /// Method to be checked. + /// True if the method is a valid custom action, else false. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + private static bool MethodHasCustomActionSignature(MethodInfo method) + { + if (method.ReturnType == typeof(ActionResult) && + method.GetParameters().Length == 1 && + method.GetParameters()[0].ParameterType == typeof(Session)) + { + object[] methodAttribs = method.GetCustomAttributes(false); + foreach (object attrib in methodAttribs) + { + if (attrib is CustomActionAttribute) + { + return true; + } + } + } + return false; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Database.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Database.cs new file mode 100644 index 00000000..09627f4b --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Database.cs @@ -0,0 +1,933 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// Accesses a Windows Installer database. + /// + ///

+ /// The method must be called before the Database is closed to write out all + /// persistent changes. If the Commit method is not called, the installer performs an implicit + /// rollback upon object destruction. + ///

+ /// The client can use the following procedure for data access: + /// Obtain a Database object using one of the Database constructors. + /// Initiate a query using a SQL string by calling the + /// method of the Database. + /// Set query parameters in a and execute the database + /// query by calling the method of the . This + /// produces a result that can be fetched or updated. + /// Call the method of the View repeatedly to return + /// Records. + /// Update database rows of a Record object obtained by the Fetch method using + /// one of the methods of the View. + /// Release the query and any unfetched records by calling the + /// method of the View. + /// Persist any database updates by calling the Commit method of the Database. + /// + /// + ///

+ public partial class Database : InstallerHandle + { + private string filePath; + private DatabaseOpenMode openMode; + private SummaryInfo summaryInfo; + private TableCollection tables; + private IList deleteOnClose; + + /// + /// Opens an existing database in read-only mode. + /// + /// Path to the database file. + /// the database could not be created/opened + ///

+ /// Because this constructor initiates database access, it cannot be used with a + /// running installation. + ///

+ /// The Database object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiOpenDatabase + ///

+ public Database(string filePath) + : this(filePath, DatabaseOpenMode.ReadOnly) + { + } + + /// + /// Opens an existing database with another database as output. + /// + /// Path to the database to be read. + /// Open mode for the database + /// Database object representing the created or opened database + /// the database could not be created/opened + ///

+ /// When a database is opened as the output of another database, the summary information stream + /// of the output database is actually a read-only mirror of the original database and thus cannot + /// be changed. Additionally, it is not persisted with the database. To create or modify the + /// summary information for the output database it must be closed and re-opened. + ///

+ /// The Database object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// The database is opened in mode, and will be + /// automatically commited when it is closed. + ///

+ /// Win32 MSI API: + /// MsiOpenDatabase + ///

+ public Database(string filePath, string outputPath) + : this((IntPtr) Database.Open(filePath, outputPath), true, outputPath, DatabaseOpenMode.CreateDirect) + { + } + + /// + /// Opens an existing database or creates a new one. + /// + /// Path to the database file. If an empty string + /// is supplied, a temporary database is created that is not persisted. + /// Open mode for the database + /// the database could not be created/opened + ///

+ /// Because this constructor initiates database access, it cannot be used with a + /// running installation. + ///

+ /// The database object should be d after use. + /// The finalizer will close the handle if it is still open, however due to the nondeterministic + /// nature of finalization it is best that the handle be closed manually as soon as it is no + /// longer needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// A database opened in or + /// mode will be automatically commited when it is + /// closed. However a database opened in or + /// mode must have the method + /// called before it is closed, otherwise no changes will be persisted. + ///

+ /// Win32 MSI API: + /// MsiOpenDatabase + ///

+ public Database(string filePath, DatabaseOpenMode mode) + : this((IntPtr) Database.Open(filePath, mode), true, filePath, mode) + { + } + + /// + /// Creates a new database from an MSI handle. + /// + /// Native MSI database handle. + /// True if the handle should be closed + /// when the database object is disposed + /// Path of the database file, if known + /// Mode the handle was originally opened in + protected internal Database( + IntPtr handle, bool ownsHandle, string filePath, DatabaseOpenMode openMode) + : base(handle, ownsHandle) + { + this.filePath = filePath; + this.openMode = openMode; + } + + /// + /// Gets the file path the Database was originally opened from, or null if not known. + /// + public String FilePath + { + get + { + return this.filePath; + } + } + + /// + /// Gets the open mode for the database. + /// + public DatabaseOpenMode OpenMode + { + get + { + return this.openMode; + } + } + + /// + /// Gets a boolean value indicating whether this database was opened in read-only mode. + /// + ///

+ /// Win32 MSI API: + /// MsiGetDatabaseState + ///

+ public bool IsReadOnly + { + get + { + if (RemotableNativeMethods.RemotingEnabled) + { + return true; + } + + int state = NativeMethods.MsiGetDatabaseState((int) this.Handle); + return state != 1; + } + } + + /// + /// Gets the collection of tables in the Database. + /// + public TableCollection Tables + { + get + { + if (this.tables == null) + { + this.tables = new TableCollection(this); + } + return this.tables; + } + } + + /// + /// Gets or sets the code page of the Database. + /// + /// error exporting/importing the codepage data + /// the Database handle is invalid + ///

+ /// Getting or setting the code page is a slow operation because it involves an export or import + /// of the codepage data to/from a temporary file. + ///

+ public int CodePage + { + get + { + string tempFile = Path.GetTempFileName(); + StreamReader reader = null; + try + { + this.Export("_ForceCodepage", tempFile); + reader = File.OpenText(tempFile); + reader.ReadLine(); // Skip column name record. + reader.ReadLine(); // Skip column defn record. + string codePageLine = reader.ReadLine(); + return Int32.Parse(codePageLine.Split('\t')[0], CultureInfo.InvariantCulture.NumberFormat); + } + finally + { + if (reader != null) reader.Close(); + File.Delete(tempFile); + } + } + + set + { + string tempFile = Path.GetTempFileName(); + StreamWriter writer = null; + try + { + writer = File.AppendText(tempFile); + writer.WriteLine(""); + writer.WriteLine(""); + writer.WriteLine("{0}\t_ForceCodepage", value); + writer.Close(); + writer = null; + this.Import(tempFile); + } + finally + { + if (writer != null) writer.Close(); + File.Delete(tempFile); + } + } + } + + /// + /// Gets the SummaryInfo object for this database that can be used to examine and modify properties + /// to the summary information stream. + /// + /// the Database handle is invalid + ///

+ /// The object returned from this property does not need to be explicitly persisted or closed. + /// Any modifications will be automatically saved when the database is committed. + ///

+ /// Win32 MSI API: + /// MsiGetSummaryInformation + ///

+ public SummaryInfo SummaryInfo + { + get + { + if (this.summaryInfo == null || this.summaryInfo.IsClosed) + { + lock (this.Sync) + { + if (this.summaryInfo == null || this.summaryInfo.IsClosed) + { + int summaryInfoHandle; + int maxProperties = this.IsReadOnly ? 0 : SummaryInfo.MAX_PROPERTIES; + uint ret = RemotableNativeMethods.MsiGetSummaryInformation((int) this.Handle, null, (uint) maxProperties, out summaryInfoHandle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + this.summaryInfo = new SummaryInfo((IntPtr) summaryInfoHandle, true); + } + } + } + return this.summaryInfo; + } + } + + /// + /// Creates a new Database object from an integer database handle. + /// + ///

+ /// This method is only provided for interop purposes. A Database object + /// should normally be obtained from or + /// a public Database constructor. + ///

+ /// Integer database handle + /// true to close the handle when this object is disposed + public static Database FromHandle(IntPtr handle, bool ownsHandle) + { + return new Database( + handle, + ownsHandle, + null, + NativeMethods.MsiGetDatabaseState((int) handle) == 1 ? DatabaseOpenMode.Direct : DatabaseOpenMode.ReadOnly); + } + + /// + /// Schedules a file or directory for deletion after the database handle is closed. + /// + /// File or directory path to be deleted. All files and subdirectories + /// under a directory are deleted. + ///

+ /// Once an item is scheduled, it cannot be unscheduled. + ///

+ /// The items cannot be deleted if the Database object is auto-disposed by the + /// garbage collector; the handle must be explicitly closed. + ///

+ /// Files which are read-only or otherwise locked cannot be deleted, + /// but they will not cause an exception to be thrown. + ///

+ public void DeleteOnClose(string path) + { + if (this.deleteOnClose == null) + { + this.deleteOnClose = new List(); + } + this.deleteOnClose.Add(path); + } + + /// + /// Merges another database with this database. + /// + /// The database to be merged into this database + /// Optional name of table to contain the names of the tables containing + /// merge conflicts, the number of conflicting rows within the table, and a reference to the table + /// with the merge conflict. + /// merge failed due to a schema difference or data conflict + /// the Database handle is invalid + ///

+ /// Merge does not copy over embedded cabinet files or embedded transforms from the + /// reference database into the target database. Embedded data streams that are listed in the + /// Binary table or Icon table are copied from the reference database to the target database. + /// Storage embedded in the reference database are not copied to the target database. + ///

+ /// The Merge method merges the data of two databases. These databases must have the same + /// codepage. The merge fails if any tables or rows in the databases conflict. A conflict exists + /// if the data in any row in the first database differs from the data in the corresponding row + /// of the second database. Corresponding rows are in the same table of both databases and have + /// the same primary key in both databases. The tables of non-conflicting databases must have + /// the same number of primary keys, same number of columns, same column types, same column names, + /// and the same data in rows with identical primary keys. Temporary columns however don't matter + /// in the column count and corresponding tables can have a different number of temporary columns + /// without creating conflict as long as the persistent columns match. + ///

+ /// If the number, type, or name of columns in corresponding tables are different, the + /// schema of the two databases are incompatible and the installer will stop processing tables + /// and the merge fails. The installer checks that the two databases have the same schema before + /// checking for row merge conflicts. If the schemas are incompatible, the databases have be + /// modified. + ///

+ /// If the data in particular rows differ, this is a row merge conflict, the merge fails + /// and creates a new table with the specified name. The first column of this table is the name + /// of the table having the conflict. The second column gives the number of rows in the table + /// having the conflict. + ///

+ /// Win32 MSI API: + /// MsiDatabaseMerge + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public void Merge(Database otherDatabase, string errorTable) + { + if (otherDatabase == null) + { + throw new ArgumentNullException("otherDatabase"); + } + + uint ret = NativeMethods.MsiDatabaseMerge((int) this.Handle, (int) otherDatabase.Handle, errorTable); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.FUNCTION_FAILED) + { + throw new MergeException(this, errorTable); + } + else if (ret == (uint) NativeMethods.Error.DATATYPE_MISMATCH) + { + throw new MergeException("Schema difference between the two databases."); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Merges another database with this database. + /// + /// The database to be merged into this database + /// merge failed due to a schema difference or data conflict + /// the Database handle is invalid + ///

+ /// MsiDatabaseMerge does not copy over embedded cabinet files or embedded transforms from + /// the reference database into the target database. Embedded data streams that are listed in + /// the Binary table or Icon table are copied from the reference database to the target database. + /// Storage embedded in the reference database are not copied to the target database. + ///

+ /// The Merge method merges the data of two databases. These databases must have the same + /// codepage. The merge fails if any tables or rows in the databases conflict. A conflict exists + /// if the data in any row in the first database differs from the data in the corresponding row + /// of the second database. Corresponding rows are in the same table of both databases and have + /// the same primary key in both databases. The tables of non-conflicting databases must have + /// the same number of primary keys, same number of columns, same column types, same column names, + /// and the same data in rows with identical primary keys. Temporary columns however don't matter + /// in the column count and corresponding tables can have a different number of temporary columns + /// without creating conflict as long as the persistent columns match. + ///

+ /// If the number, type, or name of columns in corresponding tables are different, the + /// schema of the two databases are incompatible and the installer will stop processing tables + /// and the merge fails. The installer checks that the two databases have the same schema before + /// checking for row merge conflicts. If the schemas are incompatible, the databases have be + /// modified. + ///

+ /// Win32 MSI API: + /// MsiDatabaseMerge + ///

+ public void Merge(Database otherDatabase) { this.Merge(otherDatabase, null); } + + /// + /// Checks whether a table exists and is persistent in the database. + /// + /// The table to the checked + /// true if the table exists and is persistent in the database; false otherwise + /// the table is unknown + /// the Database handle is invalid + ///

+ /// To check whether a table exists regardless of persistence, + /// use . + ///

+ /// Win32 MSI API: + /// MsiDatabaseIsTablePersistent + ///

+ public bool IsTablePersistent(string table) + { + if (String.IsNullOrEmpty(table)) + { + throw new ArgumentNullException("table"); + } + uint ret = RemotableNativeMethods.MsiDatabaseIsTablePersistent((int) this.Handle, table); + if (ret == 3) // MSICONDITION_ERROR + { + throw new InstallerException(); + } + return ret == 1; + } + + /// + /// Checks whether a table contains a persistent column with a given name. + /// + /// The table to the checked + /// The name of the column to be checked + /// true if the column exists in the table; false if the column is temporary or does not exist. + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// To check whether a column exists regardless of persistence, + /// use . + ///

+ public bool IsColumnPersistent(string table, string column) + { + if (String.IsNullOrEmpty(table)) + { + throw new ArgumentNullException("table"); + } + if (String.IsNullOrEmpty(column)) + { + throw new ArgumentNullException("column"); + } + using (View view = this.OpenView( + "SELECT `Number` FROM `_Columns` WHERE `Table` = '{0}' AND `Name` = '{1}'", table, column)) + { + view.Execute(); + using (Record rec = view.Fetch()) + { + return (rec != null); + } + } + } + + /// + /// Gets the count of all rows in the table. + /// + /// Name of the table whose rows are to be counted + /// The count of all rows in the table + /// the View could not be executed + /// the Database handle is invalid + public int CountRows(string table) + { + return this.CountRows(table, null); + } + + /// + /// Gets the count of all rows in the table that satisfy a given condition. + /// + /// Name of the table whose rows are to be counted + /// Conditional expression, such as could be placed on the end of a SQL WHERE clause + /// The count of all rows in the table satisfying the condition + /// the SQL WHERE syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + public int CountRows(string table, string where) + { + if (String.IsNullOrEmpty(table)) + { + throw new ArgumentNullException("table"); + } + + // to support temporary tables like _Streams, run the query even if the table isn't persistent + TableInfo tableInfo = this.Tables[table]; + string primaryKeys = tableInfo == null ? "*" : String.Concat("`", tableInfo.PrimaryKeys[0], "`"); + int count; + + try + { + using (View view = this.OpenView( + "SELECT {0} FROM `{1}`{2}", + primaryKeys, + table, + (where != null && where.Length != 0 ? " WHERE " + where : ""))) + { + view.Execute(); + for (count = 0; ; count++) + { + // Avoid creating unnecessary Record objects by not calling View.Fetch(). + int recordHandle; + uint ret = RemotableNativeMethods.MsiViewFetch((int)view.Handle, out recordHandle); + if (ret == (uint)NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + RemotableNativeMethods.MsiCloseHandle(recordHandle); + } + } + } + catch (BadQuerySyntaxException) + { + // table was missing + count = 0; + } + + return count; + } + + /// + /// Finalizes the persistent form of the database. All persistent data is written + /// to the writeable database, and no temporary columns or rows are written. + /// + /// the Database handle is invalid + ///

+ /// For a database open in mode, this method has no effect. + ///

+ /// For a database open in or + /// mode, it is not necessary to call this method because the database will be automatically committed + /// when it is closed. However this method may be called at any time to persist the current state of tables + /// loaded into memory. + ///

+ /// For a database open in or + /// mode, no changes will be persisted until this method is called. If the database object is closed without + /// calling this method, the database file remains unmodified. + ///

+ /// Win32 MSI API: + /// MsiDatabaseCommit + ///

+ public void Commit() + { + if (this.summaryInfo != null && !this.summaryInfo.IsClosed) + { + this.summaryInfo.Persist(); + this.summaryInfo.Close(); + this.summaryInfo = null; + } + uint ret = NativeMethods.MsiDatabaseCommit((int) this.Handle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Copies the structure and data from a specified table to a text archive file. + /// + /// Name of the table to be exported + /// Path to the file to be created + /// the file path is invalid + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseExport + ///

+ public void Export(string table, string exportFilePath) + { + if (table == null) + { + throw new ArgumentNullException("table"); + } + + FileInfo file = new FileInfo(exportFilePath); + uint ret = NativeMethods.MsiDatabaseExport((int) this.Handle, table, file.DirectoryName, file.Name); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.BAD_PATHNAME) + { + throw new FileNotFoundException(null, exportFilePath); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Imports a database table from a text archive file, dropping any existing table. + /// + /// Path to the file to be imported. + /// The table name is specified within the file. + /// the file path is invalid + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseImport + ///

+ public void Import(string importFilePath) + { + if (String.IsNullOrEmpty(importFilePath)) + { + throw new ArgumentNullException("importFilePath"); + } + + FileInfo file = new FileInfo(importFilePath); + uint ret = NativeMethods.MsiDatabaseImport((int) this.Handle, file.DirectoryName, file.Name); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.BAD_PATHNAME) + { + throw new FileNotFoundException(null, importFilePath); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Exports all database tables, streams, and summary information to archive files. + /// + /// Path to the directory where archive files will be created + /// the directory path is invalid + /// the Database handle is invalid + ///

+ /// The directory will be created if it does not already exist. + ///

+ /// Win32 MSI API: + /// MsiDatabaseExport + ///

+ public void ExportAll(string directoryPath) + { + if (String.IsNullOrEmpty(directoryPath)) + { + throw new ArgumentNullException("directoryPath"); + } + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + this.Export("_SummaryInformation", Path.Combine(directoryPath, "_SummaryInformation.idt")); + + using (View view = this.OpenView("SELECT `Name` FROM `_Tables`")) + { + view.Execute(); + + foreach (Record rec in view) using (rec) + { + string table = (string) rec[1]; + + this.Export(table, Path.Combine(directoryPath, table + ".idt")); + } + } + + if (!Directory.Exists(Path.Combine(directoryPath, "_Streams"))) + { + Directory.CreateDirectory(Path.Combine(directoryPath, "_Streams")); + } + + using (View view = this.OpenView("SELECT `Name`, `Data` FROM `_Streams`")) + { + view.Execute(); + + foreach (Record rec in view) using (rec) + { + string stream = (string) rec[1]; + if (stream.EndsWith("SummaryInformation", StringComparison.Ordinal)) continue; + + int i = stream.IndexOf('.'); + if (i >= 0) + { + if (File.Exists(Path.Combine( + directoryPath, + Path.Combine(stream.Substring(0, i), stream.Substring(i + 1) + ".ibd")))) + { + continue; + } + } + rec.GetStream(2, Path.Combine(directoryPath, Path.Combine("_Streams", stream))); + } + } + } + + /// + /// Imports all database tables, streams, and summary information from archive files. + /// + /// Path to the directory from which archive files will be imported + /// the directory path is invalid + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseImport + ///

+ public void ImportAll(string directoryPath) + { + if (String.IsNullOrEmpty(directoryPath)) + { + throw new ArgumentNullException("directoryPath"); + } + + if (File.Exists(Path.Combine(directoryPath, "_SummaryInformation.idt"))) + { + this.Import(Path.Combine(directoryPath, "_SummaryInformation.idt")); + } + + string[] idtFiles = Directory.GetFiles(directoryPath, "*.idt"); + foreach (string file in idtFiles) + { + if (Path.GetFileName(file) != "_SummaryInformation.idt") + { + this.Import(file); + } + } + + if (Directory.Exists(Path.Combine(directoryPath, "_Streams"))) + { + View view = this.OpenView("SELECT `Name`, `Data` FROM `_Streams`"); + Record rec = null; + try + { + view.Execute(); + string[] streamFiles = Directory.GetFiles(Path.Combine(directoryPath, "_Streams")); + foreach (string file in streamFiles) + { + rec = this.CreateRecord(2); + rec[1] = Path.GetFileName(file); + rec.SetStream(2, file); + view.Insert(rec); + rec.Close(); + rec = null; + } + } + finally + { + if (rec != null) rec.Close(); + view.Close(); + } + } + } + + /// + /// Creates a new record object with the requested number of fields. + /// + /// Required number of fields, which may be 0. + /// The maximum number of fields in a record is limited to 65535. + /// A new record object that can be used with the database. + ///

+ /// This method is equivalent to directly calling the + /// constructor in all cases outside of a custom action context. When in a + /// custom action session, this method allows creation of a record that can + /// work with a database other than the session database. + ///

+ /// The Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiCreateRecord + ///

+ public Record CreateRecord(int fieldCount) + { + int hRecord = RemotableNativeMethods.MsiCreateRecord((uint) fieldCount, (int) this.Handle); + return new Record((IntPtr) hRecord, true, (View) null); + } + + /// + /// Returns the file path of this database, or the handle value if a file path was not specified. + /// + public override string ToString() + { + if (this.FilePath != null) + { + return this.FilePath; + } + else + { + return "#" + ((int) this.Handle).ToString(CultureInfo.InvariantCulture); + } + } + + /// + /// Closes the database handle. After closing a handle, further method calls may throw . + /// + /// If true, the method has been called directly or + /// indirectly by a user's code, so managed and unmanaged resources will be + /// disposed. If false, only unmanaged resources will be disposed. + protected override void Dispose(bool disposing) + { + if (!this.IsClosed && + (this.OpenMode == DatabaseOpenMode.CreateDirect || + this.OpenMode == DatabaseOpenMode.Direct)) + { + // Always commit a direct-opened database before closing. + // This avoids unexpected corruption of the database. + this.Commit(); + } + + base.Dispose(disposing); + + if (disposing) + { + if (this.summaryInfo != null) + { + this.summaryInfo.Close(); + this.summaryInfo = null; + } + + if (this.deleteOnClose != null) + { + foreach (string path in this.deleteOnClose) + { + try + { + if (Directory.Exists(path)) + { + Directory.Delete(path, true); + } + else + { + if (File.Exists(path)) File.Delete(path); + } + } + catch (IOException) + { + } + catch (UnauthorizedAccessException) + { + } + } + this.deleteOnClose = null; + } + } + } + + private static int Open(string filePath, string outputPath) + { + if (String.IsNullOrEmpty(filePath)) + { + throw new ArgumentNullException("filePath"); + } + + if (String.IsNullOrEmpty(outputPath)) + { + throw new ArgumentNullException("outputPath"); + } + + int hDb; + uint ret = NativeMethods.MsiOpenDatabase(filePath, outputPath, out hDb); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return hDb; + } + + private static int Open(string filePath, DatabaseOpenMode mode) + { + if (String.IsNullOrEmpty(filePath)) + { + throw new ArgumentNullException("filePath"); + } + + if (Path.GetExtension(filePath).Equals(".msp", StringComparison.Ordinal)) + { + const int DATABASEOPENMODE_PATCH = 32; + int patchMode = (int) mode | DATABASEOPENMODE_PATCH; + mode = (DatabaseOpenMode) patchMode; + } + + int hDb; + uint ret = NativeMethods.MsiOpenDatabase(filePath, (IntPtr) mode, out hDb); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode( + ret, + String.Format(CultureInfo.InvariantCulture, "Database=\"{0}\"", filePath)); + } + return hDb; + } + + /// + /// Returns the value of the specified property. + /// + /// Name of the property to retrieve. + public string ExecutePropertyQuery(string property) + { + IList values = this.ExecuteStringQuery("SELECT `Value` FROM `Property` WHERE `Property` = '{0}'", property); + return (values.Count > 0 ? values[0] : null); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseQuery.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseQuery.cs new file mode 100644 index 00000000..7c9e011e --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseQuery.cs @@ -0,0 +1,412 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + public partial class Database + { + /// + /// Gets a View object representing the query specified by a SQL string. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// A View object representing the query specified by a SQL string + /// the SQL syntax is invalid + /// the Database handle is invalid + ///

+ /// The parameter is formatted using . + ///

+ /// The View object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiDatabaseOpenView + ///

+ public View OpenView(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + string sql = (args == null || args.Length == 0 ? sqlFormat : + String.Format(CultureInfo.InvariantCulture, sqlFormat, args)); + int viewHandle; + uint ret = RemotableNativeMethods.MsiDatabaseOpenView((int) this.Handle, sql, out viewHandle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + return new View((IntPtr) viewHandle, sql, this); + } + + /// + /// Executes the query specified by a SQL string. The query may not be a SELECT statement. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// The parameter is formatted using + /// . + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute + ///

+ public void Execute(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + this.Execute( + args == null || args.Length == 0 ? + sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args), + (Record) null); + } + + /// + /// Executes the query specified by a SQL string. The query may not be a SELECT statement. + /// + /// SQL query string + /// Optional Record object containing the values that replace + /// the parameter tokens (?) in the SQL query. + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute + ///

+ public void Execute(string sql, Record record) + { + if (String.IsNullOrEmpty(sql)) + { + throw new ArgumentNullException("sql"); + } + + using (View view = this.OpenView(sql)) + { + view.Execute(record); + } + } + + /// + /// Executes the specified SQL SELECT query and returns all results. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// The parameter is formatted using + /// . + ///

+ /// Multiple rows columns will be collapsed into a single one-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteQuery(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + return this.ExecuteQuery( + args == null || args.Length == 0 ? + sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args), + (Record) null); + } + + /// + /// Executes the specified SQL SELECT query and returns all results. + /// + /// SQL SELECT query string + /// Optional Record object containing the values that replace + /// the parameter tokens (?) in the SQL query. + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// Multiple rows columns will be collapsed into a single one-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteQuery(string sql, Record record) + { + if (String.IsNullOrEmpty(sql)) + { + throw new ArgumentNullException("sql"); + } + + using (View view = this.OpenView(sql)) + { + view.Execute(record); + IList results = new ArrayList(); + int fieldCount = 0; + + foreach (Record rec in view) using (rec) + { + if (fieldCount == 0) fieldCount = rec.FieldCount; + for (int i = 1; i <= fieldCount; i++) + { + results.Add(rec[i]); + } + } + + return results; + } + } + + /// + /// Executes the specified SQL SELECT query and returns all results as integers. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// The parameter is formatted using + /// . + ///

+ /// Multiple rows columns will be collapsed into a single one-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteIntegerQuery(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + return this.ExecuteIntegerQuery( + args == null || args.Length == 0 ? + sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args), + (Record) null); + } + + /// + /// Executes the specified SQL SELECT query and returns all results as integers. + /// + /// SQL SELECT query string + /// Optional Record object containing the values that replace + /// the parameter tokens (?) in the SQL query. + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// Multiple rows columns will be collapsed into a single one-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteIntegerQuery(string sql, Record record) + { + if (String.IsNullOrEmpty(sql)) + { + throw new ArgumentNullException("sql"); + } + + using (View view = this.OpenView(sql)) + { + view.Execute(record); + IList results = new List(); + int fieldCount = 0; + + foreach (Record rec in view) using (rec) + { + if (fieldCount == 0) fieldCount = rec.FieldCount; + for (int i = 1; i <= fieldCount; i++) + { + results.Add(rec.GetInteger(i)); + } + } + + return results; + } + } + + /// + /// Executes the specified SQL SELECT query and returns all results as strings. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// The parameter is formatted using + /// . + ///

+ /// Multiple rows columns will be collapsed into a single on-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteStringQuery(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + return this.ExecuteStringQuery( + args == null || args.Length == 0 ? + sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args), + (Record) null); + } + + /// + /// Executes the specified SQL SELECT query and returns all results as strings. + /// + /// SQL SELECT query string + /// Optional Record object containing the values that replace + /// the parameter tokens (?) in the SQL query. + /// All results combined into an array + /// the SQL syntax is invalid + /// the View could not be executed + /// the Database handle is invalid + ///

+ /// Multiple rows columns will be collapsed into a single on-dimensional list. + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public IList ExecuteStringQuery(string sql, Record record) + { + if (String.IsNullOrEmpty(sql)) + { + throw new ArgumentNullException("sql"); + } + + using (View view = this.OpenView(sql)) + { + view.Execute(record); + IList results = new List(); + int fieldCount = 0; + + foreach (Record rec in view) using (rec) + { + if (fieldCount == 0) fieldCount = rec.FieldCount; + for (int i = 1; i <= fieldCount; i++) + { + results.Add(rec.GetString(i)); + } + } + + return results; + } + } + + /// + /// Executes the specified SQL SELECT query and returns a single result. + /// + /// SQL query string, which may contain format items + /// Zero or more objects to format + /// First field of the first result + /// the SQL syntax is invalid + /// the View could not be executed + /// or the query returned 0 results + /// the Database handle is invalid + ///

+ /// The parameter is formatted using + /// . + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public object ExecuteScalar(string sqlFormat, params object[] args) + { + if (String.IsNullOrEmpty(sqlFormat)) + { + throw new ArgumentNullException("sqlFormat"); + } + + return this.ExecuteScalar( + args == null || args.Length == 0 ? + sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args), + (Record) null); + } + + /// + /// Executes the specified SQL SELECT query and returns a single result. + /// + /// SQL SELECT query string + /// Optional Record object containing the values that replace + /// the parameter tokens (?) in the SQL query. + /// First field of the first result + /// the SQL syntax is invalid + /// the View could not be executed + /// or the query returned 0 results + /// the Database handle is invalid + ///

+ /// Win32 MSI APIs: + /// MsiDatabaseOpenView, + /// MsiViewExecute, + /// MsiViewFetch + ///

+ public object ExecuteScalar(string sql, Record record) + { + if (String.IsNullOrEmpty(sql)) + { + throw new ArgumentNullException("sql"); + } + + View view = this.OpenView(sql); + Record rec = null; + try + { + view.Execute(record); + rec = view.Fetch(); + if (rec == null) + { + throw InstallerException.ExceptionFromReturnCode((uint) NativeMethods.Error.NO_MORE_ITEMS); + } + return rec[1]; + } + finally + { + if (rec != null) rec.Close(); + view.Close(); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseTransform.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseTransform.cs new file mode 100644 index 00000000..fa843012 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/DatabaseTransform.cs @@ -0,0 +1,278 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + public partial class Database + { + /// + /// Creates a transform that, when applied to the object database, results in the reference database. + /// + /// Database that does not include the changes + /// Name of the generated transform file, or null to only + /// check whether or not the two database are identical + /// true if a transform is generated, or false if a transform is not generated + /// because there are no differences between the two databases. + /// the transform could not be generated + /// a Database handle is invalid + ///

+ /// A transform can add non-primary key columns to the end of a table. A transform cannot + /// be created that adds primary key columns to a table. A transform cannot be created that + /// changes the order, names, or definitions of columns. + ///

+ /// If the transform is to be applied during an installation you must use the + /// method to populate the + /// summary information stream. + ///

+ /// Win32 MSI API: + /// MsiDatabaseGenerateTransform + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public bool GenerateTransform(Database referenceDatabase, string transformFile) + { + if (referenceDatabase == null) + { + throw new ArgumentNullException("referenceDatabase"); + } + + if (String.IsNullOrEmpty(transformFile)) + { + throw new ArgumentNullException("transformFile"); + } + + uint ret = NativeMethods.MsiDatabaseGenerateTransform((int) this.Handle, (int) referenceDatabase.Handle, transformFile, 0, 0); + if (ret == (uint) NativeMethods.Error.NO_DATA) + { + return false; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + /// + /// Creates and populates the summary information stream of an existing transform file, and + /// fills in the properties with the base and reference ProductCode and ProductVersion. + /// + /// Database that does not include the changes + /// Name of the generated transform file + /// Error conditions that should be suppressed + /// when the transform is applied + /// Defines which properties should be validated + /// to verify that this transform can be applied to a database. + /// the transform summary info could not be + /// generated + /// a Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiCreateTransformSummaryInfo + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public void CreateTransformSummaryInfo( + Database referenceDatabase, + string transformFile, + TransformErrors errors, + TransformValidations validations) + { + if (referenceDatabase == null) + { + throw new ArgumentNullException("referenceDatabase"); + } + + if (String.IsNullOrEmpty(transformFile)) + { + throw new ArgumentNullException("transformFile"); + } + + uint ret = NativeMethods.MsiCreateTransformSummaryInfo( + (int) this.Handle, + (int) referenceDatabase.Handle, + transformFile, + (int) errors, + (int) validations); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Apply a transform to the database, recording the changes in the "_TransformView" table. + /// + /// Path to the transform file + /// the transform could not be applied + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseApplyTransform + ///

+ public void ViewTransform(string transformFile) + { + TransformErrors transformErrors = + TransformErrors.AddExistingRow | + TransformErrors.DelMissingRow | + TransformErrors.AddExistingTable | + TransformErrors.DelMissingTable | + TransformErrors.UpdateMissingRow | + TransformErrors.ChangeCodePage | + TransformErrors.ViewTransform; + this.ApplyTransform(transformFile, transformErrors); + } + + /// + /// Apply a transform to the database, suppressing any error conditions + /// specified by the transform's summary information. + /// + /// Path to the transform file + /// the transform could not be applied + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseApplyTransform + ///

+ public void ApplyTransform(string transformFile) + { + if (String.IsNullOrEmpty(transformFile)) + { + throw new ArgumentNullException("transformFile"); + } + + TransformErrors errorConditionsToSuppress; + using (SummaryInfo transformSummInfo = new SummaryInfo(transformFile, false)) + { + int errorConditions = transformSummInfo.CharacterCount & 0xFFFF; + errorConditionsToSuppress = (TransformErrors) errorConditions; + } + this.ApplyTransform(transformFile, errorConditionsToSuppress); + } + + /// + /// Apply a transform to the database, specifying error conditions to suppress. + /// + /// Path to the transform file + /// Error conditions that are to be suppressed + /// the transform could not be applied + /// the Database handle is invalid + ///

+ /// Win32 MSI API: + /// MsiDatabaseApplyTransform + ///

+ public void ApplyTransform(string transformFile, TransformErrors errorConditionsToSuppress) + { + if (String.IsNullOrEmpty(transformFile)) + { + throw new ArgumentNullException("transformFile"); + } + + uint ret = NativeMethods.MsiDatabaseApplyTransform((int) this.Handle, transformFile, (int) errorConditionsToSuppress); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Checks whether a transform is valid for this Database, according to its validation data and flags. + /// + /// Path to the transform file + /// true if the transform can be validly applied to this Database; false otherwise + /// the transform could not be applied + /// the Database handle is invalid + public bool IsTransformValid(string transformFile) + { + if (String.IsNullOrEmpty(transformFile)) + { + throw new ArgumentNullException("transformFile"); + } + + using (SummaryInfo transformSummInfo = new SummaryInfo(transformFile, false)) + { + return this.IsTransformValid(transformSummInfo); + } + } + + /// + /// Checks whether a transform is valid for this Database, according to its SummaryInfo data. + /// + /// SummaryInfo data of a transform file + /// true if the transform can be validly applied to this Database; false otherwise + /// error processing summary info + /// the Database or SummaryInfo handle is invalid + public bool IsTransformValid(SummaryInfo transformSummaryInfo) + { + if (transformSummaryInfo == null) + { + throw new ArgumentNullException("transformSummaryInfo"); + } + + string[] rev = transformSummaryInfo.RevisionNumber.Split(new char[] { ';' }, 3); + string targetProductCode = rev[0].Substring(0, 38); + string targetProductVersion = rev[0].Substring(38); + string upgradeCode = rev[2]; + + string[] templ = transformSummaryInfo.Template.Split(new char[] { ';' }, 2); + int targetProductLanguage = 0; + if (templ.Length >= 2 && templ[1].Length > 0) + { + targetProductLanguage = Int32.Parse(templ[1], CultureInfo.InvariantCulture.NumberFormat); + } + + int flags = transformSummaryInfo.CharacterCount; + int validateFlags = flags >> 16; + + string thisProductCode = this.ExecutePropertyQuery("ProductCode"); + string thisProductVersion = this.ExecutePropertyQuery("ProductVersion"); + string thisUpgradeCode = this.ExecutePropertyQuery("UpgradeCode"); + string thisProductLang = this.ExecutePropertyQuery("ProductLanguage"); + int thisProductLanguage = 0; + if (!String.IsNullOrEmpty(thisProductLang)) + { + thisProductLanguage = Int32.Parse(thisProductLang, CultureInfo.InvariantCulture.NumberFormat); + } + + if ((validateFlags & (int) TransformValidations.Product) != 0 && + thisProductCode != targetProductCode) + { + return false; + } + + if ((validateFlags & (int) TransformValidations.UpgradeCode) != 0 && + thisUpgradeCode != upgradeCode) + { + return false; + } + + if ((validateFlags & (int) TransformValidations.Language) != 0 && + targetProductLanguage != 0 && thisProductLanguage != targetProductLanguage) + { + return false; + } + + Version thisProductVer = new Version(thisProductVersion); + Version targetProductVer = new Version(targetProductVersion); + if ((validateFlags & (int) TransformValidations.UpdateVersion) != 0) + { + if (thisProductVer.Major != targetProductVer.Major) return false; + if (thisProductVer.Minor != targetProductVer.Minor) return false; + if (thisProductVer.Build != targetProductVer.Build) return false; + } + else if ((validateFlags & (int) TransformValidations.MinorVersion) != 0) + { + if (thisProductVer.Major != targetProductVer.Major) return false; + if (thisProductVer.Minor != targetProductVer.Minor) return false; + } + else if ((validateFlags & (int) TransformValidations.MajorVersion) != 0) + { + if (thisProductVer.Major != targetProductVer.Major) return false; + } + + return true; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/EmbeddedUIProxy.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/EmbeddedUIProxy.cs new file mode 100644 index 00000000..05e910d4 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/EmbeddedUIProxy.cs @@ -0,0 +1,231 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections; + using System.Configuration; + using System.Diagnostics.CodeAnalysis; + using System.IO; + using System.Reflection; + using System.Runtime.InteropServices; + using System.Security; + using System.Text; + + /// + /// Managed-code portion of the embedded UI proxy. + /// + internal static class EmbeddedUIProxy + { + private static IEmbeddedUI uiInstance; + private static string uiClass; + + private static bool DebugBreakEnabled(string method) + { + return CustomActionProxy.DebugBreakEnabled(new string[] { method, EmbeddedUIProxy.uiClass + "." + method } ); + } + + /// + /// Initializes managed embedded UI by loading the UI class and invoking its Initialize method. + /// + /// Integer handle to the installer session. + /// Name of the class that implements the embedded UI. This must + /// be of the form: "AssemblyName!Namespace.Class" + /// On entry, contains the current UI level for the installation. After this + /// method returns, the installer resets the UI level to the returned value of this parameter. + /// 0 if the embedded UI was successfully loaded and initialized, + /// ERROR_INSTALL_USEREXIT if the user canceled the installation during initialization, + /// or ERROR_INSTALL_FAILURE if the embedded UI could not be initialized. + /// + /// Due to interop limitations, the successful resulting UILevel is actually returned + /// as the high-word of the return value instead of via a ref parameter. + /// + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static int Initialize(int sessionHandle, string uiClass, int internalUILevel) + { + Session session = null; + + try + { + session = new Session((IntPtr) sessionHandle, false); + + if (String.IsNullOrEmpty(uiClass)) + { + throw new ArgumentNullException("uiClass"); + } + + EmbeddedUIProxy.uiInstance = EmbeddedUIProxy.InstantiateUI(session, uiClass); + } + catch (Exception ex) + { + if (session != null) + { + try + { + session.Log("Exception while loading embedded UI:"); + session.Log(ex.ToString()); + } + catch (Exception) + { + } + } + } + + if (EmbeddedUIProxy.uiInstance == null) + { + return (int) ActionResult.Failure; + } + + try + { + string resourcePath = Path.GetDirectoryName(EmbeddedUIProxy.uiInstance.GetType().Assembly.Location); + InstallUIOptions uiOptions = (InstallUIOptions) internalUILevel; + if (EmbeddedUIProxy.DebugBreakEnabled("Initialize")) + { + System.Diagnostics.Debugger.Launch(); + } + + if (EmbeddedUIProxy.uiInstance.Initialize(session, resourcePath, ref uiOptions)) + { + // The embedded UI initialized and the installation should continue + // with internal UI reset according to options. + return ((int) uiOptions) << 16; + } + else + { + // The embedded UI did not initialize but the installation should still continue + // with internal UI reset according to options. + return (int) uiOptions; + } + } + catch (InstallCanceledException) + { + // The installation was canceled by the user. + return (int) ActionResult.UserExit; + } + catch (Exception ex) + { + // An unhandled exception causes the installation to fail immediately. + session.Log("Exception thrown by embedded UI initialization:"); + session.Log(ex.ToString()); + return (int) ActionResult.Failure; + } + } + + /// + /// Passes a progress message to the UI class. + /// + /// Installer message type and message box options. + /// Handle to a record containing message data. + /// Return value returned by the UI class. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + public static int ProcessMessage(int messageType, int recordHandle) + { + if (EmbeddedUIProxy.uiInstance != null) + { + try + { + int msgType = messageType & 0x7F000000; + int buttons = messageType & 0x0000000F; + int icon = messageType & 0x000000F0; + int defButton = messageType & 0x00000F00; + + Record msgRec = (recordHandle != 0 ? Record.FromHandle((IntPtr) recordHandle, false) : null); + using (msgRec) + { + if (EmbeddedUIProxy.DebugBreakEnabled("ProcessMessage")) + { + System.Diagnostics.Debugger.Launch(); + } + + return (int) EmbeddedUIProxy.uiInstance.ProcessMessage( + (InstallMessage) msgType, + msgRec, + (MessageButtons) buttons, + (MessageIcon) icon, + (MessageDefaultButton) defButton); + } + } + catch (Exception) + { + // Ignore it... just hope future messages will not throw exceptions. + } + } + + return 0; + } + + /// + /// Passes a shutdown message to the UI class. + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + public static void Shutdown() + { + if (EmbeddedUIProxy.uiInstance != null) + { + try + { + if (EmbeddedUIProxy.DebugBreakEnabled("Shutdown")) + { + System.Diagnostics.Debugger.Launch(); + } + + EmbeddedUIProxy.uiInstance.Shutdown(); + } + catch (Exception) + { + // Nothing to do at this point... the installation is done anyway. + } + + EmbeddedUIProxy.uiInstance = null; + } + } + + /// + /// Instantiates a UI class from a given assembly and class name. + /// + /// Installer session, for logging. + /// Name of the class that implements the embedded UI. This must + /// be of the form: "AssemblyName!Namespace.Class" + /// Interface on the UI class for handling UI messages. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + private static IEmbeddedUI InstantiateUI(Session session, string uiClass) + { + int assemblySplit = uiClass.IndexOf('!'); + if (assemblySplit < 0) + { + session.Log("Error: invalid embedded UI assembly and class:" + uiClass); + return null; + } + + string assemblyName = uiClass.Substring(0, assemblySplit); + EmbeddedUIProxy.uiClass = uiClass.Substring(assemblySplit + 1); + + Assembly uiAssembly; + try + { + uiAssembly = AppDomain.CurrentDomain.Load(assemblyName); + + // This calls out to CustomActionProxy.DebugBreakEnabled() directly instead + // of calling EmbeddedUIProxy.DebugBreakEnabled() because we don't compose a + // class.method name for this breakpoint. + if (CustomActionProxy.DebugBreakEnabled(new string[] { "EmbeddedUI" })) + { + System.Diagnostics.Debugger.Launch(); + } + + return (IEmbeddedUI) uiAssembly.CreateInstance(EmbeddedUIProxy.uiClass); + } + catch (Exception ex) + { + session.Log("Error: could not load embedded UI class " + EmbeddedUIProxy.uiClass + " from assembly: " + assemblyName); + session.Log(ex.ToString()); + return null; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Enums.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Enums.cs new file mode 100644 index 00000000..64ed0e7f --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Enums.cs @@ -0,0 +1,909 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Diagnostics.CodeAnalysis; + + // Enumerations are in alphabetical order. + + /// + /// Specifies a return status value for custom actions. + /// + public enum ActionResult : int + { + /// Action completed successfully. + Success = 0, + + /// Skip remaining actions, not an error. + SkipRemainingActions = 259, + + /// User terminated prematurely. + UserExit = 1602, + + /// Unrecoverable error or unhandled exception occurred. + Failure = 1603, + + /// Action not executed. + NotExecuted = 1626, + } + + /// + /// Specifies the open mode for a . + /// + public enum DatabaseOpenMode : int + { + /// Open a database read-only, no persistent changes. + ReadOnly = 0, + + /// Open a database read/write in transaction mode. + Transact = 1, + + /// Open a database direct read/write without transaction. + Direct = 2, + + /// Create a new database, transact mode read/write. + Create = 3, + + /// Create a new database, direct mode read/write. + CreateDirect = 4, + } + + /// + /// Log modes available for + /// and . + /// + [Flags] + public enum InstallLogModes : int + { + /// Disable logging. + None = 0, + + /// Log out of memory or fatal exit information. + FatalExit = (1 << ((int) InstallMessage.FatalExit >> 24)), + + /// Log error messages. + Error = (1 << ((int) InstallMessage.Error >> 24)), + + /// Log warning messages. + Warning = (1 << ((int) InstallMessage.Warning >> 24)), + + /// Log user requests. + User = (1 << ((int) InstallMessage.User >> 24)), + + /// Log status messages that are not displayed. + Info = (1 << ((int) InstallMessage.Info >> 24)), + + /// Log request to determine a valid source location. + ResolveSource = (1 << ((int) InstallMessage.ResolveSource >> 24)), + + /// Log insufficient disk space error. + OutOfDiskSpace = (1 << ((int) InstallMessage.OutOfDiskSpace >> 24)), + + /// Log the start of installation actions. + ActionStart = (1 << ((int) InstallMessage.ActionStart >> 24)), + + /// Log the data record for installation actions. + ActionData = (1 << ((int) InstallMessage.ActionData >> 24)), + + /// Log parameters for user-interface initialization. + CommonData = (1 << ((int) InstallMessage.CommonData >> 24)), + + /// Log the property values at termination. + PropertyDump = (1 << ((int) InstallMessage.Progress >> 24)), // log only + + /// + /// Sends large amounts of information to log file not generally useful to users. + /// May be used for support. + /// + Verbose = (1 << ((int) InstallMessage.Initialize >> 24)), // log only + + /// + /// Log extra debugging information. + /// + ExtraDebug = (1 << ((int) InstallMessage.Terminate >> 24)), // log only + + /// + /// Log only on error. + /// + LogOnlyOnError = (1 << ((int) InstallMessage.ShowDialog >> 24)), // log only + + /// + /// Log progress bar information. This message includes information on units so far and total number + /// of units. See for an explanation of the message format. This message + /// is only sent to an external user interface and is not logged. + /// + Progress = (1 << ((int) InstallMessage.Progress >> 24)), // external handler only + + /// + /// If this is not a quiet installation, then the basic UI has been initialized. If this is a full + /// UI installation, the Full UI is not yet initialized. This message is only sent to an external + /// user interface and is not logged. + /// + Initialize = (1 << ((int) InstallMessage.Initialize >> 24)), // external handler only + + /// + /// If a full UI is being used, the full UI has ended. If this is not a quiet installation, the basic + /// UI has not yet ended. This message is only sent to an external user interface and is not logged. + /// + Terminate = (1 << ((int) InstallMessage.Terminate >> 24)), // external handler only + + /// + /// Sent prior to display of the Full UI dialog. This message is only sent to an external user + /// interface and is not logged. + /// + ShowDialog = (1 << ((int) InstallMessage.ShowDialog >> 24)), // external handler only + + /// + /// List of files in use that need to be replaced. + /// + FilesInUse = (1 << ((int) InstallMessage.FilesInUse >> 24)), // external handler only + + /// + /// [MSI 4.0] List of apps that the user can request Restart Manager to shut down and restart. + /// + RMFilesInUse = (1 << ((int) InstallMessage.RMFilesInUse >> 24)), // external handler only + } + + /// + /// Type of message to be processed by , + /// , or . + /// + [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] + public enum InstallMessage : int + { + /// Premature termination, possibly fatal OOM. + FatalExit = 0x00000000, + + /// Formatted error message. + Error = 0x01000000, + + /// Formatted warning message. + Warning = 0x02000000, + + /// User request message. + User = 0x03000000, + + /// Informative message for log. + Info = 0x04000000, + + /// List of files in use that need to be replaced. + FilesInUse = 0x05000000, + + /// Request to determine a valid source location. + ResolveSource = 0x06000000, + + /// Insufficient disk space message. + OutOfDiskSpace = 0x07000000, + + /// Start of action: action name & description. + ActionStart = 0x08000000, + + /// Formatted data associated with individual action item. + ActionData = 0x09000000, + + /// Progress gauge info: units so far, total. + Progress = 0x0A000000, + + /// Product info for dialog: language Id, dialog caption. + CommonData = 0x0B000000, + + /// Sent prior to UI initialization, no string data. + Initialize = 0x0C000000, + + /// Sent after UI termination, no string data. + Terminate = 0x0D000000, + + /// Sent prior to display or authored dialog or wizard. + ShowDialog = 0x0E000000, + + /// [MSI 4.0] List of apps that the user can request Restart Manager to shut down and restart. + RMFilesInUse = 0x19000000, + + /// [MSI 4.5] Sent prior to install of a product. + InstallStart = 0x1A000000, + + /// [MSI 4.5] Sent after install of a product. + InstallEnd = 0x1B000000, + } + + /// + /// Specifies the install mode for or . + /// + public enum InstallMode : int + { + /// Provide the component only if the feature's installation state is . + NoSourceResolution = -3, + + /// Only check that the component is registered, without verifying that the key file of the component exists. + NoDetection = -2, + + /// Provide the component only if the feature exists. + Existing = -1, + + /// Provide the component and perform any installation necessary to provide the component. + Default = 0, + } + + /// + /// Specifies the run mode for . + /// + [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] + public enum InstallRunMode : int + { + /// The administrative mode is installing, or the product is installing. + Admin = 0, + + /// The advertisements are installing or the product is installing or updating. + Advertise = 1, + + /// An existing installation is being modified or there is a new installation. + Maintenance = 2, + + /// Rollback is enabled. + RollbackEnabled = 3, + + /// The log file is active. It was enabled prior to the installation session. + LogEnabled = 4, + + /// Execute operations are spooling or they are in the determination phase. + Operations = 5, + + /// A reboot is necessary after a successful installation (settable). + RebootAtEnd = 6, + + /// A reboot is necessary to continue the installation (settable). + RebootNow = 7, + + /// Files from cabinets and Media table files are installing. + Cabinet = 8, + + /// The source LongFileNames is suppressed through the PID_MSISOURCE summary property. + SourceShortNames = 9, + + /// The target LongFileNames is suppressed through the SHORTFILENAMES property. + TargetShortNames = 10, + + // Reserved for future use. + //Reserved11 = 11, + + /// The operating system is Windows 95, Windows 98, or Windows ME. + [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "x")] + Windows9x = 12, + + /// The operating system supports demand installation. + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zaw")] + ZawEnabled = 13, + + // Reserved for future use. + //Reserved14 = 14, + + // Reserved for future use. + //Reserved15 = 15, + + /// A custom action called from install script execution. + Scheduled = 16, + + /// A custom action called from rollback execution script. + Rollback = 17, + + /// A custom action called from commit execution script. + Commit = 18, + } + + /// + /// Installed state of a Component or Feature. + /// + public enum InstallState : int + { + /// The component is disabled. + NotUsed = -7, + + /// The installation configuration data is corrupt. + BadConfig = -6, + + /// The installation is suspended or in progress. + Incomplete = -5, + + /// Component is set to run from source, but source is unavailable. + SourceAbsent = -4, + + /// The buffer overflow is returned. + MoreData = -3, + + /// An invalid parameter was passed to the function. + InvalidArgument = -2, + + /// An unrecognized product or feature name was passed to the function. + Unknown = -1, + + /// The component is broken. + Broken = 0, + + /// The feature is advertised. + Advertised = 1, + + /// The component is being removed. In action state and not settable. + Removed = 1, + + /// The component is not installed, or action state is absent but clients remain. + Absent = 2, + + /// The component is installed on the local drive. + Local = 3, + + /// The component will run from the source, CD, or network. + Source = 4, + + /// The component will be installed in the default location: local or source. + Default = 5, + } + + /// + /// Specifies the type of installation for . + /// + public enum InstallType : int + { + /// Searches system for products to patch. + Default = 0, + + /// Indicates a administrative installation. + NetworkImage = 1, + + /// Indicates a particular instance. + SingleInstance = 2, + } + + /// + /// Level of the installation user interface, specified with + /// . + /// + [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] + [Flags] + public enum InstallUIOptions : int + { + /// Does not change UI level. + NoChange = 0, + + /// Uses Default UI level. + Default = 1, + + /// Silent installation. + Silent = 2, + + /// Simple progress and error handling. + Basic = 3, + + /// Authored UI, wizard dialogs suppressed. + Reduced = 4, + + /// Authored UI with wizards, progress, and errors. + Full = 5, + + /// + /// When combined with the value, the installer does not display + /// the cancel button in the progress dialog. + /// + HideCancel = 0x20, + + /// + /// When combined with the value, the installer displays progress + /// dialog boxes but does not display any modal dialog boxes or error dialog boxes. + /// + ProgressOnly = 0x40, + + /// + /// When combined with another value, the installer displays a modal dialog + /// box at the end of a successful installation or if there has been an error. + /// No dialog box is displayed if the user cancels. + /// + EndDialog = 0x80, + + /// + /// Forces display of the source resolution dialog even if the UI is otherwise silent. + /// + SourceResolutionOnly = 0x100, + + /// + /// [MSI 5.0] Forces display of the UAC dialog even if the UI is otherwise silent. + /// + UacOnly = 0x200, + } + + /// + /// Specifies a return status value for message handlers. These values are returned by + /// , , and . + /// + public enum MessageResult : int + { + /// An error was found in the message handler. + Error = -1, + + /// No action was taken. + None = 0, + + /// IDOK + [SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase")] + OK = 1, + + /// IDCANCEL + Cancel = 2, + + /// IDABORT + Abort = 3, + + /// IDRETRY + Retry = 4, + + /// IDIGNORE + Ignore = 5, + + /// IDYES + Yes = 6, + + /// IDNO + No = 7, + } + + /// + /// Specifies constants defining which buttons to display for a message. This can be cast to + /// the MessageBoxButtons enum in System.Windows.Forms and System.Windows. + /// + public enum MessageButtons + { + /// + /// The message contains an OK button. + /// + OK = 0, + + /// + /// The message contains OK and Cancel buttons. + /// + OKCancel = 1, + + /// + /// The message contains Abort, Retry, and Ignore buttons. + /// + AbortRetryIgnore = 2, + + /// + /// The message contains Yes, No, and Cancel buttons. + /// + YesNoCancel = 3, + + /// + /// The message contains Yes and No buttons. + /// + YesNo = 4, + + /// + /// The message contains Retry and Cancel buttons. + /// + RetryCancel = 5, + } + + /// + /// Specifies constants defining which information to display. This can be cast to + /// the MessageBoxIcon enum in System.Windows.Forms and System.Windows. + /// + public enum MessageIcon + { + /// + /// The message contain no symbols. + /// + None = 0, + + /// + /// The message contains a symbol consisting of white X in a circle with a red background. + /// + Error = 16, + + /// + /// The message contains a symbol consisting of a white X in a circle with a red background. + /// + Hand = 16, + + /// + /// The message contains a symbol consisting of white X in a circle with a red background. + /// + Stop = 16, + + /// + /// The message contains a symbol consisting of a question mark in a circle. + /// + Question = 32, + + /// + /// The message contains a symbol consisting of an exclamation point in a triangle with a yellow background. + /// + Exclamation = 48, + + /// + /// The message contains a symbol consisting of an exclamation point in a triangle with a yellow background. + /// + Warning = 48, + + /// + /// The message contains a symbol consisting of a lowercase letter i in a circle. + /// + Information = 64, + + /// + /// The message contains a symbol consisting of a lowercase letter i in a circle. + /// + Asterisk = 64, + } + + /// + /// Specifies constants defining the default button on a message. This can be cast to + /// the MessageBoxDefaultButton enum in System.Windows.Forms and System.Windows. + /// + public enum MessageDefaultButton + { + /// + /// The first button on the message is the default button. + /// + Button1 = 0, + + /// + /// The second button on the message is the default button. + /// + Button2 = 256, + + /// + /// The third button on the message is the default button. + /// + Button3 = 512, + } + + /// + /// Additional styles for use with message boxes. + /// + [Flags] + internal enum MessageBoxStyles + { + /// + /// The message box is created with the WS_EX_TOPMOST window style. + /// + TopMost = 0x00040000, + + /// + /// The caller is a service notifying the user of an event. + /// The function displays a message box on the current active desktop, even if there is no user logged on to the computer. + /// + ServiceNotification = 0x00200000, + } + + /// + /// Specifies the different patch states for . + /// + [Flags] + public enum PatchStates : int + { + /// Invalid value. + None = 0, + + /// Patches applied to a product. + Applied = 1, + + /// Patches that are superseded by other patches. + Superseded = 2, + + /// Patches that are obsolesced by other patches. + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Obsoleted")] + Obsoleted = 4, + + /// Patches that are registered to a product but not applied. + Registered = 8, + + /// All valid patch states. + All = (Applied | Superseded | Obsoleted | Registered) + } + + /// + /// Specifies the reinstall mode for or . + /// + [Flags] + public enum ReinstallModes : int + { + /// Reinstall only if file is missing. + FileMissing = 0x00000002, + + /// Reinstall if file is missing, or older version. + FileOlderVersion = 0x00000004, + + /// Reinstall if file is missing, or equal or older version. + FileEqualVersion = 0x00000008, + + /// Reinstall if file is missing, or not exact version. + FileExact = 0x00000010, + + /// Checksum executables, reinstall if missing or corrupt. + FileVerify = 0x00000020, + + /// Reinstall all files, regardless of version. + FileReplace = 0x00000040, + + /// Insure required machine reg entries. + MachineData = 0x00000080, + + /// Insure required user reg entries. + UserData = 0x00000100, + + /// Validate shortcuts items. + Shortcut = 0x00000200, + + /// Use re-cache source install package. + Package = 0x00000400, + } + + /// + /// Attributes for methods. + /// + [Flags] + public enum TransactionAttributes : int + { + /// No attributes. + None = 0x00000000, + + /// Request that the Windows Installer not shutdown the embedded UI until the transaction is complete. + ChainEmbeddedUI = 0x00000001, + + /// Request that the Windows Installer transfer the embedded UI from the original installation. + JoinExistingEmbeddedUI = 0x00000002, + } + + /// + /// Transform error conditions available for or + /// . + /// + [Flags] + public enum TransformErrors : int + { + /// No error conditions. + None = 0x0000, + + /// Adding a row that already exists. + AddExistingRow = 0x0001, + + /// Deleting a row that doesn't exist. + DelMissingRow = 0x0002, + + /// Adding a table that already exists. + AddExistingTable = 0x0004, + + /// Deleting a table that doesn't exist. + DelMissingTable = 0x0008, + + /// Updating a row that doesn't exist. + UpdateMissingRow = 0x0010, + + /// Transform and database code pages do not match and neither code page is neutral. + ChangeCodePage = 0x0020, + + /// Create the temporary _TransformView table when applying the transform. + ViewTransform = 0x0100, + } + + /// + /// Transform validation flags available for . + /// + [Flags] + public enum TransformValidations : int + { + /// Validate no properties. + None = 0x0000, + + /// Default language must match base database. + Language = 0x0001, + + /// Product must match base database. + Product = 0x0002, + + /// Check major version only. + MajorVersion = 0x0008, + + /// Check major and minor versions only. + MinorVersion = 0x0010, + + /// Check major, minor, and update versions. + UpdateVersion = 0x0020, + + /// Installed version < base version. + NewLessBaseVersion = 0x0040, + + /// Installed version <= base version. + NewLessEqualBaseVersion = 0x0080, + + /// Installed version = base version. + NewEqualBaseVersion = 0x0100, + + /// Installed version >= base version. + NewGreaterEqualBaseVersion = 0x0200, + + /// Installed version > base version. + NewGreaterBaseVersion = 0x0400, + + /// UpgradeCode must match base database. + UpgradeCode = 0x0800, + } + + /// + /// Specifies the installation context for s, + /// es, and + /// + /// + [Flags] + public enum UserContexts : int + { + /// Not installed. + None = 0, + + /// User managed install context. + UserManaged = 1, + + /// User non-managed context. + UserUnmanaged = 2, + + /// Per-machine context. + Machine = 4, + + /// All contexts, or all valid values. + All = (UserManaged | UserUnmanaged | Machine), + + /// All user-managed contexts. + AllUserManaged = 8, + } + + /// + /// Defines the type of error encountered by the , , + /// or methods of the class. + /// + public enum ValidationError : int + { + /* + InvalidArg = -3, + MoreData = -2, + FunctionError = -1, + */ + + /// No error. + None = 0, + + /// The new record duplicates primary keys of the existing record in a table. + DuplicateKey = 1, + + /// There are no null values allowed, or the column is about to be deleted but is referenced by another row. + Required = 2, + + /// The corresponding record in a foreign table was not found. + BadLink = 3, + + /// The data is greater than the maximum value allowed. + Overflow = 4, + + /// The data is less than the minimum value allowed. + Underflow = 5, + + /// The data is not a member of the values permitted in the set. + NotInSet = 6, + + /// An invalid version string was supplied. + BadVersion = 7, + + /// The case was invalid. The case must be all uppercase or all lowercase. + BadCase = 8, + + /// An invalid GUID was supplied. + BadGuid = 9, + + /// An invalid wildcard file name was supplied, or the use of wildcards was invalid. + BadWildcard = 10, + + /// An invalid identifier was supplied. + BadIdentifier = 11, + + /// Invalid language IDs were supplied. + BadLanguage = 12, + + /// An invalid file name was supplied. + BadFileName = 13, + + /// An invalid path was supplied. + BadPath = 14, + + /// An invalid conditional statement was supplied. + BadCondition = 15, + + /// An invalid format string was supplied. + BadFormatted = 16, + + /// An invalid template string was supplied. + BadTemplate = 17, + + /// An invalid string was supplied in the DefaultDir column of the Directory table. + BadDefaultDir = 18, + + /// An invalid registry path string was supplied. + BadRegPath = 19, + + /// An invalid string was supplied in the CustomSource column of the CustomAction table. + BadCustomSource = 20, + + /// An invalid property string was supplied. + BadProperty = 21, + + /// The _Validation table is missing a reference to a column. + MissingData = 22, + + /// The category column of the _Validation table for the column is invalid. + BadCategory = 23, + + /// The table in the Keytable column of the _Validation table was not found or loaded. + BadKeyTable = 24, + + /// The value in the MaxValue column of the _Validation table is less than the value in the MinValue column. + BadMaxMinValues = 25, + + /// An invalid cabinet name was supplied. + BadCabinet = 26, + + /// An invalid shortcut target name was supplied. + BadShortcut = 27, + + /// The string is too long for the length specified by the column definition. + StringOverflow = 28, + + /// An invalid localization attribute was supplied. (Primary keys cannot be localized.) + BadLocalizeAttrib = 29 + } + + /// + /// Specifies the modify mode for . + /// + public enum ViewModifyMode : int + { + /// + /// Refreshes the information in the supplied record without changing the position + /// in the result set and without affecting subsequent fetch operations. + /// + Seek = -1, + + /// Refreshes the data in a Record. + Refresh = 0, + + /// Inserts a Record into the view. + Insert = 1, + + /// Updates the View with new data from the Record. + Update = 2, + + /// Updates or inserts a Record into the View. + Assign = 3, + + /// Updates or deletes and inserts a Record into the View. + Replace = 4, + + /// Inserts or validates a record. + Merge = 5, + + /// Deletes a Record from the View. + Delete = 6, + + /// Inserts a Record into the View. The inserted data is not persistent. + InsertTemporary = 7, + + /// Validates a record. + Validate = 8, + + /// Validates a new record. + [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] + ValidateNew = 9, + + /// Validates fields of a fetched or new record. Can validate one or more fields of an incomplete record. + ValidateField = 10, + + /// Validates a record that will be deleted later. + ValidateDelete = 11, + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.resources b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.resources new file mode 100644 index 0000000000000000000000000000000000000000..5564e88a0c2cb737114c8f0c5f8195cfaa439b8e GIT binary patch literal 31461 zcmX?i>is@O1_p+S3=9l8!Ii}&skwSVsm1xFMaikfa8^)iVoGX}jzVs6a(+=xW|EFV zSZYymW`3Tnk)8nv>L@su=9H8crP}7DmX;JH=IAH{lqTh5CVQt=hU90b=Gi8hnh15K*3#oZh7gF=IE~MsJT}aLIx{#Vz zbs;sc>q2T6>O*Q6>qBao>qBZ->O*Q+>qBbT>O*SS>qBbz>O*Sy>qBZ3>O*Q2>qBak z>O*Rj>qBZ(>O*Q&>qBbP>O*SO>qBaE>O*RD>qBZ%>qBbN>O*SM>qBY|Higt2Y6_`2 z&=yj2uq~wKa9c>tfv%96gIysthq^*)4tIsr9O(+FIocIcbF3?*=6F{~&55p%nv-22 zH4nN%Y94ll)I916sd?NLQuCxMq~>W?NX@gZkecURAvG_$LTX-ih14)~htx23htx22 zhtx24ht#liht#lkht#ljht#llht%+Lb%)e&cZbv{bcfU^c8Am`b%)d_cZbxdbcfWa zc8Aocb%)fbcZbwyb%)ewcZbwCbcfV9c8AnBb%)eAcZbxtbcfWqc8Aosb%)frcZbyY zbcfXVc8Am?bcfU=c8Am?b%)d>cZbxZbcfWWc8AoYb%)fXcZbyEbcfXBc8An7bcfV5 zc8An7b%)e6cZbxpbcfWmc8Aoob%)fncZbyUb%)gScZbw0=nkn_*d0={s5_))ad$|~ zlJ1b2rQIPl%eq5qmUoBLtm_V`Sr4+mC#1%=C#1%|C#2>;Ur5ctzL1(jeIYf6`$B4t z^o7(M?F*?n-WO7HqA#T8WM4=PLw`sOV}D2uQ-4SebALz;OMgfWYkx=$TYpFmdp{_E z`a^0I`a^0I`$KA!`a^1z`$K9}`a^0|`$KBf`a^2e`$K9p`a^0o`$K9R`a^0Q`$KA+ z`a^1*`$KBn`a^2m`$KAc`a^1b`$K9H`a^0G`$KAy`a^1x`$K9{`$KBd`a^2c`$KB7 z`a^0O`a^0O`$KA)`a^1(`$KA4`a^13`$KBl`a^2k`$KB_`a^2^`$K9L^oP_e?GLG0 z(;rf^wm+oiL4Qci!~T$(NBto+kNZPvp7e**JnavudDb6N^SnQ#=3ReC&3lkLCWO@Z zP6(;-n-EfSV0uW+!RaA2ho*j(;OGwS3Eg?0Bw}jLj*%DH7bW2Fhu`MAr$G3#koZAvobAC%m z&4Vo=H4nFh)I8b}QuBCANX?TiAvI68gw#CS5>oSgOGwSTEg?1Uw}jL%Yz?Vl+!|8D zu{ETIb1NvYw}#YkZw;y80dcm5)bMQ$so~!mQlqdnq(*UTNR7tUkQ&XcAvIcCLu$0Q zhScb64XM%H8d9UTHKay=YeC|E(c4Nn1l|lDCG`WNZzo$=n)JleIOZCVOj0P0rSkn%u1+HF;Y@YVx;+)U<33 zscGFBQq!?Dq^5IgNKMz)kecqTAvHZ)Luz`rhScz~tsyllwuaQK z+!|7|YHLW%>a8I)Yqo~etlb(?vu!6tsyn%wuaO^+Zs~yd}~O}i>)CwFSmx&yxJO4^LlGY&6}+uHE*|u)V$jo zQu7|<$DJWHo;yQoymp4vc<&6U@!J_vMg|5!Mh1p>Mh1o)Mh1pTMh1p9 zMg|6LMg|58Mg|5~Mh1o;Mh1q-j0_A57#SEim>3v-Gcqu|V`N}>$jHEOg^_{bI3okY zE=C51wTui5N=yt4qD%}7wM+~QT}%uN$xI9k1xySKo=gl3VN47R`b-QAHcSi*)0r3; zmM}3e9AjZ%*vZ1caG8aHp@EHop_h$;VHO($!*VtThAnIi3_3j@Pj76t}A zRt5%ZRt5%P4h9A`4hDvw>v-el2{oSBH0)ieApNm z?AaI?jMx|$RM{99B-j`jxY-yO{;@JJ6tgifq_HtDgm5r0Byun?|=VxHJ!Oy_( zl%Ih?O@M*HSb%|nM}UDrQht*zhwjc=9taaPTuQi1ITqDDg8e=<_o$T;XG2c*w`V@Q#mx;Wr-x!(mFf{QpFqHB#Fl6vDFhuh*Fj(+0Fu3wDFv#&SFlh5JFtG43 zFbMK7FudYrVEE33%)r1c%)qc$h=Jjh5Cg+vAqIvGLJSO@LJSPkgcum|g%}uWgcul-gcul> z3o|gx5@uj17G_{b6J}uO6=q;)5N2SA6lP%X5oTccC&a+;QHX)zi4X(Bbs+`@eh~%+ zCJ_b(14RY~4kHFb1_K5|aO#0_j2KiH;4;Pxb_k9MLk@yt$}knrTI7SRl5FBF$ zab~z46NV53$CRNC!7&4uvm8bYAfwG0ZXjeV7=9r*mJIqVP}4xJjzDk>8Tt_%BZk8W zjxob$1jhtirhx4+WH4n2V1=7z#!!pkm@{lea4ZU0mCc=$B^M7 zf@8$+AHgwZu;7FmV9a2`P=?@`GHgR|%ozS5IOYuIpmqS*3C0W-3^_oo(Y2i z!!0D9A%iG4)GiYSBZdG3$C#lE!7*Xjir|DsXD>GpzKyXYMb|W}u4E&&y2$UL48O#~l5F87J zJqV5^!y6dKjKP3GSO99Y8G|8%ErMgjkc;3LGt5D7Oc+ifIHnB05F9fGbwRjk<_uv7 zjs-(If@8^W5ymlRFksLYg6c76Fa#G=;K(y)Fk-ljkTGU35r!)>0hd=$Wu^=&B5)Zq zh8zUPoMAbFW5I9{!Lek}7lrDvU@&0FL2wKimLWJs4A&qWP?9xb_<-OTGf0Yo4FJiQ zFt{T)rVMQejv2!)1jn4=FM?yiAR`Vpz>>il#sL)&l?aY0!&U^xg5eT^W6AIa#sOt% zMG2^Bpn}p8!7*Y8MsSQ7k`NpdhAITdlwlcyW5#eF!7*p}gWy;&=u5)wv1EvYaX_Ka zjo=tE971r67=9o)#td3gPy;|&ItIZpWmt~jm@%A0aLgH)rQv!k7z_{`ONMM12b7GlFBt z5Q^X!F)T)Kj2ZqSI3^4{a&QAo8I%zmGX@g`$DAP+!LeW{L2xV?w!t`{9Q+Q!F=Y6M z;21Fo$wTciV=!jWL~u+PA`u)@hE4>>jA1o`W6rP>!LeXC2IGJ-ZJYwsXi%m-j^G$E z{6%n#84@9F1Y-ts1`~!h1jm%&2!dnA@Cd=NWcUW-fU>5R64V|G21AB;1jmS>4#ELN zydlFB1jmTsA%p{p9YcnX2#yhhoHE!nkc=@yFoXjNLPLfo1jmSBC4ytj@BzUwVc_Lb z0h<8QWXhn7;FvM^A~@y@tq6_JHgF*s^~^?+oI z8D=6lCJg5g98-pG2#y(ph9+E(IYTjmW5KWw!Lej`4C8=GJ9RCn9#DX!AUH-0OAs7m zhIj7-I7STj5FBF$ zPF<)0Mhqql<_L}{!y5$0jDb}TuFRZ42Enmlh(&NL8LD6$P}w;f!7*fbjNlkCur8N*cs$DF~@46et5p%}rjWLOB}fHL$e1jmrU!W^o{ zjKPSZ3c)dE*nr@eGTcRQ%oyY>;Cjp%d=MN9hGGQAl3_NC1Ik+`5gbDX4oj#3pw^Ei zgaaxC4H>c!93zG~2#ztsF$Bki;V*(?$`E1&HVtHe8ABL?W6scn;8-xMM{q0|?!q{r zteI*JH2{<~Zy-2E42m{z8Dj=#1jmG7I)Y=$@BzUwW3aG=>oI4Tgy2{(JV0ucku4c21!r29utQ72#zU3pch=mjA0{!W6tmf!LeWv_J%97 zWC(z9K>2hgf@8?=4Z$&Dko1A-F=sGlNI-B*7*-=VrVN)595aSr2#z^}r7zq73x-$( z$CBX?j04KU%zjX1pr()^f@8$siQpJB6eBn$4D%5jQ-*U0ju`{9Kio8P24w`tg25lb zv1G`HaV!}O7}g;;h73;;93uw)0H|q}48{yW2#yKETLj0HK_d{Z%#0x!!7*oOL~tw^ zHXt~b41XXTko|@XHbGzmKpZ26d<4gsVH$#C!mt6sF=aT9;FvM|L2%3&6oTQVSujK* zIF<}GFb=2~T!`QpGMqwij2PY^IF<|wAyCsm1(!d9W5Q62;FvSqM{q0{{v$Y+4A!Ag z1B@Ar7;+FCV}>ONjtRqg1jm%&7lLEPpb-W)z?{Jy!LeXif#6s&NQOg|fl8MS1jmqJ zKZ0Y#@B+axW{{15>oH;ILU2qO)_^$1;ITDBh9?M)5kpEO0|TQ{a7KPnNpfjPu|i&c zi9&H{K|y{|NotBhQl&ykMyi5;upXm?XI@!iPG*XNo~NIuLSk}BW`3TPLbOpVqmFZa zX-*1QXHjZ#eok4cLP26lhC*6?kwS4sYEF(qT7FJSY7t1W9;0S>QD#YIUOL2_w9K4T zD}`v|SStm{!U~1dqN4mFh{5_WXDK)rr6z(b1gTVTOU%qkP0_=v!6h{(l?V;$t{~gM zrWU29XBL;F7J-~rQdy9ykdv8Ilvq>=bu~g^X&!#1^1-R#z){G}EG`C_1_}p6nCUS} zd#6_7l#F*tErIIKPg5u=&C3HBkyubrtdIuww~j(GJh;P5J@(WUnAR$(iT2fk+mztsg4pTkG1WGK(%u7kFAY_9gAsh4;e5Bx+msygTn3Gur@i0tF zerbt9ewspVYHof}r5>Xpnl2DmAu%~QwHOhyXj;%+>71Ac${zUzsd?a_26;dMl!8&y zBE*#%APYb$psox_Ov*`BNX#ipO-!j&NUg{$E-415d`9dlQ}RJ}U>==#Ev?0nDaJqnK1O=@^2{=%rjbj1gfPEYk5Lz^YLJ;A<*5~*;u4$^AmOf!rW`rpWagqNHbYbF ziBJFv_T0o0c$sJ%tE1qPnU|^%Z4%39j;1fXC_gV<0qi}6l6**!nd)C!Qczj~Qwa)P z%;2s(Rv{%bEe)K2i}G{9c7x+J8E##)Nvs~D9h#{yZm~jQQ7X6wEKbZ# z)l=}xS15s7n4X#kDq}$bg|6QnDg}3)6+9;@B@7wQn1#?#L(&IL zItXhM6-rV;!2+t9z$qHVB)C23CP8ZtJw{73yI?VtnUb1Ul9`s7TBM*JZ5*o(3jg3h zABDow)S^l&aEe1Octi8D^YY8{pt%s2E{swXUVY`{C#De4j9!8Sr52kU?82&QG%t@hnsTBpO$zW?hi$HN&V}ll!e)-U1tQZ`6u0F2LAqvSkiKWG< zU;(7yG>*kcb*Q@igIrvL6r3V)>vu!5-5FAXLgE2bQ56)W7K6(1{3343F{2DmtexDuf?Gp{(cs02Bp zF>F=A7c)iBB+O`wrphm0p`a);7nHGK?n+5b%LKLEKut(UiU-$#nfZBo7}{ac2Ch(x z3sRGDWoA%b)?-xh3@*tpN=#3+vI;IqEP<8}3gww48Ibx0RD5Do#V|_{RRE%70u{rF zC3f+C<|=?%K>DD%GZk!UX;G>kV<}2lC}0$z`o5sD-AVzP#=(Bf%u@gt z=8%8^wU_eLOB8YwOOi7bic-^3i&8;tVz4Z783{5&K^an_#S^gBO2Ie32vjG5+9u#+ zf@EV!Mk1)igU>ET)Di*_7FG(-f;}-M1=1J zHK3(~f^&XBWk^0ar()@JgIeB*=6O+SZhl!RET2b%dUj~NdgE9|-QbcUP%!`s7;u9V zoLHgl6-?zwqYL1US20944#V|Gbc{AaeR6(oZf1!>F{D&P?b1PlP8XrLC_g7BDKR-4 zpK^VKa%etTvOLd(36jMSo3g>n!9YvDqg$i)gpsi4k8Y6_@z5p5g` zNf*U>j1ef2tfzo530iM~1`+Z~psizwe$YSC>fx`bbEva#;FBE!m+V0CT%Sd1g)yIPF2Ip~SpO zh2)IHy!6y!g{0JEaC;3D9PoZ%W-(|)B@dhfbwN2$k1+*i7&PUAgBT&^h+Hk?gF_Nr zb-;}*Pb^j_NGvW+O;JcJ2FoMrESMra#&$-8k>DhcW=&`wDF1@`dk~+1N6(5ud`O2D z9F=+skdz1-9w%?jKa~g$0_^AW;MIH@ImBYixl00ZH26 z7y@oLj(gLe&rhi??JQ!63u1WVGe zS*+k!nv=t5<5&XfkAs7!Bp)>JotyzND%vPkp*$lMQ~`rpq_Bnus75ZzPcKR>F4kkT zLe-s|pI4HZR|*=w0BHg1&Vw162~JG~aJ|y7zDxjUust{xRL_^dhR!9xF2z#CG8#id zxfmLypy5k}#FCPt%%sv1&~U7AEM_1vih+#-B~nl^14@yQ7?*$;22Q!41}w-lhzxIN zacYr5GH6&jCpCpp4AyY~8{`PHk5LN|f8g33Y5-P8m?PAJ2EIW`6-qL5AvFMq2Tn#< zTrUlAWo8~Y{zCFy@{3&(OHxBJb5r#g4H2e7n=dJuMXAXp`QT9xtPatImF|Wuk({4bmRbbP zCZLdkL|jR}LQZ~iVh)4{%J3jLa5Q2wN&%G8!C|TZ%AWZp3W=cBEqI6{4eTKcsAb^k zgS>R`P#GjQ=7aNL22Qh)8-h9c#i?LjVAWU>lqDj~zL|dpD3s*qE94{=rKd7d;8zJm8v#5am|3ilnp;p(smExC za1khNDioy_mSz^Era;2O)7R16)x#%1&&9_FR26|ol|T~);M4({ax{uIinRjgW^k7m z+>`?qo{5=x3W*9}^$N)usma;JrMVz(X{sJ0H@HN~OwY?NN@av*;Y5_e8&u0Eq=5#C zlM|CN^HM>b0Z>;(j}hDp0)E?xYEfBgkpego zGWvjvI#7k89&Hq>4t8T&erX=Ku@18U+~C$z2+07|s^C#|NJWzjnQ8+02~;8IF-Cwx z3^c%z37hUpRe+fS3KxZ9u;mc5P{UK*8R8wil$;!Oh1|qSg``y21f(7#uOB!gLCs!zYya01hVBvO!(Itnm_;7l3~3T)SklGHpOhAH z!E-6mCUAaAYH@N=W&vdO-7Hp*F&$R-I|n(VTQm|gNf@evwLI(KI28H6p z%3@HN4psuo%Q^~~CB+KK`MCw9pwW5oz%QsS0L|jmGMa#sBsimi8hw?})>uhCBpHC3 zzUT$3aV%pJq%jO~0Vp^?#zE(3KvidcngV!~4^pN;`ks0UsLeJ=I}>66DD==;#wM|h z%HXm9WV+n{zANIBeOP%((B=7Y8#G4z0%g*aP}vM#U|6{5684EivNxD;iULFOJo zRzo@@jNWD@x=EQO3XsJXMU|iqICMz^wA4;bQOM6zFg5}!gZ4Z@Goaw!A~@NA3SUsH zGxGVPE(SoZ?Lln?&=4wYKnI+7;h8qSh|$;?G})P=03Gvo%gh5UHb{ju?(^~$GC^57 zCkIsU!AcfAMqQ|;pwhfxh>6hFJZOZvC>t{5f>5ps%Oj8^4UXUe+^%tS~RS&vb|r4-U9 zN`=fqLb^1did7tBcmd4j(md!;fF7d;B5#3fY)EYb$uQtqdr)QpWkW`@Fwk@iWKG5CIjuA&2b4cEpkC8sbU|_=BAJ4W1veTLG!T^V+TwxTej_8qr+8w!>=|!MsM?q13N@;S50<_f& z8Y4;rO$)$lVn~t7m;j0$a5e&kVrH>IZX!6Q6Cp(wsLPj{qN9*hS^|y|q^QaT#||XI z;GH(e98RS|BBEL{g>~ukOBBGl7?kKB%?rpFj-EmQbP6duwG!khW00pzg1`f_uAoIH znR)2}5dRcIS8*v6rxuoi=1M><6Hw8Ynp~1osfXNbgszi;O&P(K>44ix(Buye1BHUb z7;L1G@L?u3VIL1Gc8-347=rN?L#oRJ7>Jc81Opm=@De1@;sJ%U)I`uhLwbyk zpygj+zvQPWWD@5JXx9~%e?8&tbWjU9zX;Sag$!bNx**r`;B;OLUE2q88z>1YWac47 zvI{89B0>keC_y0=JX{7Dl>|k70XWbUNdDX9e|8KB$^3Zb0TvecYnJ;pFc1viNQ zpan`%YI1&2ih@S8QLH9nB(zuoGVquRN{FC%g2p7YjDimf6f1z&is&&K2f&IV@E{hb zSS-p1tx$yc7TjO~#WS>+0#|m7YC#|+@Ls$EW^o2lX8DXa@r{d<{-yV9)6>I)UODQlez0rYIm{92~G3;4(xLoNBS;8L*S} z7_C8OfJ))iVo>W#JvcQdHMv9`y5Xg*9#L^s4nVbV^9fLdtPEXJb3uI$c&P&!umt4|gb+AB^%$){ z{SRnZBJuxQ-)bvX(EiTE=g;fVoy*jXQ1ZbI#um)Bif?NJj)fRrK znc&V_sGqY!UVf263b;|1lUh=eS_H1>5fv7+xQFV54v)c_lu*f>%;FNzXe?^|%xL6{ z;#5%P0_A^rnsv&|1FfF`Cwk~SB%>w)J>U=r>tNKuR0@l`VujK?#LNU}0RrPDMo^lD z4vOa_CZ*;mfc*q&mV%-ZQma?ym#P<~!k6-b>r7A`4~kaEBrQlSOgm`hReEMwDtKi9 zNCK%<1nS#^a#^uLVopweIk^3sQ>l=drcjw*s*nMi0|CuVDHwu_gGx|huFNkjQb0C> zQ5=?fVUtXdWL?ZC>Ihl33=dCm3TCti`4Lf=LJBpAH$lDt7a8C}4`dz4!HAL$5~kAN z#H;`=q9N%I+NlJ!H|3#?YK7FibkM>^kmc}Z6=-Rl8z==sGFm2L)h&G99_$cnER7ye zNe)`H0cr!8#HuqYK?*BSJHj_HFEKr}2<&ncyOa=4$En5|Z4o|a4j^+rqc zAcHfYl_SZike+s8UJ6)MQfg`*Xi^%~_JXDt=J6A=JLm0sg9#m(5QW?@1Ce%`|#Ii)9 zw7Q{22dKb-3~xX~4eZEhlUOT-Xwz8e;#{*>9nfMD@N#DJSRI9Ei&#c?=ls01%=A)d zGZ-{Y03C_}yBSubg3QkZbr+zEL}3XAq#lwV6?_wmiZc?y<#tIvY{(Hgh#e5YlnPn0 zjV+A9qjr!z9H4Lpt$s+%14WWaETgk)ge!E#hXQC|3bGRfBV2XBqxYaH1zPc<7!n9y zt^}%v;Y-6o^%Sf|fsQpn*IMQz=B1Z{2E4$7NsuBPA!Zt@$LLS0k?>$OiPeGDKX4(C zfr;cA2%GM)0WGFOHyS1x4YDGMVk>NEZ-*@%?64zj2gT80M=+>d5Sati;y_wC0?K-z z1v;QEVX;DTMrKY5s2~L`kpwjZ;b|7MU|bJWDT3P#kn$Nist4`wgOWJ3d9- zfw&X2=%f_7P7yI^f7Zr{P*VcbAOcNzKqhf~gFRuBs(Os>sH))^ z%s3X@o6RjqEXf3IuK_RigES?q6?`*68`MBK-#4)WTt4eD`k)#FTNMF{G33BgaD^=Z zFD*zfN=yN*%18lkyMX0&aNc%+&Xpvkrh{rv(AEG*V_Q$bJtsdYF-IY{v?R3xT-!l{ z7}Q*Y&)=lzF`7V40FR$4Kx-CA=UET3umoZt*ofkiM9{80Jw|P)uAJIe(VbbWP?DIPny1I80UB8Vok?8` zni|W5b@4$d7Sy6kEd!0CfOIpOx_~>u3SpV4Qe;if`$Sp?4d;~$OGwlnN^_DM#lx(-A*bkDap?R4J~Kp2cGcD&np3W6TBt@v`;7{ADm)96Fs1T*UIFaR8TV-wD=N~@*#^S zKy#F!X<|^?E6In{InYtvqEwJ`^70kZN{hh#VW`P^jD<9FMpAxB1~{TXod8fX6yhd5 zMt6VYm;-IC0(%zZY*3Oe$p8Ok?`Manv$S#*$x z;4|rP-8jq#H3eKfAvpl*ZC8+sA>DojM3jNUJ`X%zpPUcLY6{4arN?Li)elZlBhlabs%#<11sRU8E9ZaHUK83q=1SY zFB07XH3Qr?0u2d4+y*KN^%xyN@e36|L?tL=!a@?1xr$Oi#c^T@s1hkI0qKMcjB9{q zy1*m4P&*JS_`q>Pv>6e&V>A`K1OPPGRhgfc0uGcU(CU@MBG5Q9baVsigJ=`b0#a}f zxFE9vJR?v6@*uQ)21(~bQeaVHN@hN21`Jegrx)dy7Jwa$8WluY4b^N4vDqwE0cLY} zND*j+yCh!$x}FafMxfAzjJ`qYN$^kuwAhB1jnL`_HgyBaY7kHAF{(r3A2c-x+R>K? z$}EVqoC2*R^%%_vDTKKQ#oKz2*?@sloK2=>e4xM(~7S5{sNxK@Dv1iYZ76$c46Az@;B}L?2wRLhHC{?P3!v>vxOYLTWx-R}piy+tBnFb_K`sQhCg7@#!LCHJ3%Y0u)Nq2- zX?l>+OEg_bt}9Q>D}hXNm4jNLMfu5~$c1#hK-D^Q{64cJH5VL|pjLiHszNb%;sZ45 zg{U_&ONvu-(m?eMq5@M0hOV*&ITT(rf?73@@ftlw=+acElR&i@sF?{K7S?0b^2=B7 z_lD&bP-O}k6oKX?NN*6Ll~D(@HyPBT0neN%;8m>0=m1J0;00L0;H{ZR!A6)8^PmG_5chxvr9qyCxDm4d6V_}fPA$=61kXE` zn4^Hks^ zg|OJi5^8#ko}hq$sld!~pgIxUx&oP)nVg@e0BT}^I7yi$xrqe|#U+(Fp!86p#~2GQ zcR+PCvYDXyLr|j|wbhE0zCmN2=milx*MbMv^%%YIyA-rTB~2j_e4K&~Wd9vBJ0yXY z7M7%fM!Z4Ibx=(v8JY*GUZ9mcbOHl3rJ={D4zdO`H2`l{fV~Y$v(S_QUbv*k=;{co zmOujrFz)$$~3QP;P?66*&7OrGiGz6`+mGVvtk(p$$f;1&QDR@f^^h91wlr z#exmg-0Bg1_jg@NCy$VKp32`L1l{`N;wS@0i|0*Gd;#;@C+X`&aoH_ zX=s7U1F&JBhE8Ul0@#FT)7Xk=(^yzCN-Tj0Lo-ogSz;!5@0Ff{PkthJaX!eDv`lb9 zgh_(6=rOJ*;EJNug%+d$NL=4k@ESu@6cwiKQhO`H<+R6$$6j>0Ec2oBtdOPt3>q}qd^8` zq~?Gs8qg66pf(A(V8)#!;Z6i80S%>sEG~xa4nm%41dp_UdES3KS$36+>3Z=Oz||_AZ0c6xbq09T&*J7xXwWaK#IHHU7K-;;Xops2dAuQN6ptX5>YJo_A6E`Sk5h+QJQ5UhU9Xh*^r~tJAR&*hhD>52mC>l z_rTH>C>kNT0^%$^Mu>Ys@`(z`kn^rU!)FYWs71L znorQ&iEtxy5J->F6qM*7L*7MDLD1R@aL|D41ZN{?^rXU??0SqEh+qLNC@;#dL=HrR zJ$j6eAQyv1J3)(3AT3Amx)P|yzpBg4OF;+yDpi<3b2jPUT*o|(-alJgtr&a*$BsowUic!@cemWs2rNM^dAeB!sbTP6XqXa0OgC>?*!C-Lsx^eX%8Ak;6>%2jvvO_ za`=KZ(83c%ghL_w7(jbs^P$sgAaCh0DkGG@mP%tPf^4<|kEFmhOr?T0GZm>9gE|h7 z_3fD{;EigCvpB(raezu7#B`V*qY=WsV$fV!X%1p{5xDdPkD4XsfU5JN)TI3U58U*#h?|3kag|g>1*)7E29o{nJl7(391fJH6kJ)0lE$cloVhSyGTpz z^c0}-P&shJL`MO%Wh@u8xev1M7F>zxDC8zqWTJ|KmSD&QgH9oZ?&!))0fjp#IYH+z z^%$+-#{~muEX>7gA!zM!2{o-V#l8R$ zG!_RskrABZpve!ksSmPOLXS}$X(J?LYaF=w2HI{1Y9E2a8JsYT5v3)x5&~6_pv(!b zB%z}$;B8f)+z8UB$Cw=gIy?!Q`#?hzuo#B-G(hglFDg+;NiE39uLPxf=-w^pgnluk zx`w7~kjda_>>`Ck1yqH4jG+B_(CsOX;MFCd5f1PKIjpKQgRU5b)GqmHprz~qIiY&_`71~O literal 0 HcmV?d00001 diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.txt b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.txt new file mode 100644 index 00000000..ec7c97b1 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Errors.txt @@ -0,0 +1,404 @@ +; Windows Installer Internal Error Messages +; +; Error numbers greater than 2000 are "internal errors" and do not have +; localized strings in msimsg.dll. The messages are provided here +; (in English only) because they can be informative and time-saving +; during developement. +; + +2101=Shortcuts not supported by the OS. +2102=Invalid .INI action: [2] +2103=Could not resolve path for shell folder [2]. +2104=Writing .INI file: [3]: System error: [2] +2105=Shortcut Creation [3] Failed. System error: [2] +2106=Shortcut Deletion [3] Failed. System error: [2] +2107=Error [3] registering type library [2]. +2108=Error [3] unregistering type library [2]. +2109=Section missing for INI action. +2110=Key missing for INI action. +2111=Detection of running apps failed, could not get performance data. Reg operation returned : [2]. +2112=Detection of running apps failed, could not get performance index. Reg operation returned : [2]. +2113=Detection of running apps failed. +2200=Database: [2]. Database object creation failed, mode = [3]. +2201=Database: [2]. Initialization failed, out of memory. +2202=Database: [2]. Data access failed, out of memory. +2203=Database: [2]. Cannot open database file. System error [3]. +2204=Database: [2]. Table already exists: [3] +2205=Database: [2]. Table does not exist: [3] +2206=Database: [2]. Table could not be dropped: [3] +2207=Database: [2]. Intent violation. +2208=Database: [2]. Insufficient parameters for Execute. +2209=Database: [2]. Cursor in invalid state. +2210=Database: [2]. Invalid update data type in column [3] +2211=Database: [2]. Could not create database table [3] +2212=Database: [2]. Database not in writable state. +2213=Database: [2]. Error saving database tables. +2214=Database: [2]. Error writing export file: [3] +2215=Database: [2]. Cannot open import file: [3] +2216=Database: [2]. Import file format error: [3], Line [4] +2217=Database: [2]. Wrong state to CreateOutputDatabase [3]. +2218=Database: [2]. Table name not supplied. +2219=Database: [2]. Invalid Installer database format. +2220=Database: [2]. Invalid row/field data. +2221=Database: [2]. Code page conflict in import file: [3]. +2222=Database: [2]. Transform or merge code page [3] differs from database code page [4]. +2223=Database: [2]. Databases are the same. No transform generated. +2224=Database: [2]. GenerateTransform: Database corrupt. Table: [3] +2225=Database: [2]. Transform: Cannot transform a temporary table. Table: [3] +2226=Database: [2]. Transform failed. +2227=Database: [2]. Invalid identifier '[3]' in SQL query: [4] +2228=Database: [2]. Unknown table '[3]' in SQL query: [4] +2229=Database: [2]. Could not load table '[3]' in SQL query: [4] +2230=Database: [2]. Repeated table '[3]' in SQL query: [4] +2231=Database: [2]. Missing ')' in SQL query: [3] +2232=Database: [2]. Unexpected token '[3]' in SQL query: [4] +2233=Database: [2]. No columns in SELECT clause in SQL query: [3] +2234=Database: [2]. No columns in ORDER BY clause in SQL query: [3] +2235=Database: [2]. Column '[3]' not present or ambiguous in SQL query: [4] +2236=Database: [2]. Invalid operator '[3]' in SQL query: [4] +2237=Database: [2]. Invalid or missing query string: [3] +2238=Database: [2]. Missing FROM clause in SQL query: [3] +2239=Database: [2]. Insufficient values in INSERT SQL stmt. +2240=Database: [2]. Missing update columns in UPDATE SQL stmt. +2241=Database: [2]. Missing insert columns in INSERT SQL stmt. +2242=Database: [2]. Column '[3]' repeated +2243=Database: [2]. No primary columns defined for table creation. +2244=Database: [2]. Invalid type specifier '[3]' in SQL query [4]. +2245=IStorage::Stat failed with error [3] +2246=Database: [2]. Invalid Installer transform format. +2247=Database: [2] Transform stream read/write failure. +2248=Database: [2] GenerateTransform/Merge: Column type in base table doesn't match reference table. Table: [3] Col #: [4] +2249=Database: [2] GenerateTransform: More columns in base table than in reference table. Table: [3] +2250=Database: [2] Transform: Cannot add existing row. Table: [3] +2251=Database: [2] Transform: Cannot delete row that doesn't exist. Table: [3] +2252=Database: [2] Transform: Cannot add existing table. Table: [3] +2253=Database: [2] Transform: Cannot delete table that doesn't exist. Table: [3] +2254=Database: [2] Transform: Cannot update row that doesn't exist. Table: [3] +2255=Database: [2] Transform: Column with this name already exists. Table: [3] Col: [4] +2256=Database: [2] GenerateTransform/Merge: Number of primary keys in base table doesn't match reference table. Table: [3] +2257=Database: [2]. Intent to modify read only table: [3] +2258=Database: [2]. Type mismatch in parameter: [3] +2259=Database: [2] Table(s) Update failed. +2260=Storage CopyTo failed. System error: [3] +2261=Could not remove stream [2]. System error: [3] +2262=Stream does not exist: [2]. System error: [3] +2263=Could not open stream [2]. System error: [3] +2264=Could not remove stream [2]. System error: [3] +2265=Could not commit storage. System error: [3] +2266=Could not rollback storage. System error: [3] +2267=Could not delete storage [2]. System error: [3] +2268=Database: [2]. Merge: There were merge conflicts reported in [3] tables. +2269=Database: [2]. Merge: The column count differed in the '[3]' table of the two databases. +2270=Database: [2]. GenerateTransform/Merge: Column name in base table doesn't match reference table. Table: [3] Col #: [4] +2271=SummaryInformation write for transform failed. +2272=Database: [2]. MergeDatabase will not write any changes because the database is open read-only. +2273=Database: [2]. MergeDatabase: A reference to the base database was passed as the reference database. +2274=Database: [2]. MergeDatabase: Unable to write errors to Error table. Could be due to a non-nullable column in a predefined Error table. +2275=Database: [2]. Specified Modify [3] operation invalid for table joins. +2276=Database: [2]. Code page [3] not supported by the system. +2277=Database: [2]. Failed to save table [3]. +2278=Database: [2]. Exceeded number of expressions limit of 32 in WHERE clause of SQL query: [3]. +2279=Database: [2] Transform: Too many columns in base table [3] +2280=Database: [2]. Could not create column [3] for table [4] +2281=Could not rename stream [2]. System error: [3] +2282=Stream name invalid [2]. +2302=Patch notify: [2] bytes patched to far. +2303=Error getting volume info. GetLastError: [2] +2304=Error getting disk free space. GetLastError: [2]. Volume: [3] +2305=Error waiting for patch thread. GetLastError: [2]. +2306=Could not create thread for patch application. GetLastError: [2]. +2307=Source file key name is null. +2308=Destination File Name is Null +2309=Attempting to patch file [2] when patch already in progress. +2310=Attempting to continue patch when no patch is in progress. +2315=Missing Path Separator: [2] +2318=File does not exist: [2] +2319=Error setting file attribute: [3] GetLastError: [2] +2320=File not writable: [2] +2321=Error creating file: [2] +2322=User canceled +2323=Invalid File Attribute +2324=Could not open file: [3] GetLastError: [2] +2325=Could not get file time for file: [3] GetLastError: [2] +2326=Error in FileToDosDateTime. +2327=Could not remove directory: [3] GetLastError: [2] +2328=Error getting file version info for file: [2] +2329=Error deleting file: [3]. GetLastError: [2] +2330=Error getting file attributes: [3]. GetLastError: [2] +2331=Error loading library [2] or finding entry point [3] +2332=Error getting file attributes. GetLastError: [2] +2333=Error setting file attributes. GetLastError: [2] +2334=Error converting file time to local time for file: [3]. GetLastError: [2] +2335=Path: [2] is not a parent of [3] +2336=Error creating temp file on path: [3]. GetLastError: [2] +2337=Could not close file: [3] GetLastError: [2] +2338=Could not update resource for file: [3] GetLastError: [2] +2339=Could not set file time for file: [3] GetLastError: [2] +2340=Could not update resource for file: [3], Missing Resource +2341=Could not update resource for file: [3], Resource too large +2342=Could not update resource for file: [3] GetLastError: [2] +2343=Specified path is empty. +2344=Could not find required file IMAGEHLP.DLL to validate file:[2] +2345=[2]: File does not contain a valid checksum value. +2347=User ignore +2348=Error attempting to read from cabinet stream. +2349=Copy Resumed With Different Info +2350=FDI Server Error +2351=File key '[2]' not found in cabinet '[3]'. The installation cannot continue. +2352=Couldn't initialize cabinet file server. The required file 'Cabinet.dll' may be missing. +2353=Not a cabinet +2354=Cannot handle cabinet +2355=Corrupt cabinet +2356=Couldn't locate cabinet in stream: [2]. +2357=Cannot set attributes +2358=Error determining whether file is in-use: [3]. GetLastError: [2] +2359=Unable to create the target file - file may be in use. +2360=progress tick. +2361=Need next cabinet. +2362=Folder not found: [2] +2363=Could not enumerate subfolders for folder: [2] +2364=Bad enumeration constant in CreateCopier call. +2365=Could not BindImage exe file [2] +2366=User Failure +2367=User Abort. +2368=Failed to get network resource information. Error [2], network path [3]. Extended error: network provider [5], error code [4], error description [6]. +2370=Invalid CRC checksum value for [2] file.{ Its header says [3] for checksum, its computed value is [4].} +2371=Could not apply patch to file [2]. GetLastError: [3] +2372=Patch file [2] is corrupt or of an invalid format. Attempting to patch file [3]. GetLastError: [4] +2373=File [2] is not a valid patch file. +2374=File [2] is not a valid destination file for patch file [3]. +2375=Unknown patching error: [2]. +2376=Cabinet not found. +2379=Error opening file for read: [3] GetLastError: [2] +2380=Error opening file for write: [3] GetLastError: [2] +2381=Directory does not exist: [2] +2382=Drive not ready: [2] +2401=64-bit registry operation attempted on 32-bit operating system for key [2]. +2402=Out of memory. +2501=Could not create rollback script enumerator +2502=Called InstallFinalize when no install in progress. +2503=Called RunScript when not marked in progress. +2601=Invalid value for property [2]: '[3]' +2602=The [2] table entry '[3]' has no associated entry in the Media table. +2603=Duplicate Table Name [2] +2604=[2] property undefined. +2605=Could not find server [2] in [3] or [4]. +2606=Value of property [2] is not a valid full path: '[3]'. +2607=Media table not found or empty (required for installation of files). +2608=Could not create security descriptor for object. Error: '[2]'. +2609=Attempt to migrate product settings before initialization. +2611=The file [2] is marked as compressed, but the associated media entry does not specify a cabinet. +2612=Stream not found in '[2]' column. Primary key: '[3]'. +2613=RemoveExistingProducts action sequenced incorrectly. +2614=Could not access IStorage object from installation package. +2615=Skipped unregistration of Module [2] due to source resolution failure. +2616=Companion file [2] parent missing. +2617=Shared component [2] not found in Component table. +2618=Isolated application component [2] not found in Component table. +2619=Isolated components [2], [3] not part of same feature. +2620=Key file of isolated application component [2] not in File table. +2621=Resource DLL or Resource ID information for shortcut [2] set incorrectly. +2701=The Component Table exceeds the acceptable tree depth of [2] levels. +2702=A Feature Table record ([2]) references a non-existent parent in the Attributes field. +2703=Property name for root source path not defined: [2] +2704=Root directory property undefined: [2] +2705=Invalid table: [2]; Could not be linked as tree. +2706=Source paths not created. No path exists for entry [2] in Directory Table +2707=Target paths not created. No path exists for entry [2] in Directory Table +2708=No entries found in the file table. +2709=The specified Component name ('[2]') not found in Component Table. +2710=The requested 'Select' state is illegal for this Component. +2711=The specified Feature name ('[2]') not found in Feature Table. +2712=Invalid return from modeless dialog: [3], in action [2]. +2713=Null value in a non-nullable column ('[2]' in '[3]' column of the '[4]' table. +2714=Invalid value for default folder name: [2]. +2715=The specified File key ('[2]') not found in the File Table. +2716=Couldn't create a random subcomponent name for component '[2]'. +2717=Bad action condition or error calling custom action '[2]'. +2718=Missing package name for product code '[2]'. +2719=Neither UNC nor drive letter path found in source '[2]'. +2720=Error opening source list key. Error: '[2]' +2721=Custom action [2] not found in Binary table stream +2722=Custom action [2] not found in File table +2723=Custom action [2] specifies unsupported type +2724=The volume label '[2]' on the media you're running from doesn't match the label '[3]' given in the Media table. This is allowed only if you have only 1 entry in your Media table. +2725=Invalid database tables +2726=Action not found: [2] +2727=The directory entry '[2]' does not exist in the Directory table +2728=Table definition error: [2] +2729=Install engine not initialized. +2730=Bad value in database. Table: '[2]'; Primary key: '[3]'; Column: '[4]' +2731=Selection Manager not initialized. +2732=Directory Manager not initialized. +2733=Bad foreign key ('[2]') in '[3]' column of the '[4]' table. +2734=Invalid Reinstall mode character. +2735=Custom action '[2]' has caused an unhandled exception and has been stopped. This may be the result of an internal error in the custom action, such as an access violation. +2736=Generation of custom action temp file failed: [2] +2737=Could not access custom action [2], entry [3], library [4] +2738=Could not access VBScript runtime for custom action [2] +2739=Could not access JavaScript runtime for custom action [2] +2740=Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] +2741=Configuration information for product [2] is corrupt. Invalid info: [2] +2742=Marshaling to Server failed: [2] +2743=Could not execute custom action [2], location: [3], command: [4] +2744=EXE failed called by custom action [2], location: [3], command: [4] +2745=Transform [2] invalid for package [3]. Expected language [4], found language [5]. +2746=Transform [2] invalid for package [3]. Expected product [4], found product [5]. +2747=Transform [2] invalid for package [3]. Expected product version < [4], found product version [5]. +2748=Transform [2] invalid for package [3]. Expected product version <= [4], found product version [5]. +2749=Transform [2] invalid for package [3]. Expected product version == [4], found product version [5]. +2750=Transform [2] invalid for package [3]. Expected product version >= [4], found product version [5]. +2751=Transform [2] invalid for package [3]. Expected product version > [4], found product version [5]. +2752=Could not open transform [2] stored as child storage of package [4]. +2753=The File '[2]' is not marked for installation. +2754=The File '[2]' is not a valid patch file. +2755=Server returned unexpected error [2] attempting to install package [3]. +2756=The property '[2]' was used as a directory property in one or more tables, but no value was ever assigned. +2757=Could not create summary info for transform [2]. +2758=Transform [2] doesn't contain a MSI version. +2759=Transform [2] version [3] incompatible with engine; Min: [4], Max: [5]. +2760=Transform [2] invalid for package [3]. Expected upgrade code [4], found [5]. +2761=Cannot begin transaction. Global mutex not properly initialized. +2762=Cannot write script record. Transaction not started. +2763=Cannot run script. Transaction not started. +2765=Assembly name missing from AssemblyName table : Component: [4]. +2766=The file [2] is an invalid MSI storage file. +2767=No more data{ while enumerating [2]}. +2768=Transform in patch package is invalid. +2769=Custom Action [2] did not close [3] handles. +2770=Cached folder [2] not defined in internal cache folder table. +2771=Upgrade of feature [2] has a missing component. +2772=New upgrade feature [2] must be a leaf feature. +2801=Unknown Message -- Type [2]. No action is taken. +2802=No publisher is found for the event [2]. +2803=Dialog View did not find a record for the dialog [2]. +2804=On activation of the control [3] on dialog [2], failed to evaluate the condition [3]. +2805= +2806=The dialog [2] failed to evaluate the condition [3]. +2807=The action [2] is not recognized. +2808=Default button is ill-defined on dialog [2]. +2809=On the dialog [2] the next control pointers do not form a cycle. There is a pointer from [3] to [4], but there is no further pointer. +2810=On the dialog [2] the next control pointers do not form a cycle. There is a pointer from both [3] and [5] to [4]. +2811=On dialog [2] control [3] has to take focus, but it is unable to do so. +2812=The event [2] is not recognized. +2813=The EndDialog event was called with the argument [2], but the dialog has a parent. +2814=On the dialog [2] the control [3] names a non-existent control [4] as the next control. +2815=ControlCondition table has a row without condition for the dialog [2]. +2816=The EventMapping table refers to an invalid control [4] on dialog [2] for the event [3]. +2817=The event [2] failed to set the attribute for the control [4] on dialog [3]. +2818=In the ControlEvent table EndDialog has an unrecognized argument [2]. +2819=Control [3] on dialog [2] needs a property linked to it. +2820=Attempted to initialize an already initialized handler. +2821=Attempted to initialize an already initialized dialog: [2]. +2822=No other method can be called on dialog [2] until all the controls are added. +2823=Attempted to initialize an already initialized control: [3] on dialog [2]. +2824=The dialog attribute [3] needs a record of at least [2] field(s). +2825=The control attribute [3] needs a record of at least [2] field(s). +2826=Control [3] on dialog [2] extends beyond the boundaries of the dialog [4] by [5] pixels. +2827=The button [4] on the radio button group [3] on dialog [2] extends beyond the boundaries of the group [5] by [6] pixels. +2828=Tried to remove control [3] from dialog [2], but the control is not part of the dialog. +2829=Attempt to use an uninitialized dialog. +2830=Attempt to use an uninitialized control on dialog [2]. +2831=The control [3] on dialog [2] does not support [5] the attribute [4]. +2832=The dialog [2] does not support the attribute [3]. +2833=Control [4] on dialog [3] ignored the message [2]. +2834=The next pointers on the dialog [2] do not form a single loop. +2835=The control [2] was not found on dialog [3]. +2836=The control [3] on the dialog [2] cannot take focus. +2837=The control [3] on dialog [2] wants the win proc to return [4]. +2838=The item [2] in the selection table has itself as a parent. +2839=Setting the property [2] failed. +2840=Error dialog name mismatch. +2841=No OK button was found on the error dialog +2842=No text field was found on the error dialog. +2843=The ErrorString attribute is not supported for standard dialogs. +2844=Cannot execute an error dialog if the error string is not set. +2845=The total width of the buttons exceeds the size of the error dialog. +2846=SetFocus did not find the required control on the error dialog. +2847=The control [3] on dialog [2] has both the icon and the bitmap style set. +2848=Tried to set control [3] as the default button on dialog [2], but the control does not exist. +2849=The control [3] on dialog [2] is of a type, that cannot be integer valued. +2850=Unrecognized volume type. +2851=The data for the icon [2] is not valid. +2852=At least one control has to be added to dialog [2] before it is used. +2853=Dialog [2] is a modeless dialog. The execute method should not be called on it. +2854=On the dialog [2] the control [3] is designated as first active control, but there is no such control. +2855=The radio button group [3] on dialog [2] has fewer than 2 buttons. +2856=Creating a second copy of the dialog [2]. +2857=The directory [2] is mentioned in the selection table but not found. +2858=The data for the bitmap [2] is not valid. +2859=Test error message. +2860=Cancel button is ill-defined on dialog [2]. +2861=The next pointers for the radio buttons on dialog [2] control [3] do not form a cycle. +2862=The attributes for the control [3] on dialog [2] do not define a valid icon size. Setting the size to 16. +2863=The control [3] on dialog [2] needs the icon [4] in size [5]x[5], but that size is not available. Loading the first available size. +2864=The control [3] on dialog [2] received a browse event, but there is no configurable directory for the present selection. Likely cause: browse button is not authored correctly. +2865=Control [3] on billboard [2] extends beyond the boundaries of the billboard [4] by [5] pixels. +2866=The dialog [2] is not allowed to return the argument [3]. +2867=The error dialog property is not set. +2868=The error dialog [2] does not have the error style bit set. +2869=The dialog [2] has the error style bit set, but is not an error dialog. +2870=The help string [4] for control [3] on dialog [2] does not contain the separator character. +2871=The [2] table is out of date: [3] +2872=The argument of the CheckPath control event on dialog [2] is invalid. +2873=On the dialog [2] the control [3] has an invalid string length limit: [4] +2874=Changing the text font to [2] failed. +2875=Changing the text color to [2] failed. +2876=The control [3] on dialog [2] had to truncate the string: [4] +2877=The binary data [2] was not found. +2878=On the dialog [2] the control [3] has a possible value: [4]. This is an invalid or duplicate value. +2879=The control [3] on dialog [2] cannot parse the mask string: [4] +2880=Do not perform the remaining control events. +2881=Initialization failed. +2882=Dialog window class registration failed. +2883=CreateNewDialog failed for the dialog [2]. +2884=Failed to create a window for the dialog [2]! +2885=Failed to create the control [3] on the dialog [2]. +2886=Creating the [2] table failed. +2887=Creating a cursor to the [2] table failed. +2888=Executing the [2] view failed. +2889=Creating the window for the control [3] on dialog [2] failed. +2890=The handler failed in creating an initialized dialog. +2891=Failed to destroy window for dialog [2]. +2892=[2] is an integer only control, [3] is not a valid integer value. +2893=The control [3] on dialog [2] can accept property values that are at most [5] characters long. The value [4] exceeds this limit, and has been truncated. +2894=Loading RichEd20.dll failed. GetLastError() returned: [2] +2895=Freeing RichEd20.dll failed. GetLastError() returned: [2] +2896=Executing action [2] failed. +2897=Failed to create any [2] font on this system. +2898=For [2] text style, the system created a '[3]' font, in [4] character set. +2899=Failed to create [2] text style. GetLastError() returned: [3]. +2901=Invalid parameter to operation [2]: Parameter [3] +2902=Operation [2] called out of sequence. +2903=The file [2] is missing. +2904=Could not BindImage file [2]. +2905=Could not read record from script file [2]. +2906=Missing header in script file [2]. +2907=Could not create secure security descriptor. Error: [2] +2908=Could not register component [2]. +2909=Could not unregister component [2]. +2910=Could not determine user's security id. +2911=Could not remove the folder [2]. +2912=Could not schedule file [2] for removal on reboot. +2919=No cabinet specified for compressed file: [2] +2920=Source directory not specified for file [2]. +2924=Script [2] version unsupported. Script version: [3], minimum version: [4], maximum version: [5]. +2927=ShellFolder id [2] is invalid. +2928=Exceeded maximum number of sources. Skipping source '[2]'. +2929=Could not determine publishing root. Error: [2] +2932=Could not create file [2] from script data. Error: [3] +2933=Could not initialize rollback script [2]. +2934=Could not secure transform [2]. Error [3] +2935=Could not un-secure transform [2]. Error [3] +2936=Could not find transform [2]. +2937=The Windows Installer cannot install a system file protection catalog. Catalog: [2], Error: [3] +2938=The Windows Installer cannot retrieve a system file protection catalog from the cache. Catalog: [2], Error: [3] +2939=The Windows Installer cannot delete a system file protection catalog from the cache. Catalog: [2], Error: [3] +2940=Directory Manager not supplied for source resolution. +2941=Unable to compute the CRC for file [2]. +2942=BindImage action has not been executed on [2] file. +2943=This version of Windows does not support deploying 64-bit packages. The script [2] is for a 64-bit package. +2944=GetProductAssignmentType failed. +2945=Installation of ComPlus App [2] failed with error [3]. +3001=The patches in this list contain incorrect sequencing information: [2][3][4][5][6][7][8][9][10][11][12][13][14][15][16]. 3.0 +3002=Patch [2] contains invalid sequencing information. diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Exceptions.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Exceptions.cs new file mode 100644 index 00000000..1f5e017a --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Exceptions.cs @@ -0,0 +1,576 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Security.Permissions; + using System.Runtime.Serialization; + using System.Diagnostics.CodeAnalysis; + + /// + /// Base class for Windows Installer exceptions. + /// + [Serializable] + public class InstallerException : SystemException + { + private int errorCode; + private object[] errorData; + + /// + /// Creates a new InstallerException with a specified error message and a reference to the + /// inner exception that is the cause of this exception. + /// + /// The message that describes the error. + /// The exception that is the cause of the current exception. If the + /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception + /// is raised in a catch block that handles the inner exception. + public InstallerException(string msg, Exception innerException) + : this(0, msg, innerException) + { + } + + /// + /// Creates a new InstallerException with a specified error message. + /// + /// The message that describes the error. + public InstallerException(string msg) + : this(0, msg) + { + } + + /// + /// Creates a new InstallerException. + /// + public InstallerException() + : this(0, null) + { + } + + internal InstallerException(int errorCode, string msg, Exception innerException) + : base(msg, innerException) + { + this.errorCode = errorCode; + this.SaveErrorRecord(); + } + + internal InstallerException(int errorCode, string msg) + : this(errorCode, msg, null) + { + } + + /// + /// Initializes a new instance of the InstallerException class with serialized data. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + protected InstallerException(SerializationInfo info, StreamingContext context) : base(info, context) + { + if (info == null) + { + throw new ArgumentNullException("info"); + } + + this.errorCode = info.GetInt32("msiErrorCode"); + } + + /// + /// Gets the system error code that resulted in this exception, or 0 if not applicable. + /// + public int ErrorCode + { + get + { + return this.errorCode; + } + } + + /// + /// Gets a message that describes the exception. This message may contain detailed + /// formatted error data if it was available. + /// + public override String Message + { + get + { + string msg = base.Message; + using (Record errorRec = this.GetErrorRecord()) + { + if (errorRec != null) + { + string errorMsg = Installer.GetErrorMessage(errorRec, CultureInfo.InvariantCulture); + msg = Combine(msg, errorMsg); + } + } + return msg; + } + } + + /// + /// Sets the SerializationInfo with information about the exception. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter=true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) + { + throw new ArgumentNullException("info"); + } + + info.AddValue("msiErrorCode", this.errorCode); + base.GetObjectData(info, context); + } + + /// + /// Gets extended information about the error, or null if no further information + /// is available. + /// + /// A Record object. Field 1 of the Record contains the installer + /// message code. Other fields contain data specific to the particular error. + ///

+ /// If the record is passed to , it is formatted + /// by looking up the string in the current database. If there is no installation + /// session, the formatted error message may be obtained by a query on the Error table using + /// the error code, followed by a call to . + /// Alternatively, the standard MSI message can by retrieved by calling the + /// method. + ///

+ /// The following methods and properties may report extended error data: + /// + /// (constructor) + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// (constructor) + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// . + /// + ///

+ /// The Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiGetLastErrorRecord + ///

+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + public Record GetErrorRecord() + { + return this.errorData != null ? new Record(this.errorData) : null; + } + + internal static Exception ExceptionFromReturnCode(uint errorCode) + { + return ExceptionFromReturnCode(errorCode, null); + } + + internal static Exception ExceptionFromReturnCode(uint errorCode, string msg) + { + msg = Combine(GetSystemMessage(errorCode), msg); + switch (errorCode) + { + case (uint) NativeMethods.Error.FILE_NOT_FOUND: + case (uint) NativeMethods.Error.PATH_NOT_FOUND: return new FileNotFoundException(msg); + + case (uint) NativeMethods.Error.INVALID_PARAMETER: + case (uint) NativeMethods.Error.DIRECTORY: + case (uint) NativeMethods.Error.UNKNOWN_PROPERTY: + case (uint) NativeMethods.Error.UNKNOWN_PRODUCT: + case (uint) NativeMethods.Error.UNKNOWN_FEATURE: + case (uint) NativeMethods.Error.UNKNOWN_COMPONENT: return new ArgumentException(msg); + + case (uint) NativeMethods.Error.BAD_QUERY_SYNTAX: return new BadQuerySyntaxException(msg); + + case (uint) NativeMethods.Error.INVALID_HANDLE_STATE: + case (uint) NativeMethods.Error.INVALID_HANDLE: + InvalidHandleException ihex = new InvalidHandleException(msg); + ihex.errorCode = (int) errorCode; + return ihex; + + case (uint) NativeMethods.Error.INSTALL_USEREXIT: return new InstallCanceledException(msg); + + case (uint) NativeMethods.Error.CALL_NOT_IMPLEMENTED: return new NotImplementedException(msg); + + default: return new InstallerException((int) errorCode, msg); + } + } + + internal static string GetSystemMessage(uint errorCode) + { + const uint FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; + const uint FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; + + StringBuilder buf = new StringBuilder(1024); + uint formatCount = NativeMethods.FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + IntPtr.Zero, + (uint) errorCode, + 0, + buf, + (uint) buf.Capacity, + IntPtr.Zero); + + if (formatCount != 0) + { + return buf.ToString().Trim(); + } + else + { + return null; + } + } + + internal void SaveErrorRecord() + { + // TODO: pass an affinity handle here? + int recordHandle = RemotableNativeMethods.MsiGetLastErrorRecord(0); + if (recordHandle != 0) + { + using (Record errorRec = new Record((IntPtr) recordHandle, true, null)) + { + this.errorData = new object[errorRec.FieldCount]; + for (int i = 0; i < this.errorData.Length; i++) + { + this.errorData[i] = errorRec[i + 1]; + } + } + } + else + { + this.errorData = null; + } + } + + private static string Combine(string msg1, string msg2) + { + if (msg1 == null) return msg2; + if (msg2 == null) return msg1; + return msg1 + " " + msg2; + } + } + + /// + /// User Canceled the installation. + /// + [Serializable] + public class InstallCanceledException : InstallerException + { + /// + /// Creates a new InstallCanceledException with a specified error message and a reference to the + /// inner exception that is the cause of this exception. + /// + /// The message that describes the error. + /// The exception that is the cause of the current exception. If the + /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception + /// is raised in a catch block that handles the inner exception. + public InstallCanceledException(string msg, Exception innerException) + : base((int) NativeMethods.Error.INSTALL_USEREXIT, msg, innerException) + { + } + + /// + /// Creates a new InstallCanceledException with a specified error message. + /// + /// The message that describes the error. + public InstallCanceledException(string msg) + : this(msg, null) + { + } + + /// + /// Creates a new InstallCanceledException. + /// + public InstallCanceledException() + : this(null, null) + { + } + + /// + /// Initializes a new instance of the InstallCanceledException class with serialized data. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + protected InstallCanceledException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + /// + /// A bad SQL query string was passed to or . + /// + [Serializable] + public class BadQuerySyntaxException : InstallerException + { + /// + /// Creates a new BadQuerySyntaxException with a specified error message and a reference to the + /// inner exception that is the cause of this exception. + /// + /// The message that describes the error. + /// The exception that is the cause of the current exception. If the + /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception + /// is raised in a catch block that handles the inner exception. + public BadQuerySyntaxException(string msg, Exception innerException) + : base((int) NativeMethods.Error.BAD_QUERY_SYNTAX, msg, innerException) + { + } + + /// + /// Creates a new BadQuerySyntaxException with a specified error message. + /// + /// The message that describes the error. + public BadQuerySyntaxException(string msg) + : this(msg, null) + { + } + + /// + /// Creates a new BadQuerySyntaxException. + /// + public BadQuerySyntaxException() + : this(null, null) + { + } + + /// + /// Initializes a new instance of the BadQuerySyntaxException class with serialized data. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + protected BadQuerySyntaxException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + /// + /// A method was called on an invalid installer handle. The handle may have been already closed. + /// + [Serializable] + public class InvalidHandleException : InstallerException + { + /// + /// Creates a new InvalidHandleException with a specified error message and a reference to the + /// inner exception that is the cause of this exception. + /// + /// The message that describes the error. + /// The exception that is the cause of the current exception. If the + /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception + /// is raised in a catch block that handles the inner exception. + public InvalidHandleException(string msg, Exception innerException) + : base((int) NativeMethods.Error.INVALID_HANDLE, msg, innerException) + { + } + + /// + /// Creates a new InvalidHandleException with a specified error message. + /// + /// The message that describes the error. + public InvalidHandleException(string msg) + : this(msg, null) + { + } + + /// + /// Creates a new InvalidHandleException. + /// + public InvalidHandleException() + : this(null, null) + { + } + + /// + /// Initializes a new instance of the InvalidHandleException class with serialized data. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + protected InvalidHandleException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } + + /// + /// A failure occurred when executing . The exception may contain + /// details about the merge conflict. + /// + [Serializable] + public class MergeException : InstallerException + { + private IList conflictTables; + private IList conflictCounts; + + /// + /// Creates a new MergeException with a specified error message and a reference to the + /// inner exception that is the cause of this exception. + /// + /// The message that describes the error. + /// The exception that is the cause of the current exception. If the + /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception + /// is raised in a catch block that handles the inner exception. + public MergeException(string msg, Exception innerException) + : base(msg, innerException) + { + } + + /// + /// Creates a new MergeException with a specified error message. + /// + /// The message that describes the error. + public MergeException(string msg) + : base(msg) + { + } + + /// + /// Creates a new MergeException. + /// + public MergeException() + : base() + { + } + + internal MergeException(Database db, string conflictsTableName) + : base("Merge failed.") + { + if (conflictsTableName != null) + { + IList conflictTableList = new List(); + IList conflictCountList = new List(); + + using (View view = db.OpenView("SELECT `Table`, `NumRowMergeConflicts` FROM `" + conflictsTableName + "`")) + { + view.Execute(); + + foreach (Record rec in view) using (rec) + { + conflictTableList.Add(rec.GetString(1)); + conflictCountList.Add((int) rec.GetInteger(2)); + } + } + + this.conflictTables = conflictTableList; + this.conflictCounts = conflictCountList; + } + } + + /// + /// Initializes a new instance of the MergeException class with serialized data. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + protected MergeException(SerializationInfo info, StreamingContext context) : base(info, context) + { + if (info == null) + { + throw new ArgumentNullException("info"); + } + + this.conflictTables = (string[]) info.GetValue("mergeConflictTables", typeof(string[])); + this.conflictCounts = (int[]) info.GetValue("mergeConflictCounts", typeof(int[])); + } + + /// + /// Gets the number of merge conflicts in each table, corresponding to the tables returned by + /// . + /// + public IList ConflictCounts + { + get + { + return new List(this.conflictCounts); + } + } + + /// + /// Gets the list of tables containing merge conflicts. + /// + public IList ConflictTables + { + get + { + return new List(this.conflictTables); + } + } + + /// + /// Gets a message that describes the merge conflits. + /// + public override String Message + { + get + { + StringBuilder msg = new StringBuilder(base.Message); + if (this.conflictTables != null) + { + for (int i = 0; i < this.conflictTables.Count; i++) + { + msg.Append(i == 0 ? " Conflicts: " : ", "); + msg.Append(this.conflictTables[i]); + msg.Append('('); + msg.Append(this.conflictCounts[i]); + msg.Append(')'); + } + } + return msg.ToString(); + } + } + + /// + /// Sets the SerializationInfo with information about the exception. + /// + /// The SerializationInfo that holds the serialized object data about the exception being thrown. + /// The StreamingContext that contains contextual information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter=true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) + { + throw new ArgumentNullException("info"); + } + + info.AddValue("mergeConflictTables", this.conflictTables); + info.AddValue("mergeConflictCounts", this.conflictCounts); + base.GetObjectData(info, context); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ExternalUIHandler.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ExternalUIHandler.cs new file mode 100644 index 00000000..08f00867 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ExternalUIHandler.cs @@ -0,0 +1,223 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + /// + /// Defines a callback function that the installer calls for progress notification and error messages. + /// + public delegate MessageResult ExternalUIHandler( + InstallMessage messageType, + string message, + MessageButtons buttons, + MessageIcon icon, + MessageDefaultButton defaultButton); + + /// + /// [MSI 3.1] Defines a callback function that the installer calls for record-based progress notification and error messages. + /// + public delegate MessageResult ExternalUIRecordHandler( + InstallMessage messageType, + Record messageRecord, + MessageButtons buttons, + MessageIcon icon, + MessageDefaultButton defaultButton); + + internal delegate int NativeExternalUIHandler(IntPtr context, int messageType, [MarshalAs(UnmanagedType.LPWStr)] string message); + + internal delegate int NativeExternalUIRecordHandler(IntPtr context, int messageType, int recordHandle); + + internal class ExternalUIProxy + { + private ExternalUIHandler handler; + + internal ExternalUIProxy(ExternalUIHandler handler) + { + this.handler = handler; + } + + public ExternalUIHandler Handler + { + get { return this.handler; } + } + + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + public int ProxyHandler(IntPtr contextPtr, int messageType, [MarshalAs(UnmanagedType.LPWStr)] string message) + { + try + { + int msgType = messageType & 0x7F000000; + int buttons = messageType & 0x0000000F; + int icon = messageType & 0x000000F0; + int defButton = messageType & 0x00000F00; + + return (int) this.handler( + (InstallMessage) msgType, + message, + (MessageButtons) buttons, + (MessageIcon) icon, + (MessageDefaultButton) defButton); + } + catch + { + return (int) MessageResult.Error; + } + } + } + + internal class ExternalUIRecordProxy + { + private ExternalUIRecordHandler handler; + + internal ExternalUIRecordProxy(ExternalUIRecordHandler handler) + { + this.handler = handler; + } + + public ExternalUIRecordHandler Handler + { + get { return this.handler; } + } + + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + public int ProxyHandler(IntPtr contextPtr, int messageType, int recordHandle) + { + try + { + int msgType = messageType & 0x7F000000; + int buttons = messageType & 0x0000000F; + int icon = messageType & 0x000000F0; + int defButton = messageType & 0x00000F00; + + Record msgRec = (recordHandle != 0 ? Record.FromHandle((IntPtr) recordHandle, false) : null); + using (msgRec) + { + return (int) this.handler( + (InstallMessage) msgType, + msgRec, + (MessageButtons) buttons, + (MessageIcon) icon, + (MessageDefaultButton) defButton); + } + } + catch + { + return (int) MessageResult.Error; + } + } + } + + public static partial class Installer + { + private static IList externalUIHandlers = ArrayList.Synchronized(new ArrayList()); + + /// + /// Enables an external user-interface handler. This external UI handler is called before the + /// normal internal user-interface handler. The external UI handler has the option to suppress + /// the internal UI by returning a non-zero value to indicate that it has handled the messages. + /// + /// A callback delegate that handles the UI messages + /// Specifies which messages to handle using the external message handler. + /// If the external handler returns a non-zero result, then that message will not be sent to the UI, + /// instead the message will be logged if logging has been enabled. + /// The previously set external handler, or null if there was no previously set handler + ///

+ /// To restore the previous UI handler, a second call is made to SetExternalUI using the + /// ExternalUIHandler returned by the first call to SetExternalUI and specifying + /// as the message filter. + ///

+ /// The external user interface handler does not have full control over the external user + /// interface unless is called with the uiLevel parameter set to + /// . If SetInternalUI is not called, the internal user + /// interface level defaults to . As a result, any message not + /// handled by the external user interface handler is handled by Windows Installer. The initial + /// "Preparing to install..." dialog always appears even if the external user interface + /// handler handles all messages. + ///

+ /// SetExternalUI should only be called from a bootstrapping application. You cannot call + /// it from a custom action + ///

+ /// Win32 MSI API: + /// MsiSetExternalUI + ///

+ public static ExternalUIHandler SetExternalUI(ExternalUIHandler uiHandler, InstallLogModes messageFilter) + { + NativeExternalUIHandler nativeHandler = null; + if (uiHandler != null) + { + nativeHandler = new ExternalUIProxy(uiHandler).ProxyHandler; + Installer.externalUIHandlers.Add(nativeHandler); + } + NativeExternalUIHandler oldNativeHandler = NativeMethods.MsiSetExternalUI(nativeHandler, (uint) messageFilter, IntPtr.Zero); + if (oldNativeHandler != null && oldNativeHandler.Target is ExternalUIProxy) + { + Installer.externalUIHandlers.Remove(oldNativeHandler); + return ((ExternalUIProxy) oldNativeHandler.Target).Handler; + } + else + { + return null; + } + } + + /// + /// [MSI 3.1] Enables a record-based external user-interface handler. This external UI handler is called + /// before the normal internal user-interface handler. The external UI handler has the option to suppress + /// the internal UI by returning a non-zero value to indicate that it has handled the messages. + /// + /// A callback delegate that handles the UI messages + /// Specifies which messages to handle using the external message handler. + /// If the external handler returns a non-zero result, then that message will not be sent to the UI, + /// instead the message will be logged if logging has been enabled. + /// The previously set external handler, or null if there was no previously set handler + ///

+ /// To restore the previous UI handler, a second call is made to SetExternalUI using the + /// ExternalUIHandler returned by the first call to SetExternalUI and specifying + /// as the message filter. + ///

+ /// The external user interface handler does not have full control over the external user + /// interface unless is called with the uiLevel parameter set to + /// . If SetInternalUI is not called, the internal user + /// interface level defaults to . As a result, any message not + /// handled by the external user interface handler is handled by Windows Installer. The initial + /// "Preparing to install..." dialog always appears even if the external user interface + /// handler handles all messages. + ///

+ /// SetExternalUI should only be called from a bootstrapping application. You cannot call + /// it from a custom action + ///

+ /// Win32 MSI API: + /// MsiSetExternalUIRecord + ///

+ public static ExternalUIRecordHandler SetExternalUI(ExternalUIRecordHandler uiHandler, InstallLogModes messageFilter) + { + NativeExternalUIRecordHandler nativeHandler = null; + if (uiHandler != null) + { + nativeHandler = new ExternalUIRecordProxy(uiHandler).ProxyHandler; + Installer.externalUIHandlers.Add(nativeHandler); + } + NativeExternalUIRecordHandler oldNativeHandler; + uint ret = NativeMethods.MsiSetExternalUIRecord(nativeHandler, (uint) messageFilter, IntPtr.Zero, out oldNativeHandler); + if (ret != 0) + { + Installer.externalUIHandlers.Remove(nativeHandler); + throw InstallerException.ExceptionFromReturnCode(ret); + } + + if (oldNativeHandler != null && oldNativeHandler.Target is ExternalUIRecordProxy) + { + Installer.externalUIHandlers.Remove(oldNativeHandler); + return ((ExternalUIRecordProxy) oldNativeHandler.Target).Handler; + } + else + { + return null; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInfo.cs new file mode 100644 index 00000000..9a1a859a --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInfo.cs @@ -0,0 +1,497 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections; + using System.Collections.Generic; + + /// + /// Accessor for information about features within the context of an installation session. + /// + public sealed class FeatureInfoCollection : ICollection + { + private Session session; + + internal FeatureInfoCollection(Session session) + { + this.session = session; + } + + /// + /// Gets information about a feature within the context of an installation session. + /// + /// name of the feature + /// feature object + public FeatureInfo this[string feature] + { + get + { + return new FeatureInfo(this.session, feature); + } + } + + void ICollection.Add(FeatureInfo item) + { + throw new InvalidOperationException(); + } + + void ICollection.Clear() + { + throw new InvalidOperationException(); + } + + /// + /// Checks if the collection contains a feature. + /// + /// name of the feature + /// true if the feature is in the collection, else false + public bool Contains(string feature) + { + return this.session.Database.CountRows( + "Feature", "`Feature` = '" + feature + "'") == 1; + } + + bool ICollection.Contains(FeatureInfo item) + { + return item != null && this.Contains(item.Name); + } + + /// + /// Copies the features into an array. + /// + /// array that receives the features + /// offset into the array + public void CopyTo(FeatureInfo[] array, int arrayIndex) + { + foreach (FeatureInfo feature in this) + { + array[arrayIndex++] = feature; + } + } + + /// + /// Gets the number of features defined for the product. + /// + public int Count + { + get + { + return this.session.Database.CountRows("Feature"); + } + } + + bool ICollection.IsReadOnly + { + get + { + return true; + } + } + + bool ICollection.Remove(FeatureInfo item) + { + throw new InvalidOperationException(); + } + + /// + /// Enumerates the features in the collection. + /// + /// an enumerator over all features in the collection + public IEnumerator GetEnumerator() + { + using (View featureView = this.session.Database.OpenView( + "SELECT `Feature` FROM `Feature`")) + { + featureView.Execute(); + + foreach (Record featureRec in featureView) using (featureRec) + { + string feature = featureRec.GetString(1); + yield return new FeatureInfo(this.session, feature); + } + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } + + /// + /// Provides access to information about a feature within the context of an installation session. + /// + public class FeatureInfo + { + private Session session; + private string name; + + internal FeatureInfo(Session session, string name) + { + this.session = session; + this.name = name; + } + + /// + /// Gets the name of the feature (primary key in the Feature table). + /// + public string Name + { + get + { + return this.name; + } + } + + /// + /// Gets the current install state of the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// Win32 MSI API: + /// MsiGetFeatureState + ///

+ public InstallState CurrentState + { + get + { + int installState, actionState; + uint ret = RemotableNativeMethods.MsiGetFeatureState((int) this.session.Handle, this.name, out installState, out actionState); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_FEATURE) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + if (installState == (int) InstallState.Advertised) + { + return InstallState.Advertised; + } + return (InstallState) installState; + } + } + + /// + /// Gets or sets the action state of the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// When changing the feature action, the action state of all the Components linked to the changed + /// Feature records are also updated appropriately, based on the new feature Select state. + /// All Features can be configured at once by specifying the keyword ALL instead of a specific feature name. + ///

+ /// Win32 MSI APIs: + /// MsiGetFeatureState, + /// MsiSetFeatureState + ///

+ public InstallState RequestState + { + get + { + int installState, actionState; + uint ret = RemotableNativeMethods.MsiGetFeatureState((int) this.session.Handle, this.name, out installState, out actionState); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_FEATURE) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return (InstallState) actionState; + } + + set + { + uint ret = RemotableNativeMethods.MsiSetFeatureState((int) this.session.Handle, this.name, (int) value); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_FEATURE) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + } + + /// + /// Gets a list of valid installation states for the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// Win32 MSI API: + /// MsiGetFeatureValidStates + ///

+ public ICollection ValidStates + { + get + { + List states = new List(); + uint installState; + uint ret = RemotableNativeMethods.MsiGetFeatureValidStates((int) this.session.Handle, this.name, out installState); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_FEATURE) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + for (int i = 1; i <= (int) InstallState.Default; i++) + { + if (((int) installState & (1 << i)) != 0) + { + states.Add((InstallState) i); + } + } + return states.AsReadOnly(); + } + } + + /// + /// Gets or sets the attributes of the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// Win32 MSI APIs: + /// MsiGetFeatureInfo, + /// MsiSetFeatureAttributes + ///

+ /// Since the lpAttributes paramter of + /// MsiGetFeatureInfo + /// does not contain an equivalent flag for , this flag will + /// not be retrieved. + ///

+ /// Since the dwAttributes parameter of + /// MsiSetFeatureAttributes + /// does not contain an equivalent flag for , the presence + /// of this flag will be ignored. + ///

+ public FeatureAttributes Attributes + { + get + { + FeatureAttributes attributes; + uint titleBufSize = 0; + uint descBufSize = 0; + uint attr; + uint ret = NativeMethods.MsiGetFeatureInfo( + (int) this.session.Handle, + this.name, + out attr, + null, + ref titleBufSize, + null, + ref descBufSize); + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + // Values for attributes that MsiGetFeatureInfo returns are + // double the values in the Attributes column of the Feature Table. + attributes = (FeatureAttributes) (attr >> 1); + + // MsiGetFeatureInfo MSDN documentation indicates + // NOUNSUPPORTEDADVERTISE is 32. Conversion above changes this to 16 + // which is UIDisallowAbsent. MsiGetFeatureInfo isn't documented to + // return an attribute for 'UIDisallowAbsent', so if UIDisallowAbsent + // is set, change it to NoUnsupportedAdvertise which then maps correctly + // to NOUNSUPPORTEDADVERTISE. + if ((attributes & FeatureAttributes.UIDisallowAbsent) == FeatureAttributes.UIDisallowAbsent) + { + attributes &= ~FeatureAttributes.UIDisallowAbsent; + attributes |= FeatureAttributes.NoUnsupportedAdvertise; + } + + return attributes; + } + + set + { + // MsiSetFeatureAttributes doesn't indicate UIDisallowAbsent is valid + // so remove it. + FeatureAttributes attributes = value; + attributes &= ~FeatureAttributes.UIDisallowAbsent; + + // Values for attributes that MsiSetFeatureAttributes uses are + // double the values in the Attributes column of the Feature Table. + uint attr = ((uint) attributes) << 1; + + // MsiSetFeatureAttributes MSDN documentation indicates + // NOUNSUPPORTEDADVERTISE is 32. Conversion above changes this to 64 + // which is undefined. Change this back to 32. + uint noUnsupportedAdvertiseDbl = ((uint)FeatureAttributes.NoUnsupportedAdvertise) << 1; + if ((attr & noUnsupportedAdvertiseDbl) == noUnsupportedAdvertiseDbl) + { + attr &= ~noUnsupportedAdvertiseDbl; + attr |= (uint) FeatureAttributes.NoUnsupportedAdvertise; + } + + uint ret = RemotableNativeMethods.MsiSetFeatureAttributes((int) this.session.Handle, this.name, attr); + + if (ret != (uint)NativeMethods.Error.SUCCESS) + { + if (ret == (uint)NativeMethods.Error.UNKNOWN_FEATURE) + { + throw InstallerException.ExceptionFromReturnCode(ret, this.name); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + } + + /// + /// Gets the title of the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// Win32 MSI API: + /// MsiGetFeatureInfo + ///

+ public string Title + { + get + { + StringBuilder titleBuf = new StringBuilder(80); + uint titleBufSize = (uint) titleBuf.Capacity; + uint descBufSize = 0; + uint attr; + uint ret = NativeMethods.MsiGetFeatureInfo( + (int) this.session.Handle, + this.name, + out attr, + titleBuf, + ref titleBufSize, + null, + ref descBufSize); + + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + titleBuf.Capacity = (int) ++titleBufSize; + ret = NativeMethods.MsiGetFeatureInfo( + (int) this.session.Handle, + this.name, + out attr, + titleBuf, + ref titleBufSize, + null, + ref descBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + return titleBuf.ToString(); + } + } + + /// + /// Gets the description of the feature. + /// + /// the Session handle is invalid + /// an unknown feature was requested + ///

+ /// Win32 MSI API: + /// MsiGetFeatureInfo + ///

+ public string Description + { + get + { + StringBuilder descBuf = new StringBuilder(256); + uint titleBufSize = 0; + uint descBufSize = (uint) descBuf.Capacity; + uint attr; + uint ret = NativeMethods.MsiGetFeatureInfo( + (int) this.session.Handle, + this.name, + out attr, + null, + ref titleBufSize, + descBuf, + ref descBufSize); + + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + descBuf.Capacity = (int) ++descBufSize; + ret = NativeMethods.MsiGetFeatureInfo( + (int) this.session.Handle, + this.name, + out attr, + null, + ref titleBufSize, + descBuf, + ref descBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + return descBuf.ToString(); + } + } + + /// + /// Calculates the disk space required by the feature and its selected children and parent features. + /// + /// If true, the parent features are included in the cost. + /// If true, the child features are included in the cost. + /// Specifies the installation state. + /// The disk space requirement in bytes. + ///

+ /// Win32 MSI API: + /// MsiGetFeatureCost + ///

+ public long GetCost(bool includeParents, bool includeChildren, InstallState installState) + { + const int MSICOSTTREE_CHILDREN = 1; + const int MSICOSTTREE_PARENTS = 2; + + int cost; + uint ret = RemotableNativeMethods.MsiGetFeatureCost( + (int) this.session.Handle, + this.name, + (includeParents ? MSICOSTTREE_PARENTS : 0) | (includeChildren ? MSICOSTTREE_CHILDREN : 0), + (int) installState, + out cost); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return cost * 512L; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInstallation.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInstallation.cs new file mode 100644 index 00000000..aa8ffe34 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/FeatureInstallation.cs @@ -0,0 +1,174 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + + /// + /// Represents an instance of a feature of an installed product. + /// + public class FeatureInstallation : InstallationPart + { + /// + /// Creates a new FeatureInstallation instance for a feature of a product. + /// + /// feature name + /// ProductCode GUID + public FeatureInstallation(string featureName, string productCode) + : base(featureName, productCode) + { + if (String.IsNullOrEmpty(featureName)) + { + throw new ArgumentNullException("featureName"); + } + } + + /// + /// Gets the name of the feature. + /// + public string FeatureName + { + get + { + return this.Id; + } + } + + /// + /// Gets the installed state of the feature. + /// + ///

+ /// Win32 MSI API: + /// MsiQueryFeatureState + ///

+ public override InstallState State + { + get + { + int installState = NativeMethods.MsiQueryFeatureState( + this.ProductCode, this.FeatureName); + return (InstallState) installState; + } + } + + /// + /// Gets the parent of the feature, or null if the feature has no parent (it is a root feature). + /// + /// + /// Invocation of this property may be slightly costly for products with many features, + /// because it involves an enumeration of all the features in the product. + /// + public FeatureInstallation Parent + { + get + { + StringBuilder featureBuf = new StringBuilder(256); + StringBuilder parentBuf = new StringBuilder(256); + for (uint i = 0; ; i++) + { + uint ret = NativeMethods.MsiEnumFeatures(this.ProductCode, i, featureBuf, parentBuf); + + if (ret != 0) + { + break; + } + + if (featureBuf.ToString() == this.FeatureName) + { + if (parentBuf.Length > 0) + { + return new FeatureInstallation(parentBuf.ToString(), this.ProductCode); + } + else + { + return null; + } + } + } + + return null; + } + } + + /// + /// Gets the usage metrics for the feature. + /// + ///

+ /// If no usage metrics are recorded, the value is 0. + ///

+ /// Win32 MSI API: + /// MsiGetFeatureUsage + ///

+ public FeatureInstallation.UsageData Usage + { + get + { + uint useCount; + ushort useDate; + uint ret = NativeMethods.MsiGetFeatureUsage( + this.ProductCode, this.FeatureName, out useCount, out useDate); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + DateTime lastUsedDate; + if (useCount == 0) + { + lastUsedDate = DateTime.MinValue; + } + else + { + lastUsedDate = new DateTime( + 1980 + (useDate >> 9), + (useDate & 0x01FF) >> 5, + (useDate & 0x001F)); + } + + return new UsageData((int) useCount, lastUsedDate); + } + } + + /// + /// Holds data about the usage of a feature. + /// + [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + public struct UsageData + { + private int useCount; + private DateTime lastUsedDate; + + internal UsageData(int useCount, DateTime lastUsedDate) + { + this.useCount = useCount; + this.lastUsedDate = lastUsedDate; + } + + /// + /// Gets count of the number of times the feature has been used. + /// + public int UseCount + { + get + { + return this.useCount; + } + } + + /// + /// Gets the date the feature was last used. + /// + public DateTime LastUsedDate + { + get + { + return this.lastUsedDate; + } + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Handle.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Handle.cs new file mode 100644 index 00000000..c3d3625f --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Handle.cs @@ -0,0 +1,154 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + + /// + /// Base class for Windows Installer handle types (Database, View, Record, SummaryInfo). + /// + ///

+ /// These classes implement the interface, because they + /// hold unmanaged resources (MSI handles) that should be properly disposed + /// when no longer needed. + ///

+ public abstract class InstallerHandle : MarshalByRefObject, IDisposable + { + private NativeMethods.MsiHandle handle; + + /// + /// Constructs a handle object from a native integer handle. + /// + /// Native integer handle. + /// true to close the handle when this object is disposed or finalized + protected InstallerHandle(IntPtr handle, bool ownsHandle) + { + if (handle == IntPtr.Zero) + { + throw new InvalidHandleException(); + } + + this.handle = new NativeMethods.MsiHandle(handle, ownsHandle); + } + + /// + /// Gets the native integer handle. + /// + [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + public IntPtr Handle + { + get + { + if (this.IsClosed) + { + throw new InvalidHandleException(); + } + return this.handle; + } + } + + /// + /// Checks if the handle is closed. When closed, method calls on the handle object may throw an . + /// + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] + public bool IsClosed + { + get + { + return this.handle.IsClosed; + } + } + + /// + /// Closes the handle. After closing a handle, further method calls may throw an . + /// + ///

+ /// The finalizer of this class will NOT close the handle if it is still open, + /// because finalization can run on a separate thread from the application, + /// resulting in potential problems if handles are closed from that thread. + /// It is best that the handle be closed manually as soon as it is no longer needed, + /// as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiCloseHandle + ///

+ /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Closes the handle. After closing a handle, further method calls may throw an . + /// + ///

+ /// The finalizer of this class will NOT close the handle if it is still open, + /// because finalization can run on a separate thread from the application, + /// resulting in potential problems if handles are closed from that thread. + /// It is best that the handle be closed manually as soon as it is no longer needed, + /// as leaving lots of unused handles open can degrade performance. + ///

+ /// This method is merely an alias for the method. + ///

+ /// Win32 MSI API: + /// MsiCloseHandle + ///

+ public void Close() + { + this.Dispose(); + } + + /// + /// Tests whether this handle object is equal to another handle object. Two handle objects are equal + /// if their types are the same and their native integer handles are the same. + /// + /// The handle object to compare with the current handle object. + /// true if the specified handle object is equal to the current handle object; otherwise false + public override bool Equals(object obj) + { + return (obj != null && this.GetType() == obj.GetType() && + this.Handle == ((InstallerHandle) obj).Handle); + } + + /// + /// Gets a hash value for the handle object. + /// + /// A hash code for the handle object. + ///

+ /// The hash code is derived from the native integer handle. + ///

+ public override int GetHashCode() + { + return this.Handle.GetHashCode(); + } + + /// + /// Gets an object that can be used internally for safe syncronization. + /// + internal object Sync + { + get + { + return this.handle; + } + } + + /// + /// Closes the handle. After closing a handle, further method calls may throw an . + /// + /// If true, the method has been called directly or indirectly by a user's code, + /// so managed and unmanaged resources will be disposed. If false, the method has been called by the + /// runtime from inside the finalizer, and only unmanaged resources will be disposed. + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + this.handle.Dispose(); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/IEmbeddedUI.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/IEmbeddedUI.cs new file mode 100644 index 00000000..d77c82a9 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/IEmbeddedUI.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System.Diagnostics.CodeAnalysis; + + /// + /// [MSI 4.5] Interface for an embedded external user interface for an installation. + /// + /// + /// Classes which implement this interface must have a public constructor that takes no parameters. + /// + public interface IEmbeddedUI + { + /// + /// Initializes the embedded UI. + /// + /// Handle to the installer which can be used to get and set properties. + /// The handle is only valid for the duration of this method call. + /// Path to the directory that contains all the files from the MsiEmbeddedUI table. + /// On entry, contains the current UI level for the installation. After this + /// method returns, the installer resets the UI level to the returned value of this parameter. + /// True if the embedded UI was successfully initialized; false if the installation + /// should continue without the embedded UI. + /// The installation was canceled by the user. + /// The embedded UI failed to initialize and + /// causes the installation to fail. + ///

+ /// Win32 MSI API: + /// InitializeEmbeddedUI + ///

+ [SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")] + bool Initialize(Session session, string resourcePath, ref InstallUIOptions internalUILevel); + + /// + /// Processes information and progress messages sent to the user interface. + /// + /// Message type. + /// Record that contains message data. + /// Message buttons. + /// Message box icon. + /// Message box default button. + /// Result of processing the message. + ///

+ /// Win32 MSI API: + /// EmbeddedUIHandler + ///

+ MessageResult ProcessMessage( + InstallMessage messageType, + Record messageRecord, + MessageButtons buttons, + MessageIcon icon, + MessageDefaultButton defaultButton); + + /// + /// Shuts down the embedded UI at the end of the installation. + /// + /// + /// If the installation was canceled during initialization, this method will not be called. + /// If the installation was canceled or failed at any later point, this method will be called at the end. + ///

+ /// Win32 MSI API: + /// ShutdownEmbeddedUI + ///

+ void Shutdown(); + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallCost.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallCost.cs new file mode 100644 index 00000000..f29612d6 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallCost.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System.Diagnostics.CodeAnalysis; + + /// + /// Represents a per-drive disk space cost for an installation. + /// + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + public struct InstallCost + { + private string driveName; + private long cost; + private long tempCost; + + /// + /// Creates a new InstallCost object. + /// + /// name of the drive this cost data applies to + /// installation cost on this drive, as a number of bytes + /// temporary disk space required on this drive, as a number of bytes + internal InstallCost(string driveName, long cost, long tempCost) + { + this.driveName = driveName; + this.cost = cost; + this.tempCost = tempCost; + } + + /// + /// The name of the drive this cost data applies to. + /// + public string DriveName + { + get + { + return this.driveName; + } + } + + /// + /// The installation cost on this drive, as a number of bytes. + /// + public long Cost + { + get + { + return this.cost; + } + } + + /// + /// The temporary disk space required on this drive, as a number of bytes. + /// + ///

+ /// This temporary space requirement is space needed only for the duration + /// of the installation, over the final footprint on disk. + ///

+ public long TempCost + { + get + { + return this.tempCost; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installation.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installation.cs new file mode 100644 index 00000000..47ca00a1 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installation.cs @@ -0,0 +1,100 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Globalization; + + /// + /// Subclasses of this abstract class represent a unique instance of a + /// registered product or patch installation. + /// + public abstract class Installation + { + private string installationCode; + private string userSid; + private UserContexts context; + private SourceList sourceList; + + internal Installation(string installationCode, string userSid, UserContexts context) + { + if (context == UserContexts.Machine) + { + userSid = null; + } + this.installationCode = installationCode; + this.userSid = userSid; + this.context = context; + } + + /// + /// Gets the user security identifier (SID) under which this product or patch + /// installation is available. + /// + public string UserSid + { + get + { + return this.userSid; + } + } + + /// + /// Gets the user context of this product or patch installation. + /// + public UserContexts Context + { + get + { + return this.context; + } + } + + /// + /// Gets the source list of this product or patch installation. + /// + public virtual SourceList SourceList + { + get + { + if (this.sourceList == null) + { + this.sourceList = new SourceList(this); + } + return this.sourceList; + } + } + + /// + /// Gets a value indicating whether this product or patch is installed on the current system. + /// + public abstract bool IsInstalled + { + get; + } + + internal string InstallationCode + { + get + { + return this.installationCode; + } + } + + internal abstract int InstallationType + { + get; + } + + /// + /// Gets a property about the product or patch installation. + /// + /// Name of the property being retrieved. + /// + public abstract string this[string propertyName] + { + get; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallationPart.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallationPart.cs new file mode 100644 index 00000000..ce5a6a94 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallationPart.cs @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + /// + /// Subclasses of this abstract class represent an instance + /// of a registered feature or component. + /// + public abstract class InstallationPart + { + private string id; + private string productCode; + private string userSid; + private UserContexts context; + + internal InstallationPart(string id, string productCode) + : this(id, productCode, null, UserContexts.None) + { + } + + internal InstallationPart(string id, string productCode, string userSid, UserContexts context) + { + this.id = id; + this.productCode = productCode; + this.userSid = userSid; + this.context = context; + } + + internal string Id + { + get + { + return this.id; + } + } + + internal string ProductCode + { + get + { + return this.productCode; + } + } + + internal string UserSid + { + get + { + return this.userSid; + } + } + + internal UserContexts Context + { + get + { + return this.context; + } + } + + /// + /// Gets the product that this item is a part of. + /// + public ProductInstallation Product + { + get + { + return this.productCode != null ? + new ProductInstallation(this.productCode, userSid, context) : null; + } + } + + /// + /// Gets the current installation state of the item. + /// + public abstract InstallState State + { + get; + } + } + +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installer.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installer.cs new file mode 100644 index 00000000..8df0aed9 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Installer.cs @@ -0,0 +1,890 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Resources; + using System.Reflection; + using System.Collections.Generic; + using System.Globalization; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + +/// +/// Receives an exception from +/// +/// indicating the reason a particular patch is not applicable to a product. +/// +/// MSP file path, XML file path, or XML blob that was passed to +/// +/// exception indicating the reason the patch is not applicable +///

+/// If is an or subclass, then +/// its and +/// properties will indicate a more specific reason the patch was not applicable. +///

+/// The could also be a FileNotFoundException if the +/// patch string was a file path. +///

+public delegate void InapplicablePatchHandler(string patch, Exception exception); + +/// +/// Provides static methods for installing and configuring products and patches. +/// +public static partial class Installer +{ + private static bool rebootRequired; + private static bool rebootInitiated; + private static ResourceManager errorResources; + + /// + /// Indicates whether a system reboot is required after running an installation or configuration operation. + /// + public static bool RebootRequired + { + get + { + return Installer.rebootRequired; + } + } + + /// + /// Indicates whether a system reboot has been initiated after running an installation or configuration operation. + /// + public static bool RebootInitiated + { + get + { + return Installer.rebootInitiated; + } + } + + /// + /// Enables the installer's internal user interface. Then this user interface is used + /// for all subsequent calls to user-interface-generating installer functions in this process. + /// + /// Specifies the level of complexity of the user interface + /// Handle to a window, which becomes the owner of any user interface created. + /// A pointer to the previous owner of the user interface is returned. + /// The previous user interface level + ///

+ /// Win32 MSI API: + /// MsiSetInternalUI + ///

+ [SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")] + public static InstallUIOptions SetInternalUI(InstallUIOptions uiOptions, ref IntPtr windowHandle) + { + return (InstallUIOptions) NativeMethods.MsiSetInternalUI((uint) uiOptions, ref windowHandle); + } + + /// + /// Enables the installer's internal user interface. Then this user interface is used + /// for all subsequent calls to user-interface-generating installer functions in this process. + /// The owner of the user interface does not change. + /// + /// Specifies the level of complexity of the user interface + /// The previous user interface level + ///

+ /// Win32 MSI API: + /// MsiSetInternalUI + ///

+ public static InstallUIOptions SetInternalUI(InstallUIOptions uiOptions) + { + return (InstallUIOptions) NativeMethods.MsiSetInternalUI((uint) uiOptions, IntPtr.Zero); + } + + /// + /// Enables logging of the selected message type for all subsequent install sessions in + /// the current process space. + /// + /// One or more mode flags specifying the type of messages to log + /// Full path to the log file. A null path disables logging, + /// in which case the logModes paraneter is ignored. + /// an invalid log mode was specified + /// This method takes effect on any new installation processes. Calling this + /// method from within a custom action will not start logging for that installation. + public static void EnableLog(InstallLogModes logModes, string logFile) + { + Installer.EnableLog(logModes, logFile, false, true); + } + + /// + /// Enables logging of the selected message type for all subsequent install sessions in + /// the current process space. + /// + /// One or more mode flags specifying the type of messages to log + /// Full path to the log file. A null path disables logging, + /// in which case the logModes paraneter is ignored. + /// If true, the log lines will be appended to any existing file content. + /// If false, the log file will be truncated if it exists. The default is false. + /// If true, the log will be flushed after every line. + /// If false, the log will be flushed every 20 lines. The default is true. + /// an invalid log mode was specified + ///

+ /// This method takes effect on any new installation processes. Calling this + /// method from within a custom action will not start logging for that installation. + ///

+ /// Win32 MSI API: + /// MsiEnableLog + ///

+ public static void EnableLog(InstallLogModes logModes, string logFile, bool append, bool flushEveryLine) + { + uint ret = NativeMethods.MsiEnableLog((uint) logModes, logFile, (append ? (uint) 1 : 0) + (flushEveryLine ? (uint) 2 : 0)); + if (ret != 0 && ret != (uint) NativeMethods.Error.FILE_INVALID) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// increments the usage count for a particular feature and returns the installation state for + /// that feature. This method should be used to indicate an application's intent to use a feature. + /// + /// The product code of the product. + /// The feature to be used. + /// Must have the value . + /// The installed state of the feature. + ///

+ /// The UseFeature method should only be used on features known to be published. The application + /// should determine the status of the feature by calling either the FeatureState method or + /// Features method. + ///

+ /// Win32 MSI APIs: + /// MsiUseFeature, + /// MsiUseFeatureEx + ///

+ public static InstallState UseFeature(string productCode, string feature, InstallMode installMode) + { + int installState = NativeMethods.MsiUseFeatureEx(productCode, feature, unchecked ((uint) installMode), 0); + return (InstallState) installState; + } + + /// + /// Opens an installer package for use with functions that access the product database and install engine, + /// returning an Session object. + /// + /// Path to the package + /// Specifies whether or not the create a Session object that ignores the + /// computer state and that is incapable of changing the current computer state. A value of false yields + /// the normal behavior. A value of true creates a "safe" Session object that cannot change of the current + /// machine state. + /// A Session object allowing access to the product database and install engine + /// The product could not be opened + /// The installer configuration data is corrupt + ///

+ /// Note that only one Session object can be opened by a single process. OpenPackage cannot be used in a + /// custom action because the active installation is the only session allowed. + ///

+ /// A "safe" Session object ignores the current computer state when opening the package and prevents + /// changes to the current computer state. + ///

+ /// The Session object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI APIs: + /// MsiOpenPackage, + /// MsiOpenPackageEx + ///

+ public static Session OpenPackage(string packagePath, bool ignoreMachineState) + { + int sessionHandle; + uint ret = NativeMethods.MsiOpenPackageEx(packagePath, ignoreMachineState ? (uint) 1 : 0, out sessionHandle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return new Session((IntPtr) sessionHandle, true); + } + + /// + /// Opens an installer package for use with functions that access the product database and install engine, + /// returning an Session object. + /// + /// Database used to create the session + /// Specifies whether or not the create a Session object that ignores the + /// computer state and that is incapable of changing the current computer state. A value of false yields + /// the normal behavior. A value of true creates a "safe" Session object that cannot change of the current + /// machine state. + /// A Session object allowing access to the product database and install engine + /// The product could not be opened + /// The installer configuration data is corrupt + ///

+ /// Note that only one Session object can be opened by a single process. OpenPackage cannot be used in a + /// custom action because the active installation is the only session allowed. + ///

+ /// A "safe" Session object ignores the current computer state when opening the package and prevents + /// changes to the current computer state. + ///

+ /// The Session object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI APIs: + /// MsiOpenPackage, + /// MsiOpenPackageEx + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public static Session OpenPackage(Database database, bool ignoreMachineState) + { + if (database == null) + { + throw new ArgumentNullException("database"); + } + + return Installer.OpenPackage( + String.Format(CultureInfo.InvariantCulture, "#{0}", database.Handle), + ignoreMachineState); + } + + /// + /// Opens an installer package for an installed product using the product code. + /// + /// Product code of the installed product + /// A Session object allowing access to the product database and install engine, + /// or null if the specified product is not installed. + /// An unknown product was requested + /// The product could not be opened + /// The installer configuration data is corrupt + ///

+ /// Note that only one Session object can be opened by a single process. OpenProduct cannot be + /// used in a custom action because the active installation is the only session allowed. + ///

+ /// The Session object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiOpenProduct + ///

+ public static Session OpenProduct(string productCode) + { + int sessionHandle; + uint ret = NativeMethods.MsiOpenProduct(productCode, out sessionHandle); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_PRODUCT) + { + return null; + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return new Session((IntPtr) sessionHandle, true); + } + + /// + /// Gets the full component path, performing any necessary installation. This method prompts for source if + /// necessary and increments the usage count for the feature. + /// + /// Product code for the product that contains the feature with the necessary component + /// Feature ID of the feature with the necessary component + /// Component code of the necessary component + /// Installation mode; this can also include bits from + /// Path to the component + ///

+ /// Win32 MSI API: + /// MsiProvideComponent + ///

+ public static string ProvideComponent(string product, string feature, string component, InstallMode installMode) + { + StringBuilder pathBuf = new StringBuilder(512); + uint pathBufSize = (uint) pathBuf.Capacity; + uint ret = NativeMethods.MsiProvideComponent(product, feature, component, unchecked((uint)installMode), pathBuf, ref pathBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + pathBuf.Capacity = (int) ++pathBufSize; + ret = NativeMethods.MsiProvideComponent(product, feature, component, unchecked((uint)installMode), pathBuf, ref pathBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return pathBuf.ToString(); + } + + /// + /// Gets the full component path for a qualified component that is published by a product and + /// performs any necessary installation. This method prompts for source if necessary and increments + /// the usage count for the feature. + /// + /// Specifies the component ID for the requested component. This may not be the + /// GUID for the component itself but rather a server that provides the correct functionality, as in the + /// ComponentId column of the PublishComponent table. + /// Specifies a qualifier into a list of advertising components (from PublishComponent Table). + /// Installation mode; this can also include bits from + /// Optional; specifies the product to match that has published the qualified component. + /// Path to the component + ///

+ /// Win32 MSI APIs: + /// MsiProvideQualifiedComponent + /// MsiProvideQualifiedComponentEx + ///

+ public static string ProvideQualifiedComponent(string component, string qualifier, InstallMode installMode, string product) + { + StringBuilder pathBuf = new StringBuilder(512); + uint pathBufSize = (uint) pathBuf.Capacity; + uint ret = NativeMethods.MsiProvideQualifiedComponentEx(component, qualifier, unchecked((uint)installMode), product, 0, 0, pathBuf, ref pathBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + pathBuf.Capacity = (int) ++pathBufSize; + ret = NativeMethods.MsiProvideQualifiedComponentEx(component, qualifier, unchecked((uint)installMode), product, 0, 0, pathBuf, ref pathBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return pathBuf.ToString(); + } + + /// + /// Gets the full path to a Windows Installer component containing an assembly. This method prompts for a source and + /// increments the usage count for the feature. + /// + /// Assembly name + /// Set to null for global assemblies. For private assemblies, set to the full path of the + /// application configuration file (.cfg file) or executable file (.exe) of the application to which the assembly + /// has been made private. + /// Installation mode; this can also include bits from + /// True if this is a Win32 assembly, false if it is a .NET assembly + /// Path to the assembly + ///

+ /// Win32 MSI API: + /// MsiProvideAssembly + ///

+ public static string ProvideAssembly(string assemblyName, string appContext, InstallMode installMode, bool isWin32Assembly) + { + StringBuilder pathBuf = new StringBuilder(512); + uint pathBufSize = (uint) pathBuf.Capacity; + uint ret = NativeMethods.MsiProvideAssembly(assemblyName, appContext, unchecked ((uint) installMode), (isWin32Assembly ? (uint) 1 : 0), pathBuf, ref pathBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + pathBuf.Capacity = (int) ++pathBufSize; + ret = NativeMethods.MsiProvideAssembly(assemblyName, appContext, unchecked ((uint) installMode), (isWin32Assembly ? (uint) 1 : 0), pathBuf, ref pathBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return pathBuf.ToString(); + } + + /// + /// Installs files that are unexpectedly missing. + /// + /// Product code for the product that owns the component to be installed + /// Component to be installed + /// Specifies the way the component should be installed. + /// the user exited the installation + ///

+ /// Win32 MSI API: + /// MsiInstallMissingComponent + ///

+ public static void InstallMissingComponent(string product, string component, InstallState installState) + { + uint ret = NativeMethods.MsiInstallMissingComponent(product, component, (int) installState); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Installs files that are unexpectedly missing. + /// + /// Product code for the product that owns the file to be installed + /// File to be installed + /// the user exited the installation + ///

+ /// Win32 MSI API: + /// MsiInstallMissingFile + ///

+ public static void InstallMissingFile(string product, string file) + { + uint ret = NativeMethods.MsiInstallMissingFile(product, file); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Reinstalls a feature. + /// + /// Product code for the product containing the feature to be reinstalled + /// Feature to be reinstalled + /// Reinstall modes + /// the user exited the installation + ///

+ /// Win32 MSI API: + /// MsiReinstallFeature + ///

+ public static void ReinstallFeature(string product, string feature, ReinstallModes reinstallModes) + { + uint ret = NativeMethods.MsiReinstallFeature(product, feature, (uint) reinstallModes); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Reinstalls a product. + /// + /// Product code for the product to be reinstalled + /// Reinstall modes + /// the user exited the installation + ///

+ /// Win32 MSI API: + /// MsiReinstallProduct + ///

+ public static void ReinstallProduct(string product, ReinstallModes reinstallModes) + { + uint ret = NativeMethods.MsiReinstallProduct(product, (uint) reinstallModes); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Opens an installer package and initializes an install session. + /// + /// path to the patch package + /// command line property settings + /// There was an error installing the product + ///

+ /// To completely remove a product, set REMOVE=ALL in . + ///

+ /// This method displays the user interface with the current settings and + /// log mode. You can change user interface settings with the + /// and functions. You can set the log mode with the + /// function. + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI API: + /// MsiInstallProduct + ///

+ public static void InstallProduct(string packagePath, string commandLine) + { + uint ret = NativeMethods.MsiInstallProduct(packagePath, commandLine); + Installer.CheckInstallResult(ret); + } + + /// + /// Installs or uninstalls a product. + /// + /// Product code of the product to be configured. + /// Specifies the default installation configuration of the + /// product. The parameter is ignored and all features + /// are installed if the parameter is set to any other + /// value than . This parameter must be either 0 + /// (install using authored feature levels), 65535 (install all features), or a value + /// between 0 and 65535 to install a subset of available features. + /// Specifies the installation state for the product. + /// Specifies the command line property settings. This should + /// be a list of the format Property=Setting Property=Setting. + /// There was an error configuring the product + ///

+ /// This method displays the user interface with the current settings and + /// log mode. You can change user interface settings with the + /// and functions. You can set the log mode with the + /// function. + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI APIs: + /// MsiConfigureProduct, + /// MsiConfigureProductEx + ///

+ public static void ConfigureProduct(string productCode, int installLevel, InstallState installState, string commandLine) + { + uint ret = NativeMethods.MsiConfigureProductEx(productCode, installLevel, (int) installState, commandLine); + Installer.CheckInstallResult(ret); + } + + /// + /// Configures the installed state for a product feature. + /// + /// Product code of the product to be configured. + /// Specifies the feature ID for the feature to be configured. + /// Specifies the installation state for the feature. + /// There was an error configuring the feature + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI API: + /// MsiConfigureFeature + ///

+ public static void ConfigureFeature(string productCode, string feature, InstallState installState) + { + uint ret = NativeMethods.MsiConfigureFeature(productCode, feature, (int) installState); + Installer.CheckInstallResult(ret); + } + + /// + /// For each product listed by the patch package as eligible to receive the patch, ApplyPatch invokes + /// an installation and sets the PATCH property to the path of the patch package. + /// + /// path to the patch package + /// optional command line property settings + /// There was an error applying the patch + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI API: + /// MsiApplyPatch + ///

+ public static void ApplyPatch(string patchPackage, string commandLine) + { + Installer.ApplyPatch(patchPackage, null, InstallType.Default, commandLine); + } + + /// + /// For each product listed by the patch package as eligible to receive the patch, ApplyPatch invokes + /// an installation and sets the PATCH property to the path of the patch package. + /// + /// path to the patch package + /// path to the product to be patched, if installType + /// is set to + /// type of installation to patch + /// optional command line property settings + /// There was an error applying the patch + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI API: + /// MsiApplyPatch + ///

+ public static void ApplyPatch(string patchPackage, string installPackage, InstallType installType, string commandLine) + { + uint ret = NativeMethods.MsiApplyPatch(patchPackage, installPackage, (int) installType, commandLine); + Installer.CheckInstallResult(ret); + } + + /// + /// Removes one or more patches from a single product. To remove a patch from + /// multiple products, RemovePatches must be called for each product. + /// + /// List of patches to remove. Each patch can be specified by the GUID + /// of the patch or the full path to the patch package. + /// The ProductCode (GUID) of the product from which the patches + /// are removed. This parameter cannot be null. + /// optional command line property settings + /// There was an error removing the patches + ///

+ /// The and properties should be + /// tested after calling this method. + ///

+ /// Win32 MSI API: + /// MsiRemovePatches + ///

+ public static void RemovePatches(IList patches, string productCode, string commandLine) + { + if (patches == null || patches.Count == 0) + { + throw new ArgumentNullException("patches"); + } + + if (productCode == null) + { + throw new ArgumentNullException("productCode"); + } + + StringBuilder patchList = new StringBuilder(); + foreach (string patch in patches) + { + if (patch != null) + { + if (patchList.Length != 0) + { + patchList.Append(';'); + } + + patchList.Append(patch); + } + } + + if (patchList.Length == 0) + { + throw new ArgumentNullException("patches"); + } + + uint ret = NativeMethods.MsiRemovePatches(patchList.ToString(), productCode, (int) InstallType.SingleInstance, commandLine); + Installer.CheckInstallResult(ret); + } + + /// + /// Determines which patches apply to a specified product MSI and in what sequence. + /// + /// Full path to an MSI file that is the target product + /// for the set of patches. + /// An array of strings specifying the patches to be checked. Each item + /// may be the path to an MSP file, the path an XML file, or just an XML blob. + /// Callback to be invoked for each inapplicable patch, reporting the + /// reason the patch is not applicable. This value may be left null if that information is not + /// desired. + /// An array of selected patch strings from , indicating + /// the set of applicable patches. The items are re-ordered to be in the best sequence. + ///

+ /// If an item in is a file path but does not end in .MSP or .XML, + /// it is assumed to be an MSP file. + ///

+ /// As this overload uses InstallContext.None, it does not consider the current state of + /// the system. + ///

+ /// Win32 MSI API: + /// MsiDetermineApplicablePatches + ///

+ public static IList DetermineApplicablePatches( + string productPackage, + string[] patches, + InapplicablePatchHandler errorHandler) + { + return DetermineApplicablePatches(productPackage, patches, errorHandler, null, UserContexts.None); + } + + /// + /// Determines which patches apply to a specified product and in what sequence. If + /// the product is installed, this method accounts for patches that have already been applied to + /// the product and accounts for obsolete and superceded patches. + /// + /// The product that is the target for the set of patches. This may be + /// either a ProductCode (GUID) of a product that is currently installed, or the path to a an + /// MSI file. + /// An array of strings specifying the patches to be checked. Each item + /// may be the path to an MSP file, the path an XML file, or just an XML blob. + /// Callback to be invoked for each inapplicable patch, reporting the + /// reason the patch is not applicable. This value may be left null if that information is not + /// desired. + /// Specifies a security identifier (SID) of a user. This parameter restricts + /// the context of enumeration for this user account. This parameter cannot be the special SID + /// strings s-1-1-0 (everyone) or s-1-5-18 (local system). If is set to + /// or , then + /// must be null. For the current user context, + /// can be null and can be set to + /// or . + /// Restricts the enumeration to per-user-unmanaged, per-user-managed, + /// or per-machine context, or (if referring to an MSI) to no system context at all. This + /// parameter can be , , + /// , or . + /// An array of selected patch strings from , indicating + /// the set of applicable patches. The items are re-ordered to be in the best sequence. + ///

+ /// If an item in is a file path but does not end in .MSP or .XML, + /// it is assumed to be an MSP file. + ///

+ /// Passing an InstallContext of None only analyzes the MSI file; it does not consider the + /// current state of the system. You cannot use InstallContext.None with a ProductCode GUID. + ///

+ /// Win32 MSI APIs: + /// MsiDetermineApplicablePatches + /// MsiDeterminePatchSequence + ///

+ public static IList DetermineApplicablePatches( + string product, + string[] patches, + InapplicablePatchHandler errorHandler, + string userSid, + UserContexts context) + { + if (String.IsNullOrEmpty(product)) + { + throw new ArgumentNullException("product"); + } + + if (patches == null) + { + throw new ArgumentNullException("patches"); + } + + NativeMethods.MsiPatchSequenceData[] sequenceData = new NativeMethods.MsiPatchSequenceData[patches.Length]; + for (int i = 0; i < patches.Length; i++) + { + if (String.IsNullOrEmpty(patches[i])) + { + throw new ArgumentNullException("patches[" + i + "]"); + } + + sequenceData[i].szPatchData = patches[i]; + sequenceData[i].ePatchDataType = GetPatchStringDataType(patches[i]); + sequenceData[i].dwOrder = -1; + sequenceData[i].dwStatus = 0; + } + + uint ret; + if (context == UserContexts.None) + { + ret = NativeMethods.MsiDetermineApplicablePatches(product, (uint) sequenceData.Length, sequenceData); + } + else + { + ret = NativeMethods.MsiDeterminePatchSequence(product, userSid, context, (uint) sequenceData.Length, sequenceData); + } + + if (errorHandler != null) + { + for (int i = 0; i < sequenceData.Length; i++) + { + if (sequenceData[i].dwOrder < 0 && sequenceData[i].dwStatus != 0) + { + errorHandler(sequenceData[i].szPatchData, InstallerException.ExceptionFromReturnCode(sequenceData[i].dwStatus)); + } + } + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + IList patchSeq = new List(patches.Length); + for (int i = 0; i < sequenceData.Length; i++) + { + for (int j = 0; j < sequenceData.Length; j++) + { + if (sequenceData[j].dwOrder == i) + { + patchSeq.Add(sequenceData[j].szPatchData); + } + } + } + return patchSeq; + } + + /// + /// Applies one or more patches to products that are eligible to receive the patch. + /// For each product listed by the patch package as eligible to receive the patch, ApplyPatch invokes + /// an installation and sets the PATCH property to the path of the patch package. + /// + /// The set of patch packages to be applied. + /// Each item is the full path to an MSP file. + /// Provides the ProductCode of the product being patched. If this parameter + /// is null, the patches are applied to all products that are eligible to receive these patches. + /// optional command line property settings + ///

+ /// Win32 MSI API: + /// MsiApplyMultiplePatches + ///

+ public static void ApplyMultiplePatches( + IList patchPackages, string productCode, string commandLine) + { + if (patchPackages == null || patchPackages.Count == 0) + { + throw new ArgumentNullException("patchPackages"); + } + + StringBuilder patchList = new StringBuilder(); + foreach (string patch in patchPackages) + { + if (patch != null) + { + if (patchList.Length != 0) + { + patchList.Append(';'); + } + + patchList.Append(patch); + } + } + + if (patchList.Length == 0) + { + throw new ArgumentNullException("patchPackages"); + } + + uint ret = NativeMethods.MsiApplyMultiplePatches(patchList.ToString(), productCode, commandLine); + Installer.CheckInstallResult(ret); + } + + /// + /// Extracts information from a patch that can be used to determine whether the patch + /// applies on a target system. The method returns an XML string that can be provided to + /// + /// instead of the full patch file. + /// + /// Full path to the patch being queried. + /// XML string containing patch data. + ///

+ /// Win32 MSI API: + /// MsiExtractPatchXMLData + ///

+ public static string ExtractPatchXmlData(string patchPath) + { + StringBuilder buf = new StringBuilder(""); + uint bufSize = 0; + uint ret = NativeMethods.MsiExtractPatchXMLData(patchPath, 0, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiExtractPatchXMLData(patchPath, 0, buf, ref bufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return buf.ToString(); + } + + /// + /// [MSI 3.1] Migrates a user's application configuration data to a new SID. + /// + /// Previous user SID that data is to be migrated from + /// New user SID that data is to be migrated to + ///

+ /// Win32 MSI API: + /// MsiNotifySidChange + ///

+ public static void NotifySidChange(string oldSid, string newSid) + { + uint ret = NativeMethods.MsiNotifySidChange(oldSid, newSid); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + private static void CheckInstallResult(uint ret) + { + switch (ret) + { + case (uint) NativeMethods.Error.SUCCESS: break; + case (uint) NativeMethods.Error.SUCCESS_REBOOT_REQUIRED: Installer.rebootRequired = true; break; + case (uint) NativeMethods.Error.SUCCESS_REBOOT_INITIATED: Installer.rebootInitiated = true; break; + default: throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + private static int GetPatchStringDataType(string patchData) + { + if (patchData.IndexOf("<", StringComparison.Ordinal) >= 0 && + patchData.IndexOf(">", StringComparison.Ordinal) >= 0) + { + return 2; // XML blob + } + else if (String.Compare(Path.GetExtension(patchData), ".xml", + StringComparison.OrdinalIgnoreCase) == 0) + { + return 1; // XML file path + } + else + { + return 0; // MSP file path + } + } +} +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerAdvertise.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerAdvertise.cs new file mode 100644 index 00000000..9da593d9 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerAdvertise.cs @@ -0,0 +1,270 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Reflection; + using System.Globalization; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + + public static partial class Installer + { + /// + /// Advertises a product to the local computer. + /// + /// Path to the package of the product being advertised + /// True if the product is user-assigned; false if it is machine-assigned. + /// Semi-colon delimited list of transforms to be applied. This parameter may be null. + /// The language to use if the source supports multiple languages + /// the specified package file does not exist + /// + ///

+ /// Win32 MSI APIs: + /// MsiAdvertiseProduct, + /// MsiAdvertiseProductEx + ///

+ public static void AdvertiseProduct(string packagePath, bool perUser, string transforms, int locale) + { + if (String.IsNullOrEmpty(packagePath)) + { + throw new ArgumentNullException("packagePath"); + } + + if (!File.Exists(packagePath)) + { + throw new FileNotFoundException(null, packagePath); + } + + uint ret = NativeMethods.MsiAdvertiseProduct(packagePath, new IntPtr(perUser ? 1 : 0), transforms, (ushort) locale); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Generates an advertise script. The method enables the installer to write to a + /// script the registry and shortcut information used to assign or publish a product. + /// + /// Path to the package of the product being advertised + /// path to script file to be created with the advertise information + /// Semi-colon delimited list of transforms to be applied. This parameter may be null. + /// The language to use if the source supports multiple languages + /// the specified package file does not exist + /// + ///

+ /// Win32 MSI APIs: + /// MsiAdvertiseProduct, + /// MsiAdvertiseProductEx + ///

+ public static void GenerateAdvertiseScript(string packagePath, string scriptFilePath, string transforms, int locale) + { + if (String.IsNullOrEmpty(packagePath)) + { + throw new ArgumentNullException("packagePath"); + } + + if (!File.Exists(packagePath)) + { + throw new FileNotFoundException(null, packagePath); + } + + uint ret = NativeMethods.MsiAdvertiseProduct(packagePath, scriptFilePath, transforms, (ushort) locale); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Generates an advertise script. The method enables the installer to write to a + /// script the registry and shortcut information used to assign or publish a product. + /// + /// Path to the package of the product being advertised + /// path to script file to be created with the advertise information + /// Semi-colon delimited list of transforms to be applied. This parameter may be null. + /// The language to use if the source supports multiple languages + /// Targeted processor architecture. + /// True to install multiple instances through product code changing transform. + /// Advertises a new instance of the product. Requires that the parameter + /// includes the instance transform that changes the product code. + /// + ///

+ /// Win32 MSI APIs: + /// MsiAdvertiseProduct, + /// MsiAdvertiseProductEx + ///

+ public static void GenerateAdvertiseScript( + string packagePath, + string scriptFilePath, + string transforms, + int locale, + ProcessorArchitecture processor, + bool instance) + { + if (String.IsNullOrEmpty(packagePath)) + { + throw new ArgumentNullException("packagePath"); + } + + if (String.IsNullOrEmpty(scriptFilePath)) + { + throw new ArgumentNullException("scriptFilePath"); + } + + if (!File.Exists(packagePath)) + { + throw new FileNotFoundException(null, packagePath); + } + + uint platform = 0; + switch (processor) + { + case ProcessorArchitecture.X86: platform = (uint) 1; break; + case ProcessorArchitecture.IA64: platform = (uint) 2; break; + case ProcessorArchitecture.Amd64: platform = (uint) 4; break; + } + + uint ret = NativeMethods.MsiAdvertiseProductEx( + packagePath, + scriptFilePath, + transforms, + (ushort) locale, + platform, + instance ? (uint) 1 : 0); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Copies an advertise script file to the local computer. + /// + /// Path to a script file generated by + /// + /// Flags controlling advertisement + /// True if specified items are to be removed instead of being created + ///

+ /// The process calling this function must be running under the LocalSystem account. To advertise an + /// application for per-user installation to a targeted user, the thread that calls this function must + /// impersonate the targeted user. If the thread calling this function is not impersonating a targeted + /// user, the application is advertised to all users for installation with elevated privileges. + ///

+ [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags")] + public static void AdvertiseScript(string scriptFile, int flags, bool removeItems) + { + uint ret = NativeMethods.MsiAdvertiseScript(scriptFile, (uint) flags, IntPtr.Zero, removeItems); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Processes an advertise script file into the specified locations. + /// + /// Path to a script file generated by + /// + /// An optional path to a folder in which advertised icon files and transform + /// files are located. If this parameter is null, no icon or transform files are written. + /// True if shortcuts should be created + /// True if specified items are to be removed instead of created + ///

+ /// The process calling this function must be running under the LocalSystem account. To advertise an + /// application for per-user installation to a targeted user, the thread that calls this function must + /// impersonate the targeted user. If the thread calling this function is not impersonating a targeted + /// user, the application is advertised to all users for installation with elevated privileges. + ///

+ /// Win32 MSI API: + /// MsiProcessAdvertiseScript + ///

+ public static void ProcessAdvertiseScript(string scriptFile, string iconFolder, bool shortcuts, bool removeItems) + { + uint ret = NativeMethods.MsiProcessAdvertiseScript(scriptFile, iconFolder, IntPtr.Zero, shortcuts, removeItems); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Gets product information for an installer script file. + /// + /// Path to a script file generated by + /// + /// ProductInstallation stub with advertise-related properties filled in. + /// An invalid product property was requested + ///

+ /// Only the following properties will be filled in in the returned object:

    + ///
  • + ///
  • + ///
  • + ///
  • + ///
  • + ///
Other properties will be null. + ///

+ /// Win32 MSI API: + /// MsiGetProductInfoFromScript + ///

+ public static ProductInstallation GetProductInfoFromScript(string scriptFile) + { + if (String.IsNullOrEmpty(scriptFile)) + { + throw new ArgumentNullException("scriptFile"); + } + StringBuilder productCodeBuf = new StringBuilder(40); + ushort lang; + uint ver; + StringBuilder productNameBuf = new StringBuilder(100); + StringBuilder packageNameBuf = new StringBuilder(40); + uint productCodeBufSize = (uint) productCodeBuf.Capacity; + uint productNameBufSize = (uint) productNameBuf.Capacity; + uint packageNameBufSize = (uint) packageNameBuf.Capacity; + uint ret = NativeMethods.MsiGetProductInfoFromScript( + scriptFile, + productCodeBuf, + out lang, + out ver, + productNameBuf, + ref productNameBufSize, + packageNameBuf, + ref packageNameBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + productCodeBuf.Capacity = (int) ++productCodeBufSize; + productNameBuf.Capacity = (int) ++productNameBufSize; + packageNameBuf.Capacity = (int) ++packageNameBufSize; + ret = NativeMethods.MsiGetProductInfoFromScript( + scriptFile, + productCodeBuf, + out lang, + out ver, + productNameBuf, + ref productNameBufSize, + packageNameBuf, + ref packageNameBufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + uint verPart1 = ver >> 24; + uint verPart2 = (ver & 0x00FFFFFF) >> 16; + uint verPart3 = ver & 0x0000FFFF; + Version version = new Version((int) verPart1, (int) verPart2, (int) verPart3); + + IDictionary props = new Dictionary(); + props["ProductCode"] = productCodeBuf.ToString(); + props["Language"] = lang.ToString(CultureInfo.InvariantCulture); + props["Version"] = version.ToString(); + props["ProductName"] = productNameBuf.ToString(); + props["PackageName"] = packageNameBuf.ToString(); + return new ProductInstallation(props); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerUtils.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerUtils.cs new file mode 100644 index 00000000..8d9cf0a1 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/InstallerUtils.cs @@ -0,0 +1,472 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Resources; + using System.Reflection; + using System.Collections.Generic; + using System.Globalization; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + public static partial class Installer + { + /// + /// Gets the current version of the installer. + /// + public static Version Version + { + get + { + // TODO: Use the extended form of version info to get the 4th component of the verison. + uint[] dllVersionInfo = new uint[5]; + dllVersionInfo[0] = 20; + int hr = NativeMethods.DllGetVersion(dllVersionInfo); + if (hr != 0) + { + Marshal.ThrowExceptionForHR(hr); + } + + return new Version((int) dllVersionInfo[1], (int) dllVersionInfo[2], (int) dllVersionInfo[3]); + } + } + + internal static ResourceManager ErrorResources + { + get + { + if (errorResources == null) + { + errorResources = new ResourceManager(typeof(Installer).Namespace + ".Errors", typeof(Installer).Assembly); + } + return errorResources; + } + } + + /// + /// Gets a Windows Installer error message in the system default language. + /// + /// The error number. + /// The message string, or null if the error message is not found. + ///

+ /// The returned string may have tokens such as [2] and [3] that are meant to be substituted + /// with context-specific values. + ///

+ /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always + /// returned in English. + ///

+ public static string GetErrorMessage(int errorNumber) + { + return Installer.GetErrorMessage(errorNumber, null); + } + + /// + /// Gets a Windows Installer error message in a specified language. + /// + /// The error number. + /// The locale for the message. + /// The message string, or null if the error message or locale is not found. + ///

+ /// The returned string may have tokens such as [2] and [3] that are meant to be substituted + /// with context-specific values. + ///

+ /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always + /// returned in English. + ///

+ [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] + public static string GetErrorMessage(int errorNumber, CultureInfo culture) + { + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + + string msg = Installer.ErrorResources.GetString( + errorNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), + culture); + if (msg == null) + { + string msiMsgModule = Path.Combine( + Environment.SystemDirectory, "msimsg.dll"); + msg = Installer.GetMessageFromModule( + msiMsgModule, errorNumber, culture); + } + return msg; + } + + private static string GetMessageFromModule( + string modulePath, int errorNumber, CultureInfo culture) + { + const uint LOAD_LIBRARY_AS_DATAFILE = 2; + const int RT_RCDATA = 10; + + IntPtr msgModule = NativeMethods.LoadLibraryEx( + modulePath, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); + if (msgModule == IntPtr.Zero) + { + return null; + } + + try + { + // On pre-Vista systems, the messages are stored as RCDATA resources. + + int lcid = (culture == CultureInfo.InvariantCulture) ? + 0 : culture.LCID; + IntPtr resourceInfo = NativeMethods.FindResourceEx( + msgModule, + new IntPtr(RT_RCDATA), + new IntPtr(errorNumber), + (ushort) lcid); + if (resourceInfo != IntPtr.Zero) + { + IntPtr resourceData = NativeMethods.LoadResource( + msgModule, resourceInfo); + IntPtr resourcePtr = NativeMethods.LockResource(resourceData); + + if (lcid == 0) + { + string msg = Marshal.PtrToStringAnsi(resourcePtr); + return msg; + } + else + { + int len = 0; + while (Marshal.ReadByte(resourcePtr, len) != 0) + { + len++; + } + byte[] msgBytes = new byte[len + 1]; + Marshal.Copy(resourcePtr, msgBytes, 0, msgBytes.Length); + Encoding encoding = Encoding.GetEncoding( + culture.TextInfo.ANSICodePage); + string msg = encoding.GetString(msgBytes); + return msg; + } + } + else + { + // On Vista (and above?), the messages are stored in the module message table. + // They're actually in MUI files, and the redirection happens automatically here. + + const uint FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; + const uint FORMAT_MESSAGE_FROM_HMODULE = 0x00000800; + const uint MESSAGE_OFFSET = 20000; // Not documented, but observed on Vista + + StringBuilder buf = new StringBuilder(1024); + uint formatCount = NativeMethods.FormatMessage( + FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, + msgModule, + (uint) errorNumber + MESSAGE_OFFSET, + (ushort) lcid, + buf, + (uint) buf.Capacity, + IntPtr.Zero); + + return formatCount != 0 ? buf.ToString().Trim() : null; + } + } + finally + { + NativeMethods.FreeLibrary(msgModule); + } + } + + /// + /// Gets a formatted Windows Installer error message in the system default language. + /// + /// Error record containing the error number in the first field, and + /// error-specific parameters in the other fields. + /// The message string, or null if the error message is not found. + ///

+ /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always + /// returned in English. + ///

+ public static string GetErrorMessage(Record errorRecord) { return Installer.GetErrorMessage(errorRecord, null); } + + /// + /// Gets a formatted Windows Installer error message in a specified language. + /// + /// Error record containing the error number in the first field, and + /// error-specific parameters in the other fields. + /// The locale for the message. + /// The message string, or null if the error message or locale is not found. + ///

+ /// Error numbers greater than 2000 refer to MSI "internal" errors, and are always + /// returned in English. + ///

+ public static string GetErrorMessage(Record errorRecord, CultureInfo culture) + { + if (errorRecord == null) + { + throw new ArgumentNullException("errorRecord"); + } + int errorNumber; + if (errorRecord.FieldCount < 1 || (errorNumber = (int) errorRecord.GetInteger(1)) == 0) + { + throw new ArgumentOutOfRangeException("errorRecord"); + } + + string msg = Installer.GetErrorMessage(errorNumber, culture); + if (msg != null) + { + errorRecord.FormatString = msg; + msg = errorRecord.ToString((IFormatProvider)null); + } + return msg; + } + + /// + /// Gets the version string of the path specified using the format that the installer + /// expects to find it in in the database. + /// + /// Path to the file + /// Version string in the "#.#.#.#" format, or an empty string if the file + /// does not contain version information + /// the file does not exist or could not be read + ///

+ /// Win32 MSI API: + /// MsiGetFileVersion + ///

+ public static string GetFileVersion(string path) + { + StringBuilder version = new StringBuilder(20); + uint verBufSize = 0, langBufSize = 0; + uint ret = NativeMethods.MsiGetFileVersion(path, version, ref verBufSize, null, ref langBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + version.Capacity = (int) ++verBufSize; + ret = NativeMethods.MsiGetFileVersion(path, version, ref verBufSize, null, ref langBufSize); + } + + if (ret != 0 && ret != (uint) NativeMethods.Error.FILE_INVALID) + { + if (ret == (uint) NativeMethods.Error.FILE_NOT_FOUND || + ret == (uint) NativeMethods.Error.ACCESS_DENIED) + { + throw new FileNotFoundException(null, path); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return version.ToString(); + } + + /// + /// Gets the language string of the path specified using the format that the installer + /// expects to find them in in the database. + /// + /// Path to the file + /// Language string in the form of a decimal language ID, or an empty string if the file + /// does not contain a language ID + /// the file does not exist or could not be read + ///

+ /// Win32 MSI API: + /// MsiGetFileVersion + ///

+ public static string GetFileLanguage(string path) + { + StringBuilder language = new StringBuilder("", 10); + uint verBufSize = 0, langBufSize = 0; + uint ret = NativeMethods.MsiGetFileVersion(path, null, ref verBufSize, language, ref langBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + language.Capacity = (int) ++langBufSize; + ret = NativeMethods.MsiGetFileVersion(path, null, ref verBufSize, language, ref langBufSize); + } + + if (ret != 0 && ret != (uint) NativeMethods.Error.FILE_INVALID) + { + if (ret == (uint) NativeMethods.Error.FILE_NOT_FOUND || + ret == (uint) NativeMethods.Error.ACCESS_DENIED) + { + throw new FileNotFoundException(null, path); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return language.ToString(); + } + + /// + /// Gets a 128-bit hash of the specified file. + /// + /// Path to the file + /// Integer array of length 4 which receives the + /// four 32-bit parts of the hash value. + /// the file does not exist or + /// could not be read + ///

+ /// Win32 MSI API: + /// MsiGetFileHash + ///

+ public static void GetFileHash(string path, int[] hash) + { + if (hash == null) + { + throw new ArgumentNullException("hash"); + } + + uint[] tempHash = new uint[5]; + tempHash[0] = 20; + uint ret = NativeMethods.MsiGetFileHash(path, 0, tempHash); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.FILE_NOT_FOUND || + ret == (uint) NativeMethods.Error.ACCESS_DENIED) + { + throw new FileNotFoundException(null, path); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + for (int i = 0; i < 4; i++) + { + hash[i] = unchecked ((int) tempHash[i + 1]); + } + } + + /// + /// Examines a shortcut and returns its product, feature name, and component if available. + /// + /// Full path to a shortcut + /// ShortcutTarget structure containing target product code, feature, and component code + ///

+ /// Win32 MSI API: + /// MsiGetShortcutTarget + ///

+ public static ShortcutTarget GetShortcutTarget(string shortcut) + { + StringBuilder productBuf = new StringBuilder(40); + StringBuilder featureBuf = new StringBuilder(40); + StringBuilder componentBuf = new StringBuilder(40); + + uint ret = NativeMethods.MsiGetShortcutTarget(shortcut, productBuf, featureBuf, componentBuf); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return new ShortcutTarget( + productBuf.Length > 0 ? productBuf.ToString() : null, + featureBuf.Length > 0 ? featureBuf.ToString() : null, + componentBuf.Length > 0 ? componentBuf.ToString() : null); + } + + /// + /// Verifies that the given file is an installation package. + /// + /// Path to the package + /// True if the file is an installation package; false otherwise. + /// the specified package file does not exist + /// the package file could not be opened + ///

+ /// Win32 MSI API: + /// MsiVerifyPackage + ///

+ public static bool VerifyPackage(string packagePath) + { + if (String.IsNullOrEmpty(packagePath)) + { + throw new ArgumentNullException("packagePath"); + } + + if (!File.Exists(packagePath)) + { + throw new FileNotFoundException(null, packagePath); + } + + uint ret = NativeMethods.MsiVerifyPackage(packagePath); + if (ret == (uint) NativeMethods.Error.INSTALL_PACKAGE_INVALID) + { + return false; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + /// + /// [MSI 4.0] Gets the list of files that can be updated by one or more patches. + /// + /// ProductCode (GUID) of the product which is + /// the target of the patches + /// list of file paths of one or more patches to be + /// analyzed + /// List of absolute paths of files that can be updated when the + /// patches are applied on this system. + ///

+ /// Win32 MSI API: + /// MsiGetPatchFileList + ///

+ public static IList GetPatchFileList(string productCode, IList patches) + { + if (String.IsNullOrEmpty(productCode)) + { + throw new ArgumentNullException("productCode"); + } + + if (patches == null || patches.Count == 0) + { + throw new ArgumentNullException("patches"); + } + + StringBuilder patchList = new StringBuilder(); + foreach (string patch in patches) + { + if (patch != null) + { + if (patchList.Length != 0) + { + patchList.Append(';'); + } + + patchList.Append(patch); + } + } + + if (patchList.Length == 0) + { + throw new ArgumentNullException("patches"); + } + + IntPtr phFileRecords; + uint cFiles; + + uint ret = NativeMethods.MsiGetPatchFileList( + productCode, + patchList.ToString(), + out cFiles, + out phFileRecords); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + List files = new List(); + + for (uint i = 0; i < cFiles; i++) + { + int hFileRec = Marshal.ReadInt32(phFileRecords, (int) i); + + using (Record fileRec = new Record(hFileRec, true, null)) + { + files.Add(fileRec.GetString(1)); + } + } + + return files; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/MediaDisk.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/MediaDisk.cs new file mode 100644 index 00000000..7b196b3e --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/MediaDisk.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Diagnostics.CodeAnalysis; + + /// + /// Represents a media disk source of a product or a patch. + /// + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + public struct MediaDisk + { + private int diskId; + private string volumeLabel; + private string diskPrompt; + + /// + /// Creates a new media disk. + /// + /// + /// + /// + public MediaDisk(int diskId, string volumeLabel, string diskPrompt) + { + this.diskId = diskId; + this.volumeLabel = volumeLabel; + this.diskPrompt = diskPrompt; + } + + /// + /// Gets or sets the disk id of the media disk. + /// + public int DiskId + { + get { return this.diskId; } + set { this.diskId = value; } + } + + /// + /// Gets or sets the volume label of the media disk. + /// + public string VolumeLabel + { + get { return this.volumeLabel; } + set { this.volumeLabel = value; } + } + + /// + /// Gets or sets the disk prompt of the media disk. + /// + public string DiskPrompt + { + get { return this.diskPrompt; } + set { this.diskPrompt = value; } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/NativeMethods.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/NativeMethods.cs new file mode 100644 index 00000000..6c5b84fd --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/NativeMethods.cs @@ -0,0 +1,311 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ +using System; +using System.Text; +using System.Security.Permissions; +using System.Runtime.InteropServices; +using System.Diagnostics.CodeAnalysis; + +using IStream = System.Runtime.InteropServices.ComTypes.IStream; +using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; +using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG; + +[Guid("0000000b-0000-0000-C000-000000000046")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal interface IStorage +{ + [return: MarshalAs(UnmanagedType.Interface)] + IStream CreateStream([MarshalAs(UnmanagedType.LPWStr)] string wcsName, uint grfMode, uint reserved1, uint reserved2); + [return: MarshalAs(UnmanagedType.Interface)] + IStream OpenStream([MarshalAs(UnmanagedType.LPWStr)] string wcsName, IntPtr reserved1, uint grfMode, uint reserved2); + [return: MarshalAs(UnmanagedType.Interface)] + IStorage CreateStorage([MarshalAs(UnmanagedType.LPWStr)] string wcsName, uint grfMode, uint reserved1, uint reserved2); + [return: MarshalAs(UnmanagedType.Interface)] + IStorage OpenStorage([MarshalAs(UnmanagedType.LPWStr)] string wcsName, IntPtr stgPriority, uint grfMode, IntPtr snbExclude, uint reserved); + void CopyTo(uint ciidExclude, IntPtr rgiidExclude, IntPtr snbExclude, [MarshalAs(UnmanagedType.Interface)] IStorage stgDest); + void MoveElementTo([MarshalAs(UnmanagedType.LPWStr)] string wcsName, [MarshalAs(UnmanagedType.Interface)] IStorage stgDest, [MarshalAs(UnmanagedType.LPWStr)] string wcsNewName, uint grfFlags); + void Commit(uint grfCommitFlags); + void Revert(); + IntPtr EnumElements(uint reserved1, IntPtr reserved2, uint reserved3); + void DestroyElement([MarshalAs(UnmanagedType.LPWStr)] string wcsName); + void RenameElement([MarshalAs(UnmanagedType.LPWStr)] string wcsOldName, [MarshalAs(UnmanagedType.LPWStr)] string wcsNewName); + void SetElementTimes([MarshalAs(UnmanagedType.LPWStr)] string wcsName, ref FILETIME ctime, ref FILETIME atime, ref FILETIME mtime); + void SetClass(ref Guid clsid); + void SetStateBits(uint grfStateBits, uint grfMask); + void Stat(ref STATSTG statstg, uint grfStatFlag); +} + +internal static class NativeMethods +{ + internal enum Error : uint + { + SUCCESS = 0, + FILE_NOT_FOUND = 2, + PATH_NOT_FOUND = 3, + ACCESS_DENIED = 5, + INVALID_HANDLE = 6, + INVALID_DATA = 13, + INVALID_PARAMETER = 87, + OPEN_FAILED = 110, + DISK_FULL = 112, + CALL_NOT_IMPLEMENTED = 120, + BAD_PATHNAME = 161, + NO_DATA = 232, + MORE_DATA = 234, + NO_MORE_ITEMS = 259, + DIRECTORY = 267, + INSTALL_USEREXIT = 1602, + INSTALL_FAILURE = 1603, + FILE_INVALID = 1006, + UNKNOWN_PRODUCT = 1605, + UNKNOWN_FEATURE = 1606, + UNKNOWN_COMPONENT = 1607, + UNKNOWN_PROPERTY = 1608, + INVALID_HANDLE_STATE = 1609, + INSTALL_SOURCE_ABSENT = 1612, + BAD_QUERY_SYNTAX = 1615, + INSTALL_PACKAGE_INVALID = 1620, + FUNCTION_FAILED = 1627, + INVALID_TABLE = 1628, + DATATYPE_MISMATCH = 1629, + CREATE_FAILED = 1631, + SUCCESS_REBOOT_INITIATED = 1641, + SUCCESS_REBOOT_REQUIRED = 3010, + } + + internal enum SourceType : int + { + Unknown = 0, + Network = 1, + Url = 2, + Media = 3, + } + + [Flags] + internal enum STGM : uint + { + DIRECT = 0x00000000, + TRANSACTED = 0x00010000, + SIMPLE = 0x08000000, + + READ = 0x00000000, + WRITE = 0x00000001, + READWRITE = 0x00000002, + + SHARE_DENY_NONE = 0x00000040, + SHARE_DENY_READ = 0x00000030, + SHARE_DENY_WRITE = 0x00000020, + SHARE_EXCLUSIVE = 0x00000010, + + PRIORITY = 0x00040000, + DELETEONRELEASE = 0x04000000, + NOSCRATCH = 0x00100000, + + CREATE = 0x00001000, + CONVERT = 0x00020000, + FAILIFTHERE = 0x00000000, + + NOSNAPSHOT = 0x00200000, + DIRECT_SWMR = 0x00400000, + } + +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int DllGetVersion(uint[] dvi); + +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetInternalUI(uint dwUILevel, ref IntPtr phWnd); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetInternalUI(uint dwUILevel, IntPtr phWnd); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern NativeExternalUIHandler MsiSetExternalUI([MarshalAs(UnmanagedType.FunctionPtr)] NativeExternalUIHandler puiHandler, uint dwMessageFilter, IntPtr pvContext); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnableLog(uint dwLogMode, string szLogFile, uint dwLogAttributes); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumProducts(uint iProductIndex, StringBuilder lpProductBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProductInfo(string szProduct, string szProperty, StringBuilder lpValueBuf, ref uint pcchValueBuf); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumPatches(string szProduct, uint iPatchIndex, StringBuilder lpPatchBuf, StringBuilder lpTransformsBuf, ref uint pcchTransformsBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetPatchInfo(string szPatch, string szAttribute, StringBuilder lpValueBuf, ref uint pcchValueBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumFeatures(string szProduct, uint iFeatureIndex, StringBuilder lpFeatureBuf, StringBuilder lpParentBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiQueryFeatureState(string szProduct, string szFeature); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiUseFeatureEx(string szProduct, string szFeature, uint dwInstallMode, uint dwReserved); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiQueryProductState(string szProduct); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetShortcutTarget(string szShortcut, StringBuilder szProductCode, StringBuilder szFeatureId, StringBuilder szComponentCode); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiProvideComponent(string szProduct, string szFeature, string szComponent, uint dwInstallMode, StringBuilder lpPathBuf, ref uint cchPathBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiProvideQualifiedComponentEx(string szComponent, string szQualifier, uint dwInstallMode, string szProduct, uint dwUnused1, uint dwUnused2, StringBuilder lpPathBuf, ref uint cchPathBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiReinstallFeature(string szFeature, string szProduct, uint dwReinstallMode); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiReinstallProduct(string szProduct, uint dwReinstallMode); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListAddSource(string szProduct, string szUserName, uint dwReserved, string szSource); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListClearAll(string szProduct, string szUserName, uint dwReserved); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListForceResolution(string szProduct, string szUserName, uint dwReserved); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiCollectUserInfo(string szProduct); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetUserInfo(string szProduct, StringBuilder lpUserNameBuf, ref uint cchUserNameBuf, StringBuilder lpOrgNameBuf, ref uint cchOrgNameBuf, StringBuilder lpSerialBuf, ref uint cchSerialBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiOpenPackageEx(string szPackagePath, uint dwOptions, out int hProduct); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiOpenProduct(string szProduct, out int hProduct); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiInstallProduct(string szPackagePath, string szCommandLine); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiConfigureProductEx(string szProduct, int iInstallLevel, int eInstallState, string szCommandLine); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiConfigureFeature(string szProduct, string szFeature, int eInstallState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiApplyPatch(string szPatchPackage, string szInstallPackage, int eInstallType, string szCommandLine); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiOpenDatabase(string szDatabasePath, IntPtr uiOpenMode, out int hDatabase); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiOpenDatabase(string szDatabasePath, string szPersist, out int hDatabase); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetDatabaseState(int hDatabase); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseOpenView(int hDatabase, string szQuery, out int hView); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseMerge(int hDatabase, int hDatabaseMerge, string szTableName); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseCommit(int hDatabase); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseGetPrimaryKeys(int hDatabase, string szTableName, out int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseIsTablePersistent(int hDatabase, string szTableName); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseExport(int hDatabase, string szTableName, string szFolderPath, string szFileName); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseImport(int hDatabase, string szFolderPath, string szFileName); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseGenerateTransform(int hDatabase, int hDatabaseReference, string szTransformFile, int iReserved1, int iReserved2); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiCreateTransformSummaryInfo(int hDatabase, int hDatabaseReference, string szTransformFile, int iErrorConditions, int iValidation); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDatabaseApplyTransform(int hDatabase, string szTransformFile, int iErrorConditions); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiViewExecute(int hView, int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiViewFetch(int hView, out int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiViewModify(int hView, int iModifyMode, int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiViewGetError(int hView, StringBuilder szColumnNameBuffer, ref uint cchBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiViewGetColumnInfo(int hView, uint eColumnInfo, out int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiCreateRecord(uint cParams); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiFormatRecord(int hInstall, int hRecord, StringBuilder szResultBuf, ref uint cchResultBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordClearData(int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordGetFieldCount(int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool MsiRecordIsNull(int hRecord, uint iField); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiRecordGetInteger(int hRecord, uint iField); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordGetString(int hRecord, uint iField, StringBuilder szValueBuf, ref uint cchValueBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordSetInteger(int hRecord, uint iField, int iValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordSetString(int hRecord, uint iField, string szValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordDataSize(int hRecord, uint iField); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordReadStream(int hRecord, uint iField, byte[] szDataBuf, ref uint cbDataBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRecordSetStream(int hRecord, uint iField, string szFilePath); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetSummaryInformation(int hDatabase, string szDatabasePath, uint uiUpdateCount, out int hSummaryInfo); +//[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSummaryInfoGetPropertyCount(int hSummaryInfo, out uint uiPropertyCount); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSummaryInfoGetProperty(int hSummaryInfo, uint uiProperty, out uint uiDataType, out int iValue, ref long ftValue, StringBuilder szValueBuf, ref uint cchValueBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSummaryInfoSetProperty(int hSummaryInfo, uint uiProperty, uint uiDataType, int iValue, ref long ftValue, string szValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSummaryInfoPersist(int hSummaryInfo); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiCloseHandle(int hAny); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFileVersion(string szFilePath, StringBuilder szVersionBuf, ref uint cchVersionBuf, StringBuilder szLangBuf, ref uint cchLangBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFileHash(string szFilePath, uint dwOptions, uint[] hash); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetActiveDatabase(int hInstall); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProperty(int hInstall, string szName, StringBuilder szValueBuf, ref uint cchValueBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetProperty(int hInstall, string szName, string szValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiProcessMessage(int hInstall, uint eMessageType, int hRecord); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEvaluateCondition(int hInstall, string szCondition); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool MsiGetMode(int hInstall, uint iRunMode); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetMode(int hInstall, uint iRunMode, [MarshalAs(UnmanagedType.Bool)] bool fState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDoAction(int hInstall, string szAction); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSequence(int hInstall, string szTable, int iSequenceMode); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetSourcePath(int hInstall, string szFolder, StringBuilder szPathBuf, ref uint cchPathBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetTargetPath(int hInstall, string szFolder, StringBuilder szPathBuf, ref uint cchPathBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetTargetPath(int hInstall, string szFolder, string szFolderPath); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetComponentState(int hInstall, string szComponent, out int iInstalled, out int iAction); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetComponentState(int hInstall, string szComponent, int iState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFeatureState(int hInstall, string szFeature, out int iInstalled, out int iAction); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetFeatureState(int hInstall, string szFeature, int iState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFeatureValidStates(int hInstall, string szFeature, out uint dwInstallState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetInstallLevel(int hInstall, int iInstallLevel); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern ushort MsiGetLanguage(int hInstall); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumComponents(uint iComponentIndex, StringBuilder lpComponentBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumComponentsEx(string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwIndex, StringBuilder szInstalledProductCode, [MarshalAs(UnmanagedType.I4)] out UserContexts pdwInstalledContext, StringBuilder szSid, ref uint pcchSid); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumClients(string szComponent, uint iProductIndex, StringBuilder lpProductBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumClientsEx(string szComponent, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint iProductIndex, StringBuilder lpProductBuf, [MarshalAs(UnmanagedType.I4)] out UserContexts pdwInstalledContext, StringBuilder szSid, ref uint pcchSid); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetComponentPath(string szProduct, string szComponent, StringBuilder lpPathBuf, ref uint pcchBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetComponentPathEx(string szProduct, string szComponent, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, StringBuilder lpPathBuf, ref uint pcchBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumComponentQualifiers(string szComponent, uint iIndex, StringBuilder lpQualifierBuf, ref uint pcchQualifierBuf, StringBuilder lpApplicationDataBuf, ref uint pcchApplicationDataBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiGetLastErrorRecord(); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumRelatedProducts(string upgradeCode, uint dwReserved, uint iProductIndex, StringBuilder lpProductBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProductCode(string szComponent, StringBuilder lpProductBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFeatureUsage(string szProduct, string szFeature, out uint dwUseCount, out ushort dwDateUsed); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFeatureCost(int hInstall, string szFeature, int iCostTree, int iState, out int iCost); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiVerifyPackage(string szPackagePath); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiIsProductElevated(string szProductCode, [MarshalAs(UnmanagedType.Bool)] out bool fElevated); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiAdvertiseProduct(string szPackagePath, IntPtr szScriptFilePath, string szTransforms, ushort lgidLanguage); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiAdvertiseProduct(string szPackagePath, string szScriptFilePath, string szTransforms, ushort lgidLanguage); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiAdvertiseProductEx(string szPackagePath, string szScriptFilePath, string szTransforms, ushort lgidLanguage, uint dwPlatform, uint dwReserved); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiAdvertiseScript(string szScriptFile, uint dwFlags, IntPtr phRegData, [MarshalAs(UnmanagedType.Bool)] bool fRemoveItems); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiProcessAdvertiseScript(string szScriptFile, string szIconFolder, IntPtr hRegData, [MarshalAs(UnmanagedType.Bool)] bool fShortcuts, [MarshalAs(UnmanagedType.Bool)] bool fRemoveItems); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProductInfoFromScript(string szScriptFile, StringBuilder lpProductBuf39, out ushort plgidLanguage, out uint pdwVersion, StringBuilder lpNameBuf, ref uint cchNameBuf, StringBuilder lpPackageBuf, ref uint cchPackageBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiProvideAssembly(string szAssemblyName, string szAppContext, uint dwInstallMode, uint dwAssemblyInfo, StringBuilder lpPathBuf, ref uint cchPathBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiInstallMissingComponent(string szProduct, string szComponent, int eInstallState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiInstallMissingFile(string szProduct, string szFile); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern int MsiLocateComponent(string szComponent, StringBuilder lpPathBuf, ref uint cchBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProductProperty(int hProduct, string szProperty, StringBuilder lpValueBuf, ref uint cchValueBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetFeatureInfo(int hProduct, string szFeature, out uint lpAttributes, StringBuilder lpTitleBuf, ref uint cchTitleBuf, StringBuilder lpHelpBuf, ref uint cchHelpBuf); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiVerifyDiskSpace(int hInstall); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumComponentCosts(int hInstall, string szComponent, uint dwIndex, int iState, StringBuilder lpDriveBuf, ref uint cchDriveBuf, out int iCost, out int iTempCost); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetFeatureAttributes(int hInstall, string szFeature, uint dwAttributes); + +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiRemovePatches(string szPatchList, string szProductCode, int eUninstallType, string szPropertyList); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDetermineApplicablePatches(string szProductPackagePath, uint cPatchInfo, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1), In, Out] MsiPatchSequenceData[] pPatchInfo); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiDeterminePatchSequence(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint cPatchInfo, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3), In, Out] MsiPatchSequenceData[] pPatchInfo); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiApplyMultiplePatches(string szPatchPackages, string szProductCode, string szPropertiesList); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumPatchesEx(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwFilter, uint dwIndex, StringBuilder szPatchCode, StringBuilder szTargetProductCode, [MarshalAs(UnmanagedType.I4)] out UserContexts pdwTargetProductContext, StringBuilder szTargetUserSid, ref uint pcchTargetUserSid); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetPatchInfoEx(string szPatchCode, string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, string szProperty, StringBuilder lpValue, ref uint pcchValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEnumProductsEx(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwIndex, StringBuilder szInstalledProductCode, [MarshalAs(UnmanagedType.I4)] out UserContexts pdwInstalledContext, StringBuilder szSid, ref uint pcchSid); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetProductInfoEx(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, string szProperty, StringBuilder lpValue, ref uint pcchValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiQueryFeatureStateEx(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, string szFeature, out int pdwState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiQueryComponentState(string szProductCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, string szComponent, out int pdwState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiExtractPatchXMLData(string szPatchPath, uint dwReserved, StringBuilder szXMLData, ref uint pcchXMLData); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListEnumSources(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, uint dwIndex, StringBuilder szSource, ref uint pcchSource); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListAddSourceEx(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, string szSource, uint dwIndex); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListClearSource(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, string szSource); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListClearAllEx(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListForceResolutionEx(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListGetInfo(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, string szProperty, StringBuilder szValue, ref uint pcchValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListSetInfo(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, string szProperty, string szValue); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListEnumMediaDisks(string szProductCodeOrPatchCode, string szUserSID, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, uint dwIndex, out uint pdwDiskId, StringBuilder szVolumeLabel, ref uint pcchVolumeLabel, StringBuilder szDiskPrompt, ref uint pcchDiskPrompt); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListAddMediaDisk(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, uint dwDiskId, string szVolumeLabel, string szDiskPrompt); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSourceListClearMediaDisk(string szProductCodeOrPatchCode, string szUserSid, [MarshalAs(UnmanagedType.I4)] UserContexts dwContext, uint dwOptions, uint dwDiskID); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiNotifySidChange(string szOldSid, string szNewSid); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiSetExternalUIRecord([MarshalAs(UnmanagedType.FunctionPtr)] NativeExternalUIRecordHandler puiHandler, uint dwMessageFilter, IntPtr pvContext, out NativeExternalUIRecordHandler ppuiPrevHandler); + +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiGetPatchFileList(string szProductCode, string szPatchList, out uint cFiles, out IntPtr phFileRecords); + +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiBeginTransaction(string szTransactionName, int dwTransactionAttributes, out int hTransaction, out IntPtr phChangeOfOwnerEvent); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiEndTransaction(int dwTransactionState); +[DllImport("msi.dll", CharSet=CharSet.Unicode)] internal static extern uint MsiJoinTransaction(int hTransaction, int dwTransactionAttributes, out IntPtr phChangeOfOwnerEvent); + +[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode, EntryPoint="LoadLibraryExW")] internal static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, uint flags); +[DllImport("kernel32.dll", SetLastError=true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool FreeLibrary(IntPtr hModule); +[DllImport("kernel32.dll", SetLastError=true)] internal static extern IntPtr FindResourceEx(IntPtr hModule, IntPtr type, IntPtr name, ushort langId); +[DllImport("kernel32.dll", SetLastError=true)] internal static extern IntPtr LoadResource(IntPtr hModule, IntPtr lpResourceInfo); +[DllImport("kernel32.dll", SetLastError=true)] internal static extern IntPtr LockResource(IntPtr resourceData); +[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode, EntryPoint="FormatMessageW")] internal static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, StringBuilder lpBuffer, uint nSize, IntPtr Arguments); +[DllImport("kernel32.dll", SetLastError=true)] internal static extern int WaitForSingleObject(IntPtr handle, int milliseconds); + +[DllImport("ole32.dll")] internal static extern int StgOpenStorage([MarshalAs(UnmanagedType.LPWStr)] string wcsName, IntPtr stgPriority, uint grfMode, IntPtr snbExclude, uint reserved, [MarshalAs(UnmanagedType.Interface)] out IStorage stgOpen); +[DllImport("ole32.dll")] internal static extern int StgCreateDocfile([MarshalAs(UnmanagedType.LPWStr)] string wcsName, uint grfMode, uint reserved, [MarshalAs(UnmanagedType.Interface)] out IStorage stgOpen); + +[DllImport("user32.dll", CharSet=CharSet.Unicode, EntryPoint="MessageBoxW")] internal static extern MessageResult MessageBox(IntPtr hWnd, string lpText, string lpCaption, [MarshalAs(UnmanagedType.U4)] int uType); + + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] + internal struct MsiPatchSequenceData + { + public string szPatchData; + public int ePatchDataType; + public int dwOrder; + public uint dwStatus; + } + + internal class MsiHandle : SafeHandle + { + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] + public MsiHandle(IntPtr handle, bool ownsHandle) + : base(handle, ownsHandle) + { + } + + public override bool IsInvalid + { + get + { + return this.handle == IntPtr.Zero; + } + } + + public static implicit operator IntPtr(MsiHandle msiHandle) + { + return msiHandle.handle; + } + + [SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)] + protected override bool ReleaseHandle() + { + return RemotableNativeMethods.MsiCloseHandle((int) this.handle) == 0; + } + } +} +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/PatchInstallation.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/PatchInstallation.cs new file mode 100644 index 00000000..defbf64a --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/PatchInstallation.cs @@ -0,0 +1,413 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// The Patch object represents a unique instance of a patch that has been + /// registered or applied. + /// + public class PatchInstallation : Installation + { + /// + /// Enumerates all patch installations on the system. + /// + /// Enumeration of patch objects. + ///

+ /// Win32 MSI API: + /// MsiEnumPatches + ///

+ public static IEnumerable AllPatches + { + get + { + return PatchInstallation.GetPatches(null, null, null, UserContexts.All, PatchStates.All); + } + } + + /// + /// Enumerates patch installations based on certain criteria. + /// + /// PatchCode (GUID) of the patch to be enumerated. Only + /// instances of patches within the scope of the context specified by the + /// and parameters will be + /// enumerated. This parameter may be set to null to enumerate all patches in the specified + /// context. + /// ProductCode (GUID) product whose patches are to be + /// enumerated. If non-null, patch enumeration is restricted to instances of this product + /// within the specified context. If null, the patches for all products under the specified + /// context are enumerated. + /// Specifies a security identifier (SID) that restricts the context + /// of enumeration. A SID value other than s-1-1-0 is considered a user SID and restricts + /// enumeration to the current user or any user in the system. The special SID string + /// s-1-1-0 (Everyone) specifies enumeration across all users in the system. This parameter + /// can be set to null to restrict the enumeration scope to the current user. When + /// must be null. + /// Specifies the user context. + /// The of patches to return. + ///

+ /// Win32 MSI APIs: + /// MsiEnumPatchesEx + ///

+ public static IEnumerable GetPatches( + string patchCode, + string targetProductCode, + string userSid, + UserContexts context, + PatchStates states) + { + StringBuilder buf = new StringBuilder(40); + StringBuilder targetProductBuf = new StringBuilder(40); + UserContexts targetContext; + StringBuilder targetSidBuf = new StringBuilder(40); + for (uint i = 0; ; i++) + { + uint targetSidBufSize = (uint) targetSidBuf.Capacity; + uint ret = NativeMethods.MsiEnumPatchesEx( + targetProductCode, + userSid, + context, + (uint) states, + i, + buf, + targetProductBuf, + out targetContext, + targetSidBuf, + ref targetSidBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + targetSidBuf.Capacity = (int) ++targetSidBufSize; + ret = NativeMethods.MsiEnumPatchesEx( + targetProductCode, + userSid, + context, + (uint) states, + i, + buf, + targetProductBuf, + out targetContext, + targetSidBuf, + ref targetSidBufSize); + } + + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + string thisPatchCode = buf.ToString(); + if (patchCode == null || patchCode == thisPatchCode) + { + yield return new PatchInstallation( + buf.ToString(), + targetProductBuf.ToString(), + targetSidBuf.ToString(), + targetContext); + } + } + } + + private string productCode; + + /// + /// Creates a new object for accessing information about a patch installation on the current system. + /// + /// Patch code (GUID) of the patch. + /// ProductCode (GUID) the patch has been applied to. + /// This parameter may be null for patches that are registered only and not yet + /// applied to any product. + ///

+ /// All available user contexts will be queried. + ///

+ public PatchInstallation(string patchCode, string productCode) + : this(patchCode, productCode, null, UserContexts.All) + { + } + + /// + /// Creates a new object for accessing information about a patch installation on the current system. + /// + /// Registered patch code (GUID) of the patch. + /// ProductCode (GUID) the patch has been applied to. + /// This parameter may be null for patches that are registered only and not yet + /// applied to any product. + /// The specific user, when working in a user context. This + /// parameter may be null to indicate the current user. The parameter must be null + /// when working in a machine context. + /// The user context. The calling process must have administrative + /// privileges to get information for a product installed for a user other than the + /// current user. + ///

+ /// If the is null, the Patch object may + /// only be used to read and update the patch's SourceList information. + ///

+ public PatchInstallation(string patchCode, string productCode, string userSid, UserContexts context) + : base(patchCode, userSid, context) + { + if (String.IsNullOrEmpty(patchCode)) + { + throw new ArgumentNullException("patchCode"); + } + + this.productCode = productCode; + } + + /// + /// Gets the patch code (GUID) of the patch. + /// + public string PatchCode + { + get + { + return this.InstallationCode; + } + } + + /// + /// Gets the ProductCode (GUID) of the product. + /// + public string ProductCode + { + get + { + return this.productCode; + } + } + + /// + /// Gets a value indicating whether this patch is currently installed. + /// + public override bool IsInstalled + { + get + { + return (this.State & PatchStates.Applied) != 0; + } + } + + /// + /// Gets a value indicating whether this patch is marked as obsolte. + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Obsoleted")] + public bool IsObsoleted + { + get + { + return (this.State & PatchStates.Obsoleted) != 0; + } + } + + /// + /// Gets a value indicating whether this patch is present but has been + /// superseded by a more recent installed patch. + /// + public bool IsSuperseded + { + get + { + return (this.State & PatchStates.Superseded) != 0; + } + } + + internal override int InstallationType + { + get + { + const int MSICODE_PATCH = 0x40000000; + return MSICODE_PATCH; + } + } + + /// + /// Gets the installation state of this instance of the patch. + /// + /// An unknown patch was requested + /// The installer configuration data is corrupt + public PatchStates State + { + get + { + string stateString = this["State"]; + return (PatchStates) Int32.Parse(stateString, CultureInfo.InvariantCulture.NumberFormat); + } + } + + /// + /// Gets the cached patch file that the product uses. + /// + public string LocalPackage + { + get + { + return this["LocalPackage"]; + } + } + + /// + /// Gets the set of patch transforms that the last patch + /// installation applied to the product. + /// + ///

+ /// This value may not be available for per-user, non-managed applications + /// if the user is not logged on. + ///

+ public string Transforms + { + get + { + // TODO: convert to IList? + return this["Transforms"]; + } + } + + /// + /// Gets the date and time when the patch is applied to the product. + /// + public DateTime InstallDate + { + get + { + try + { + return DateTime.ParseExact( + this["InstallDate"], "yyyyMMdd", CultureInfo.InvariantCulture); + } + catch (FormatException) + { + return DateTime.MinValue; + } + } + } + + /// + /// True patch is marked as possible to uninstall from the product. + /// + ///

+ /// Even if this property is true, the installer can still block the + /// uninstallation if this patch is required by another patch that + /// cannot be uninstalled. + ///

+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Uninstallable")] + public bool Uninstallable + { + get + { + return this["Uninstallable"] == "1"; + } + } + + /// + /// Get the registered display name for the patch. + /// + public string DisplayName + { + get + { + return this["DisplayName"]; + } + } + + /// + /// Gets the registered support information URL for the patch. + /// + public Uri MoreInfoUrl + { + get + { + string value = this["MoreInfoURL"]; + if (!String.IsNullOrEmpty(value)) + { + try + { + return new Uri(value); + } + catch (UriFormatException) { } + } + + return null; + } + } + + /// + /// Gets information about a specific patch installation. + /// + /// The property being retrieved; see remarks for valid properties. + /// The property value, or an empty string if the property is not set for the patch. + /// An unknown patch or property was requested + /// The installer configuration data is corrupt + ///

+ /// Win32 MSI APIs: + /// MsiGetPatchInfo, + /// MsiGetPatchInfoEx + ///

+ public override string this[string propertyName] + { + get + { + StringBuilder buf = new StringBuilder(""); + uint bufSize = 0; + uint ret; + + if (this.Context == UserContexts.UserManaged || + this.Context == UserContexts.UserUnmanaged || + this.Context == UserContexts.Machine) + { + ret = NativeMethods.MsiGetPatchInfoEx( + this.PatchCode, + this.ProductCode, + this.UserSid, + this.Context, + propertyName, + buf, + ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiGetPatchInfoEx( + this.PatchCode, + this.ProductCode, + this.UserSid, + this.Context, + propertyName, + buf, + ref bufSize); + } + } + else + { + ret = NativeMethods.MsiGetPatchInfo( + this.PatchCode, + propertyName, + buf, + ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiGetPatchInfo( + this.PatchCode, + propertyName, + buf, + ref bufSize); + } + } + + if (ret != 0) + { + return null; + } + + return buf.ToString(); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ProductInstallation.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ProductInstallation.cs new file mode 100644 index 00000000..27739e17 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ProductInstallation.cs @@ -0,0 +1,801 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// Represents a unique instance of a product that + /// is either advertised, installed or unknown. + /// + public class ProductInstallation : Installation + { + /// + /// Gets the set of all products with a specified upgrade code. This method lists the + /// currently installed and advertised products that have the specified UpgradeCode + /// property in their Property table. + /// + /// Upgrade code of related products + /// Enumeration of product codes + ///

+ /// Win32 MSI API: + /// MsiEnumRelatedProducts + ///

+ public static IEnumerable GetRelatedProducts(string upgradeCode) + { + StringBuilder buf = new StringBuilder(40); + for (uint i = 0; true; i++) + { + uint ret = NativeMethods.MsiEnumRelatedProducts(upgradeCode, 0, i, buf); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + yield return new ProductInstallation(buf.ToString()); + } + } + + /// + /// Enumerates all product installations on the system. + /// + /// An enumeration of product objects. + ///

+ /// Win32 MSI API: + /// MsiEnumProducts, + ///

+ public static IEnumerable AllProducts + { + get + { + return GetProducts(null, null, UserContexts.All); + } + } + + /// + /// Enumerates product installations based on certain criteria. + /// + /// ProductCode (GUID) of the product instances to be enumerated. Only + /// instances of products within the scope of the context specified by the + /// and parameters will be + /// enumerated. This parameter may be set to null to enumerate all products in the specified + /// context. + /// Specifies a security identifier (SID) that restricts the context + /// of enumeration. A SID value other than s-1-1-0 is considered a user SID and restricts + /// enumeration to the current user or any user in the system. The special SID string + /// s-1-1-0 (Everyone) specifies enumeration across all users in the system. This parameter + /// can be set to null to restrict the enumeration scope to the current user. When + /// is set to the machine context only, + /// must be null. + /// Specifies the user context. + /// An enumeration of product objects for enumerated product instances. + ///

+ /// Win32 MSI API: + /// MsiEnumProductsEx + ///

+ public static IEnumerable GetProducts( + string productCode, string userSid, UserContexts context) + { + StringBuilder buf = new StringBuilder(40); + UserContexts targetContext; + StringBuilder targetSidBuf = new StringBuilder(40); + for (uint i = 0; ; i++) + { + uint targetSidBufSize = (uint) targetSidBuf.Capacity; + uint ret = NativeMethods.MsiEnumProductsEx( + productCode, + userSid, + context, + i, + buf, + out targetContext, + targetSidBuf, + ref targetSidBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + targetSidBuf.Capacity = (int) ++targetSidBufSize; + ret = NativeMethods.MsiEnumProductsEx( + productCode, + userSid, + context, + i, + buf, + out targetContext, + targetSidBuf, + ref targetSidBufSize); + } + + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + yield return new ProductInstallation( + buf.ToString(), + targetSidBuf.ToString(), + targetContext); + } + } + + private IDictionary properties; + + /// + /// Creates a new object for accessing information about a product installation on the current system. + /// + /// ProductCode (GUID) of the product. + ///

+ /// All available user contexts will be queried. + ///

+ public ProductInstallation(string productCode) + : this(productCode, null, UserContexts.All) + { + } + + /// + /// Creates a new object for accessing information about a product installation on the current system. + /// + /// ProductCode (GUID) of the product. + /// The specific user, when working in a user context. This + /// parameter may be null to indicate the current user. The parameter must be null + /// when working in a machine context. + /// The user context. The calling process must have administrative + /// privileges to get information for a product installed for a user other than the + /// current user. + public ProductInstallation(string productCode, string userSid, UserContexts context) + : base(productCode, userSid, context) + { + if (String.IsNullOrEmpty(productCode)) + { + throw new ArgumentNullException("productCode"); + } + } + + internal ProductInstallation(IDictionary properties) + : base(properties["ProductCode"], null, UserContexts.None) + { + this.properties = properties; + } + + /// + /// Gets the set of published features for the product. + /// + /// Enumeration of published features for the product. + /// The installer configuration data is corrupt + ///

+ /// Because features are not ordered, any new feature has an arbitrary index, meaning + /// this property can return features in any order. + ///

+ /// Win32 MSI API: + /// MsiEnumFeatures + ///

+ public IEnumerable Features + { + get + { + StringBuilder buf = new StringBuilder(256); + for (uint i = 0; ; i++) + { + uint ret = NativeMethods.MsiEnumFeatures(this.ProductCode, i, buf, null); + + if (ret != 0) + { + break; + } + + yield return new FeatureInstallation(buf.ToString(), this.ProductCode); + } + } + } + + /// + /// Gets the ProductCode (GUID) of the product. + /// + public string ProductCode + { + get { return this.InstallationCode; } + } + + /// + /// Gets a value indicating whether this product is installed on the current system. + /// + public override bool IsInstalled + { + get + { + return (this.State == InstallState.Default); + } + } + + /// + /// Gets a value indicating whether this product is advertised on the current system. + /// + public bool IsAdvertised + { + get + { + return (this.State == InstallState.Advertised); + } + } + + /// + /// Checks whether the product is installed with elevated privileges. An application is called + /// a "managed application" if elevated (system) privileges are used to install the application. + /// + /// True if the product is elevated; false otherwise + ///

+ /// Note that this property does not take into account policies such as AlwaysInstallElevated, + /// but verifies that the local system owns the product's registry data. + ///

+ public bool IsElevated + { + get + { + bool isElevated; + uint ret = NativeMethods.MsiIsProductElevated(this.ProductCode, out isElevated); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return isElevated; + } + } + + /// + /// Gets the source list of this product installation. + /// + public override SourceList SourceList + { + get + { + return this.properties == null ? base.SourceList : null; + } + } + + internal InstallState State + { + get + { + if (this.properties != null) + { + return InstallState.Unknown; + } + else + { + int installState = NativeMethods.MsiQueryProductState(this.ProductCode); + return (InstallState) installState; + } + } + } + + internal override int InstallationType + { + get + { + const int MSICODE_PRODUCT = 0x00000000; + return MSICODE_PRODUCT; + } + } + + /// + /// The support link. + /// + public string HelpLink + { + get + { + return this["HelpLink"]; + } + } + + /// + /// The support telephone. + /// + public string HelpTelephone + { + get + { + return this["HelpTelephone"]; + } + } + + /// + /// Date and time the product was installed. + /// + public DateTime InstallDate + { + get + { + try + { + return DateTime.ParseExact( + this["InstallDate"], "yyyyMMdd", CultureInfo.InvariantCulture); + } + catch (FormatException) + { + return DateTime.MinValue; + } + } + } + + /// + /// The installed product name. + /// + public string ProductName + { + get + { + return this["InstalledProductName"]; + } + } + + /// + /// The installation location. + /// + public string InstallLocation + { + get + { + return this["InstallLocation"]; + } + } + + /// + /// The installation source. + /// + public string InstallSource + { + get + { + return this["InstallSource"]; + } + } + + /// + /// The local cached package. + /// + public string LocalPackage + { + get + { + return this["LocalPackage"]; + } + } + + /// + /// The publisher. + /// + public string Publisher + { + get + { + return this["Publisher"]; + } + } + + /// + /// URL about information. + /// + public Uri UrlInfoAbout + { + get + { + string value = this["URLInfoAbout"]; + if (!String.IsNullOrEmpty(value)) + { + try + { + return new Uri(value); + } + catch (UriFormatException) { } + } + + return null; + } + } + + /// + /// The URL update information. + /// + public Uri UrlUpdateInfo + { + get + { + string value = this["URLUpdateInfo"]; + if (!String.IsNullOrEmpty(value)) + { + try + { + return new Uri(value); + } + catch (UriFormatException) { } + } + + return null; + } + } + + /// + /// The product version. + /// + public Version ProductVersion + { + get + { + string ver = this["VersionString"]; + return ProductInstallation.ParseVersion(ver); + } + } + + /// + /// The product identifier. + /// + ///

+ /// For more information, see + /// ProductID + ///

+ public string ProductId + { + get + { + return this["ProductID"]; + } + } + + /// + /// The company that is registered to use the product. + /// + public string RegCompany + { + get + { + return this["RegCompany"]; + } + } + + /// + /// The owner who is registered to use the product. + /// + public string RegOwner + { + get + { + return this["RegOwner"]; + } + } + + /// + /// Transforms. + /// + public string AdvertisedTransforms + { + get + { + return this["Transforms"]; + } + } + + /// + /// Product language. + /// + public string AdvertisedLanguage + { + get + { + return this["Language"]; + } + } + + /// + /// Human readable product name. + /// + public string AdvertisedProductName + { + get + { + return this["ProductName"]; + } + } + + /// + /// True if the product is advertised per-machine; + /// false if it is per-user or not advertised. + /// + public bool AdvertisedPerMachine + { + get + { + return this["AssignmentType"] == "1"; + } + } + + /// + /// Identifier of the package that a product is installed from. + /// + public string AdvertisedPackageCode + { + get + { + return this["PackageCode"]; + } + } + + /// + /// Version of the advertised product. + /// + public Version AdvertisedVersion + { + get + { + string ver = this["Version"]; + return ProductInstallation.ParseVersion(ver); + } + } + + /// + /// Primary icon for the package. + /// + public string AdvertisedProductIcon + { + get + { + return this["ProductIcon"]; + } + } + + /// + /// Name of the installation package for the advertised product. + /// + public string AdvertisedPackageName + { + get + { + return this["PackageName"]; + } + } + + /// + /// True if the advertised product can be serviced by + /// non-administrators without elevation. + /// + public bool PrivilegedPatchingAuthorized + { + get + { + return this["AuthorizedLUAApp"] == "1"; + } + } + + /// + /// Gets information about an installation of a product. + /// + /// Name of the property being retrieved. + /// An unknown product or property was requested + /// The installer configuration data is corrupt + ///

+ /// Win32 MSI APIs: + /// MsiGetProductInfo, + /// MsiGetProductInfoEx + ///

+ public override string this[string propertyName] + { + get + { + if (this.properties != null) + { + string value = null; + this.properties.TryGetValue(propertyName, out value); + return value; + } + else + { + StringBuilder buf = new StringBuilder(40); + uint bufSize = (uint) buf.Capacity; + uint ret; + + if (this.Context == UserContexts.UserManaged || + this.Context == UserContexts.UserUnmanaged || + this.Context == UserContexts.Machine) + { + ret = NativeMethods.MsiGetProductInfoEx( + this.ProductCode, + this.UserSid, + this.Context, + propertyName, + buf, + ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiGetProductInfoEx( + this.ProductCode, + this.UserSid, + this.Context, + propertyName, + buf, + ref bufSize); + } + } + else + { + ret = NativeMethods.MsiGetProductInfo( + this.ProductCode, + propertyName, + buf, + ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiGetProductInfo( + this.ProductCode, + propertyName, + buf, + ref bufSize); + } + } + + if (ret != 0) + { + return null; + } + + return buf.ToString(); + } + } + } + + /// + /// Gets the installed state for a product feature. + /// + /// The feature being queried; identifier from the + /// Feature table + /// Installation state of the feature for the product instance: either + /// , , + /// or . + ///

+ /// Win32 MSI APIs: + /// MsiQueryFeatureState, + /// MsiQueryFeatureStateEx + ///

+ public InstallState GetFeatureState(string feature) + { + if (this.properties != null) + { + return InstallState.Unknown; + } + else + { + int installState; + uint ret = NativeMethods.MsiQueryFeatureStateEx( + this.ProductCode, + this.UserSid, + this.Context, + feature, + out installState); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return (InstallState) installState; + } + } + + /// + /// Gets the installed state for a product component. + /// + /// The component being queried; GUID of the component + /// as found in the ComponentId column of the Component table. + /// Installation state of the component for the product instance: either + /// or . + ///

+ /// Win32 MSI API: + /// MsiQueryComponentState + ///

+ public InstallState GetComponentState(string component) + { + if (this.properties != null) + { + return InstallState.Unknown; + } + else + { + int installState; + uint ret = NativeMethods.MsiQueryComponentState( + this.ProductCode, + this.UserSid, + this.Context, + component, + out installState); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return (InstallState) installState; + } + } + + /// + /// Obtains and stores the user information and product ID from an installation wizard. + /// + ///

+ /// This method is typically called by an application during the first run of the application. The application + /// first gets the or . + /// If those properties are missing, the application calls CollectUserInfo. + /// CollectUserInfo opens the product's installation package and invokes a wizard sequence that collects + /// user information. Upon completion of the sequence, user information is registered. Since this API requires + /// an authored user interface, the user interface level should be set to full by calling + /// as . + ///

+ /// The CollectUserInfo method invokes a FirstRun dialog from the product installation database. + ///

+ /// Win32 MSI API: + /// MsiCollectUserInfo + ///

+ public void CollectUserInfo() + { + if (this.properties == null) + { + uint ret = NativeMethods.MsiCollectUserInfo(this.InstallationCode); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Some products might write some invalid/nonstandard version strings to the registry. + /// This method tries to get the best data it can. + /// + /// Version string retrieved from the registry. + /// Version object, or null if the version string is completely invalid. + private static Version ParseVersion(string ver) + { + if (ver != null) + { + int dotCount = 0; + for (int i = 0; i < ver.Length; i++) + { + char c = ver[i]; + if (c == '.') dotCount++; + else if (!Char.IsDigit(c)) + { + ver = ver.Substring(0, i); + break; + } + } + + if (ver.Length > 0) + { + if (dotCount == 0) + { + ver = ver + ".0"; + } + else if (dotCount > 3) + { + string[] verSplit = ver.Split('.'); + ver = String.Join(".", verSplit, 0, 4); + } + + try + { + return new Version(ver); + } + catch (ArgumentException) + { + } + } + } + + return null; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Record.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Record.cs new file mode 100644 index 00000000..2d31fa75 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Record.cs @@ -0,0 +1,1048 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Collections.Generic; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + /// + /// The Record object is a container for holding and transferring a variable number of values. + /// Fields within the record are numerically indexed and can contain strings, integers, streams, + /// and null values. Record fields are indexed starting with 1. Field 0 is a special format field. + /// + ///

+ /// Most methods on the Record class have overloads that allow using either a number + /// or a name to designate a field. However note that field names only exist when the + /// Record is directly returned from a query on a database. For other records, attempting + /// to access a field by name will result in an InvalidOperationException. + ///

+ public class Record : InstallerHandle + { + private View view; + private bool isFormatStringInvalid; + + /// + /// IsFormatStringInvalid is set from several View methods that invalidate the FormatString + /// and used to determine behavior during Record.ToString(). + /// + internal protected bool IsFormatStringInvalid + { + set { this.isFormatStringInvalid = value; } + + get { return this.isFormatStringInvalid; } + } + + /// + /// Creates a new record object with the requested number of fields. + /// + /// Required number of fields, which may be 0. + /// The maximum number of fields in a record is limited to 65535. + ///

+ /// The Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiCreateRecord + ///

+ public Record(int fieldCount) + : this((IntPtr) RemotableNativeMethods.MsiCreateRecord((uint) fieldCount, 0), true, (View) null) + { + } + + /// + /// Creates a new record object, providing values for an arbitrary number of fields. + /// + /// The values of the record fields. The parameters should be of type Int16, Int32 or String + ///

+ /// The Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiCreateRecord + ///

+ public Record(params object[] fields) + : this(fields.Length) + { + for (int i = 0; i < fields.Length; i++) + { + this[i + 1] = fields[i]; + } + } + + internal Record(IntPtr handle, bool ownsHandle, View view) + : base(handle, ownsHandle) + { + this.view = view; + } + + /// + /// Gets the number of fields in a record. + /// + ///

+ /// Win32 MSI API: + /// MsiRecordGetFieldCount + ///

+ public int FieldCount + { + get + { + return (int) RemotableNativeMethods.MsiRecordGetFieldCount((int) this.Handle); + } + } + + /// + /// Gets or sets field 0 of the Record, which is the format string. + /// + public string FormatString + { + get { return this.GetString(0); } + set { this.SetString(0, value); } + } + + /// + /// Gets or sets a record field value. + /// + /// Specifies the name of the field of the Record to get or set. + /// The name does not match any known field of the Record. + ///

+ /// When getting a field, the type of the object returned depends on the type of the Record field. + /// The object will be one of: Int16, Int32, String, Stream, or null. + ///

+ /// When setting a field, the type of the object provided will be converted to match the View + /// query that returned the record, or if Record was not returned from a view then the type of + /// the object provided will determine the type of the Record field. The object should be one of: + /// Int16, Int32, String, Stream, or null. + ///

+ public object this[string fieldName] + { + get + { + int field = this.FindColumn(fieldName); + return this[field]; + } + + set + { + int field = this.FindColumn(fieldName); + this[field] = value; + } + } + + /// + /// Gets or sets a record field value. + /// + /// Specifies the field of the Record to get or set. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Record fields are indexed starting with 1. Field 0 is a special format field. + ///

+ /// When getting a field, the type of the object returned depends on the type of the Record field. + /// The object will be one of: Int16, Int32, String, Stream, or null. If the Record was returned + /// from a View, the type will match that of the field from the View query. Otherwise, the type + /// will match the type of the last value set for the field. + ///

+ /// When setting a field, the type of the object provided will be converted to match the View + /// query that returned the Record, or if Record was not returned from a View then the type of + /// the object provided will determine the type of the Record field. The object should be one of: + /// Int16, Int32, String, Stream, or null. + ///

+ /// The type-specific getters and setters are slightly more efficient than this property, since + /// they don't have to do the extra work to infer the value's type every time. + ///

+ /// Win32 MSI APIs: + /// MsiRecordGetInteger, + /// MsiRecordGetString, + /// MsiRecordSetInteger, + /// MsiRecordSetString + ///

+ public object this[int field] + { + get + { + if (field == 0) + { + return this.GetString(0); + } + else + { + Type valueType = null; + if (this.view != null) + { + this.CheckRange(field); + + valueType = this.view.Columns[field - 1].Type; + } + + if (valueType == null || valueType == typeof(String)) + { + return this.GetString(field); + } + else if (valueType == typeof(Stream)) + { + return this.IsNull(field) ? null : new RecordStream(this, field); + } + else + { + int? value = this.GetNullableInteger(field); + return value.HasValue ? (object) value.Value : null; + } + } + } + + set + { + if (field == 0) + { + if (value == null) + { + value = String.Empty; + } + + this.SetString(0, value.ToString()); + } + else if (value == null) + { + this.SetNullableInteger(field, null); + } + else + { + Type valueType = value.GetType(); + if (valueType == typeof(Int32) || valueType == typeof(Int16)) + { + this.SetInteger(field, (int) value); + } + else if (valueType.IsSubclassOf(typeof(Stream))) + { + this.SetStream(field, (Stream) value); + } + else + { + this.SetString(field, value.ToString()); + } + } + } + } + + /// + /// Creates a new Record object from an integer record handle. + /// + ///

+ /// This method is only provided for interop purposes. A Record object + /// should normally be obtained by calling + /// other methods. + ///

The handle will be closed when this object is disposed or finalized.

+ ///

+ /// Integer record handle + /// true to close the handle when this object is disposed or finalized + public static Record FromHandle(IntPtr handle, bool ownsHandle) + { + return new Record(handle, ownsHandle, (View) null); + } + + /// + /// Sets all fields in a record to null. + /// + ///

+ /// Win32 MSI API: + /// MsiRecordClearData + ///

+ public void Clear() + { + uint ret = RemotableNativeMethods.MsiRecordClearData((int) this.Handle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Reports whether a record field is null. + /// + /// Specifies the field to check. + /// True if the field is null, false otherwise. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordIsNull + ///

+ public bool IsNull(int field) + { + this.CheckRange(field); + return RemotableNativeMethods.MsiRecordIsNull((int) this.Handle, (uint) field); + } + + /// + /// Reports whether a record field is null. + /// + /// Specifies the field to check. + /// True if the field is null, false otherwise. + /// The field name does not match any + /// of the named fields in the Record. + public bool IsNull(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.IsNull(field); + } + + /// + /// Gets the length of a record field. The count does not include the terminating null. + /// + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// The returned data size is 0 if the field is null, non-existent, + /// or an internal object pointer. The method also returns 0 if the handle is not a valid + /// Record handle. + ///

+ /// If the data is in integer format, the property returns 2 or 4. + ///

+ /// If the data is in string format, the property returns the character count + /// (not including the NULL terminator). + ///

+ /// If the data is in stream format, the property returns the byte count. + ///

+ /// Win32 MSI API: + /// MsiRecordDataSize + ///

+ public int GetDataSize(int field) + { + this.CheckRange(field); + return (int) RemotableNativeMethods.MsiRecordDataSize((int) this.Handle, (uint) field); + } + + /// + /// Gets the length of a record field. The count does not include the terminating null. + /// + /// Specifies the field to check. + /// The field name does not match any + /// of the named fields in the Record. + ///

The returned data size is 0 if the field is null, non-existent, + /// or an internal object pointer. The method also returns 0 if the handle is not a valid + /// Record handle. + ///

+ /// If the data is in integer format, the property returns 2 or 4. + ///

+ /// If the data is in string format, the property returns the character count + /// (not including the NULL terminator). + ///

+ /// If the data is in stream format, the property returns the byte count. + ///

+ public int GetDataSize(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.GetDataSize(field); + } + + /// + /// Gets a field value as an integer. + /// + /// Specifies the field to retrieve. + /// Integer value of the field, or 0 if the field is null. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordGetInteger + ///

+ /// + [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "integer")] + public int GetInteger(int field) + { + this.CheckRange(field); + + int value = RemotableNativeMethods.MsiRecordGetInteger((int) this.Handle, (uint) field); + if (value == Int32.MinValue) // MSI_NULL_INTEGER + { + return 0; + } + return value; + } + + /// + /// Gets a field value as an integer. + /// + /// Specifies the field to retrieve. + /// Integer value of the field, or 0 if the field is null. + /// The field name does not match any + /// of the named fields in the Record. + /// + [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "integer")] + public int GetInteger(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.GetInteger(field); + } + + /// + /// Gets a field value as an integer. + /// + /// Specifies the field to retrieve. + /// Integer value of the field, or null if the field is null. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordGetInteger + ///

+ /// + public int? GetNullableInteger(int field) + { + this.CheckRange(field); + + int value = RemotableNativeMethods.MsiRecordGetInteger((int) this.Handle, (uint) field); + if (value == Int32.MinValue) // MSI_NULL_INTEGER + { + return null; + } + return value; + } + + /// + /// Gets a field value as an integer. + /// + /// Specifies the field to retrieve. + /// Integer value of the field, or null if the field is null. + /// The field name does not match any + /// of the named fields in the Record. + /// + public int? GetNullableInteger(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.GetInteger(field); + } + + /// + /// Sets the value of a field to an integer. + /// + /// Specifies the field to set. + /// new value of the field + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordSetInteger + ///

+ /// + public void SetInteger(int field, int value) + { + this.CheckRange(field); + + uint ret = RemotableNativeMethods.MsiRecordSetInteger((int) this.Handle, (uint) field, value); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Sets the value of a field to an integer. + /// + /// Specifies the field to set. + /// new value of the field + /// The field name does not match any + /// of the named fields in the Record. + /// + public void SetInteger(string fieldName, int value) + { + int field = this.FindColumn(fieldName); + this.SetInteger(field, value); + } + + /// + /// Sets the value of a field to a nullable integer. + /// + /// Specifies the field to set. + /// new value of the field + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordSetInteger + ///

+ /// + public void SetNullableInteger(int field, int? value) + { + this.CheckRange(field); + + uint ret = RemotableNativeMethods.MsiRecordSetInteger( + (int) this.Handle, + (uint) field, + value.HasValue ? (int) value : Int32.MinValue); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Sets the value of a field to a nullable integer. + /// + /// Specifies the field to set. + /// new value of the field + /// The field name does not match any + /// of the named fields in the Record. + /// + public void SetNullableInteger(string fieldName, int? value) + { + int field = this.FindColumn(fieldName); + this.SetNullableInteger(field, value); + } + + /// + /// Gets a field value as a string. + /// + /// Specifies the field to retrieve. + /// String value of the field, or an empty string if the field is null. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordGetString + ///

+ public string GetString(int field) + { + this.CheckRange(field); + + StringBuilder buf = new StringBuilder(String.Empty); + uint bufSize = 0; + uint ret = RemotableNativeMethods.MsiRecordGetString((int) this.Handle, (uint) field, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = RemotableNativeMethods.MsiRecordGetString((int) this.Handle, (uint) field, buf, ref bufSize); + } + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return buf.ToString(); + } + + /// + /// Gets a field value as a string. + /// + /// Specifies the field to retrieve. + /// String value of the field, or an empty string if the field is null. + /// The field name does not match any + /// of the named fields in the Record. + public string GetString(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.GetString(field); + } + + /// + /// Sets the value of a field to a string. + /// + /// Specifies the field to set. + /// new value of the field + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// Win32 MSI API: + /// MsiRecordSetString + ///

+ public void SetString(int field, string value) + { + this.CheckRange(field); + + if (value == null) + { + value = String.Empty; + } + + uint ret = RemotableNativeMethods.MsiRecordSetString((int) this.Handle, (uint) field, value); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + // If we set the FormatString manually, then it should be valid again + if (field == 0) + { + this.IsFormatStringInvalid = false; + } + } + + /// + /// Sets the value of a field to a string. + /// + /// Specifies the field to set. + /// new value of the field + /// The field name does not match any + /// of the named fields in the Record. + public void SetString(string fieldName, string value) + { + int field = this.FindColumn(fieldName); + this.SetString(field, value); + } + + /// + /// Reads a record stream field into a file. + /// + /// Specifies the field of the Record to get. + /// Specifies the path to the file to contain the stream. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + /// Attempt to extract a storage from a database open + /// in read-write mode, or from a database without an associated file path + ///

+ /// This method is capable of directly extracting substorages. To do so, first select both the + /// `Name` and `Data` column of the `_Storages` table, then get the stream of the `Data` field. + /// However, substorages may only be extracted from a database that is open in read-only mode. + ///

+ /// Win32 MSI API: + /// MsiRecordReadStream + ///

+ public void GetStream(int field, string filePath) + { + if (String.IsNullOrEmpty(filePath)) + { + throw new ArgumentNullException("filePath"); + } + + IList tables = (this.view != null ? this.view.Tables : null); + if (tables != null && tables.Count == 1 && tables[0].Name == "_Storages" && field == this.FindColumn("Data")) + { + if (!this.view.Database.IsReadOnly) + { + throw new NotSupportedException("Database must be opened read-only to support substorage extraction."); + } + else if (this.view.Database.FilePath == null) + { + throw new NotSupportedException("Database must have an associated file path to support substorage extraction."); + } + else if (this.FindColumn("Name") <= 0) + { + throw new NotSupportedException("Name column must be part of the Record in order to extract substorage."); + } + else + { + Record.ExtractSubStorage(this.view.Database.FilePath, this.GetString("Name"), filePath); + } + } + else + { + if (!this.IsNull(field)) + { + Stream readStream = null, writeStream = null; + try + { + readStream = new RecordStream(this, field); + writeStream = new FileStream(filePath, FileMode.Create, FileAccess.Write); + int count = 512; + byte[] buf = new byte[count]; + while (count == buf.Length) + { + if ((count = readStream.Read(buf, 0, buf.Length)) > 0) + { + writeStream.Write(buf, 0, count); + } + } + } + finally + { + if (readStream != null) readStream.Close(); + if (writeStream != null) writeStream.Close(); + } + } + } + } + + /// + /// Reads a record stream field into a file. + /// + /// Specifies the field of the Record to get. + /// Specifies the path to the file to contain the stream. + /// The field name does not match any + /// of the named fields in the Record. + /// Attempt to extract a storage from a database open + /// in read-write mode, or from a database without an associated file path + ///

+ /// This method is capable of directly extracting substorages. To do so, first select both the + /// `Name` and `Data` column of the `_Storages` table, then get the stream of the `Data` field. + /// However, substorages may only be extracted from a database that is open in read-only mode. + ///

+ public void GetStream(string fieldName, string filePath) + { + int field = this.FindColumn(fieldName); + this.GetStream(field, filePath); + } + + /// + /// Gets a record stream field. + /// + /// Specifies the field of the Record to get. + /// A Stream that reads the field data. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// This method is not capable of reading substorages. To extract a substorage, + /// use . + ///

+ /// Win32 MSI API: + /// MsiRecordReadStream + ///

+ public Stream GetStream(int field) + { + this.CheckRange(field); + + return this.IsNull(field) ? null : new RecordStream(this, field); + } + + /// + /// Gets a record stream field. + /// + /// Specifies the field of the Record to get. + /// A Stream that reads the field data. + /// The field name does not match any + /// of the named fields in the Record. + ///

+ /// This method is not capable of reading substorages. To extract a substorage, + /// use . + ///

+ public Stream GetStream(string fieldName) + { + int field = this.FindColumn(fieldName); + return this.GetStream(field); + } + + /// + /// Sets a record stream field from a file. Stream data cannot be inserted into temporary fields. + /// + /// Specifies the field of the Record to set. + /// Specifies the path to the file containing the stream. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// The contents of the specified file are read into a stream object. The stream persists if + /// the Record is inserted into the Database and the Database is committed. + ///

+ /// To reset the stream to its beginning you must pass in null for filePath. + /// Do not pass an empty string, "", to reset the stream. + ///

+ /// Setting a stream with this method is more efficient than setting a field to a + /// FileStream object. + ///

+ /// Win32 MSI API: + /// MsiRecordsetStream + ///

+ public void SetStream(int field, string filePath) + { + this.CheckRange(field); + + if (String.IsNullOrEmpty(filePath)) + { + throw new ArgumentNullException("filePath"); + } + + uint ret = RemotableNativeMethods.MsiRecordSetStream((int) this.Handle, (uint) field, filePath); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Sets a record stream field from a file. Stream data cannot be inserted into temporary fields. + /// + /// Specifies the field name of the Record to set. + /// Specifies the path to the file containing the stream. + /// The field name does not match any + /// of the named fields in the Record. + ///

+ /// The contents of the specified file are read into a stream object. The stream persists if + /// the Record is inserted into the Database and the Database is committed. + /// To reset the stream to its beginning you must pass in null for filePath. + /// Do not pass an empty string, "", to reset the stream. + ///

+ /// Setting a stream with this method is more efficient than setting a field to a + /// FileStream object. + ///

+ public void SetStream(string fieldName, string filePath) + { + int field = this.FindColumn(fieldName); + this.SetStream(field, filePath); + } + + /// + /// Sets a record stream field from a Stream object. Stream data cannot be inserted into temporary fields. + /// + /// Specifies the field of the Record to set. + /// Specifies the stream data. + /// The field is less than 0 or greater than the + /// number of fields in the Record. + ///

+ /// The stream persists if the Record is inserted into the Database and the Database is committed. + ///

+ /// Win32 MSI API: + /// MsiRecordsetStream + ///

+ public void SetStream(int field, Stream stream) + { + this.CheckRange(field); + + if (stream == null) + { + uint ret = RemotableNativeMethods.MsiRecordSetStream((int) this.Handle, (uint) field, null); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + else + { + Stream writeStream = null; + string tempPath = Path.GetTempFileName(); + try + { + writeStream = new FileStream(tempPath, FileMode.Truncate, FileAccess.Write); + byte[] buf = new byte[512]; + int count; + while ((count = stream.Read(buf, 0, buf.Length)) > 0) + { + writeStream.Write(buf, 0, count); + } + writeStream.Close(); + writeStream = null; + + uint ret = RemotableNativeMethods.MsiRecordSetStream((int) this.Handle, (uint) field, tempPath); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + finally + { + if (writeStream != null) writeStream.Close(); + if (File.Exists(tempPath)) + { + try + { + File.Delete(tempPath); + } + catch (IOException) + { + if (this.view != null) + { + this.view.Database.DeleteOnClose(tempPath); + } + } + } + } + } + } + + /// + /// Sets a record stream field from a Stream object. Stream data cannot be inserted into temporary fields. + /// + /// Specifies the field name of the Record to set. + /// Specifies the stream data. + /// The field name does not match any + /// of the named fields in the Record. + ///

+ /// The stream persists if the Record is inserted into the Database and the Database is committed. + ///

+ public void SetStream(string fieldName, Stream stream) + { + int field = this.FindColumn(fieldName); + this.SetStream(field, stream); + } + + /// + /// Gets a formatted string representation of the Record. + /// + /// A formatted string representation of the Record. + ///

+ /// If field 0 of the Record is set to a nonempty string, it is used to format the data in the Record. + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ /// + /// + public override string ToString() + { + return this.ToString((IFormatProvider) null); + } + + /// + /// Gets a formatted string representation of the Record, optionally using a Session to format properties. + /// + /// an optional Session instance that will be used to lookup any + /// properties in the Record's format string + /// A formatted string representation of the Record. + ///

+ /// If field 0 of the Record is set to a nonempty string, it is used to format the data in the Record. + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ /// + /// + public string ToString(IFormatProvider provider) + { + if (this.IsFormatStringInvalid) // Format string is invalid + { + // TODO: return all values by default? + return String.Empty; + } + + InstallerHandle session = provider as InstallerHandle; + int sessionHandle = session != null ? (int) session.Handle : 0; + StringBuilder buf = new StringBuilder(String.Empty); + uint bufSize = 1; + uint ret = RemotableNativeMethods.MsiFormatRecord(sessionHandle, (int) this.Handle, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + bufSize++; + buf = new StringBuilder((int) bufSize); + ret = RemotableNativeMethods.MsiFormatRecord(sessionHandle, (int) this.Handle, buf, ref bufSize); + } + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return buf.ToString(); + } + + /// + /// Gets a formatted string representation of the Record. + /// + /// String to be used to format the data in the Record, + /// instead of the Record's format string. + /// A formatted string representation of the Record. + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ [Obsolete("This method is obsolete because it has undesirable side-effects. As an alternative, set the FormatString " + + "property separately before calling the ToString() override that takes no parameters.")] + public string ToString(string format) + { + return this.ToString(format, null); + } + + /// + /// Gets a formatted string representation of the Record, optionally using a Session to format properties. + /// + /// String to be used to format the data in the Record, + /// instead of the Record's format string. + /// an optional Session instance that will be used to lookup any + /// properties in the Record's format string + /// A formatted string representation of the Record. + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ /// + /// + [Obsolete("This method is obsolete because it has undesirable side-effects. As an alternative, set the FormatString " + + "property separately before calling the ToString() override that takes just a format provider.")] + public string ToString(string format, IFormatProvider provider) + { + if (format == null) + { + return this.ToString(provider); + } + else if (format.Length == 0) + { + return String.Empty; + } + else + { + string savedFormatString = (string) this[0]; + try + { + this.FormatString = format; + return this.ToString(provider); + } + finally + { + this.FormatString = savedFormatString; + } + } + } + + [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] + private static void ExtractSubStorage(string databaseFile, string storageName, string extractFile) + { + IStorage storage; + NativeMethods.STGM openMode = NativeMethods.STGM.READ | NativeMethods.STGM.SHARE_DENY_WRITE; + int hr = NativeMethods.StgOpenStorage(databaseFile, IntPtr.Zero, (uint) openMode, IntPtr.Zero, 0, out storage); + if (hr != 0) + { + Marshal.ThrowExceptionForHR(hr); + } + + try + { + openMode = NativeMethods.STGM.READ | NativeMethods.STGM.SHARE_EXCLUSIVE; + IStorage subStorage = storage.OpenStorage(storageName, IntPtr.Zero, (uint) openMode, IntPtr.Zero, 0); + + try + { + IStorage newStorage; + openMode = NativeMethods.STGM.CREATE | NativeMethods.STGM.READWRITE | NativeMethods.STGM.SHARE_EXCLUSIVE; + hr = NativeMethods.StgCreateDocfile(extractFile, (uint) openMode, 0, out newStorage); + if (hr != 0) + { + Marshal.ThrowExceptionForHR(hr); + } + + try + { + subStorage.CopyTo(0, IntPtr.Zero, IntPtr.Zero, newStorage); + + newStorage.Commit(0); + } + finally + { + Marshal.ReleaseComObject(newStorage); + } + } + finally + { + Marshal.ReleaseComObject(subStorage); + } + } + finally + { + Marshal.ReleaseComObject(storage); + } + } + + private int FindColumn(string fieldName) + { + if (this.view == null) + { + throw new InvalidOperationException(); + } + ColumnCollection columns = this.view.Columns; + for (int i = 0; i < columns.Count; i++) + { + if (columns[i].Name == fieldName) + { + return i + 1; + } + } + throw new ArgumentOutOfRangeException("fieldName"); + } + + private void CheckRange(int field) + { + if (field < 0 || field > this.FieldCount) + { + throw new ArgumentOutOfRangeException("field"); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RecordStream.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RecordStream.cs new file mode 100644 index 00000000..82e8fb46 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RecordStream.cs @@ -0,0 +1,92 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + + internal class RecordStream : Stream + { + private Record record; + private int field; + private long position; + + internal RecordStream(Record record, int field) + : base() + { + this.record = record; + this.field = field; + } + + public override bool CanRead { get { return true; } } + public override bool CanWrite { get { return false; } } + public override bool CanSeek { get { return false; } } + + public override long Length + { + get + { + return this.record.GetDataSize(this.field); + } + } + + public override long Position + { + get + { + return this.position; + } + + set + { + throw new NotSupportedException(); + } + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Flush() + { + throw new NotSupportedException(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (count > 0) + { + byte[] readBuffer = (offset == 0 ? buffer : new byte[count]); + uint ucount = (uint) count; + uint ret = RemotableNativeMethods.MsiRecordReadStream((int) this.record.Handle, (uint) this.field, buffer, ref ucount); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + count = (int) ucount; + if (offset > 0) + { + Array.Copy(readBuffer, 0, buffer, offset, count); + } + this.position += count; + } + return count; + } + + public override void Write(byte[] array, int offset, int count) + { + throw new NotSupportedException(); + } + + public override string ToString() + { + return "[Binary data]"; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RemotableNativeMethods.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RemotableNativeMethods.cs new file mode 100644 index 00000000..960fd15f --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/RemotableNativeMethods.cs @@ -0,0 +1,1171 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + /// + /// Assigns ID numbers to the MSI APIs that are remotable. + /// + ///

+ /// This enumeration MUST stay in sync with the + /// unmanaged equivalent in RemoteMsiSession.h! + ///

+ internal enum RemoteMsiFunctionId + { + EndSession = 0, + MsiCloseHandle, + MsiCreateRecord, + MsiDatabaseGetPrimaryKeys, + MsiDatabaseIsTablePersistent, + MsiDatabaseOpenView, + MsiDoAction, + MsiEnumComponentCosts, + MsiEvaluateCondition, + MsiFormatRecord, + MsiGetActiveDatabase, + MsiGetComponentState, + MsiGetFeatureCost, + MsiGetFeatureState, + MsiGetFeatureValidStates, + MsiGetLanguage, + MsiGetLastErrorRecord, + MsiGetMode, + MsiGetProperty, + MsiGetSourcePath, + MsiGetSummaryInformation, + MsiGetTargetPath, + MsiProcessMessage, + MsiRecordClearData, + MsiRecordDataSize, + MsiRecordGetFieldCount, + MsiRecordGetInteger, + MsiRecordGetString, + MsiRecordIsNull, + MsiRecordReadStream, + MsiRecordSetInteger, + MsiRecordSetStream, + MsiRecordSetString, + MsiSequence, + MsiSetComponentState, + MsiSetFeatureAttributes, + MsiSetFeatureState, + MsiSetInstallLevel, + MsiSetMode, + MsiSetProperty, + MsiSetTargetPath, + MsiSummaryInfoGetProperty, + MsiVerifyDiskSpace, + MsiViewExecute, + MsiViewFetch, + MsiViewGetError, + MsiViewGetColumnInfo, + MsiViewModify, + } + + /// + /// Defines the signature of the native function + /// in SfxCA.dll that implements the remoting call. + /// + internal delegate void MsiRemoteInvoke( + RemoteMsiFunctionId id, + [MarshalAs(UnmanagedType.SysInt)] + IntPtr request, + [MarshalAs(UnmanagedType.SysInt)] + out IntPtr response); + + /// + /// Redirects native API calls to either the normal NativeMethods class + /// or to out-of-proc calls via the remoting channel. + /// + internal static class RemotableNativeMethods + { + private const int MAX_REQUEST_FIELDS = 4; + private static int requestFieldDataOffset; + private static int requestFieldSize; + + [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] + private static IntPtr requestBuf; + + private static MsiRemoteInvoke remotingDelegate; + + /// + /// Checks if the current process is using remoting to access the + /// MSI session and database APIs. + /// + internal static bool RemotingEnabled + { + get + { + return RemotableNativeMethods.remotingDelegate != null; + } + } + + /// + /// Sets a delegate that is used to make remote API calls. + /// + ///

+ /// The implementation of this delegate is provided by the + /// custom action host DLL. + ///

+ [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal static MsiRemoteInvoke RemotingDelegate + { + set + { + RemotableNativeMethods.remotingDelegate = value; + + if (value != null && requestBuf == IntPtr.Zero) + { + requestFieldDataOffset = Marshal.SizeOf(typeof(IntPtr)); + requestFieldSize = 2 * Marshal.SizeOf(typeof(IntPtr)); + RemotableNativeMethods.requestBuf = Marshal.AllocHGlobal( + requestFieldSize * MAX_REQUEST_FIELDS); + } + } + } + + internal static bool IsRemoteHandle(int handle) + { + return (handle & Int32.MinValue) != 0; + } + + internal static int MakeRemoteHandle(int handle) + { + if (handle == 0) + { + return handle; + } + + if (RemotableNativeMethods.IsRemoteHandle(handle)) + { + throw new InvalidOperationException("Handle already has the remote bit set."); + } + + return handle ^ Int32.MinValue; + } + + internal static int GetRemoteHandle(int handle) + { + if (handle == 0) + { + return handle; + } + + if (!RemotableNativeMethods.IsRemoteHandle(handle)) + { + throw new InvalidOperationException("Handle does not have the remote bit set."); + } + + return handle ^ Int32.MinValue; + } + + private static void ClearData(IntPtr buf) + { + for (int i = 0; i < MAX_REQUEST_FIELDS; i++) + { + Marshal.WriteInt32(buf, (i * requestFieldSize), (int) VarEnum.VT_NULL); + Marshal.WriteIntPtr(buf, (i * requestFieldSize) + requestFieldDataOffset, IntPtr.Zero); + } + } + + private static void WriteInt(IntPtr buf, int field, int value) + { + Marshal.WriteInt32(buf, (field * requestFieldSize), (int) VarEnum.VT_I4); + Marshal.WriteInt32(buf, (field * requestFieldSize) + requestFieldDataOffset, value); + } + + private static void WriteString(IntPtr buf, int field, string value) + { + if (value == null) + { + Marshal.WriteInt32(buf, (field * requestFieldSize), (int) VarEnum.VT_NULL); + Marshal.WriteIntPtr(buf, (field * requestFieldSize) + requestFieldDataOffset, IntPtr.Zero); + } + else + { + IntPtr stringPtr = Marshal.StringToHGlobalUni(value); + Marshal.WriteInt32(buf, (field * requestFieldSize), (int) VarEnum.VT_LPWSTR); + Marshal.WriteIntPtr(buf, (field * requestFieldSize) + requestFieldDataOffset, stringPtr); + } + } + + private static int ReadInt(IntPtr buf, int field) + { + VarEnum vt = (VarEnum) Marshal.ReadInt32(buf, (field * requestFieldSize)); + if (vt == VarEnum.VT_EMPTY) + { + return 0; + } + else if (vt != VarEnum.VT_I4 && vt != VarEnum.VT_UI4) + { + throw new InstallerException("Invalid data received from remote MSI function invocation."); + } + return Marshal.ReadInt32(buf, (field * requestFieldSize) + requestFieldDataOffset); + } + + private static void ReadString(IntPtr buf, int field, StringBuilder szBuf, ref uint cchBuf) + { + VarEnum vt = (VarEnum) Marshal.ReadInt32(buf, (field * requestFieldSize)); + if (vt == VarEnum.VT_NULL) + { + szBuf.Remove(0, szBuf.Length); + return; + } + else if (vt != VarEnum.VT_LPWSTR) + { + throw new InstallerException("Invalid data received from remote MSI function invocation."); + } + + szBuf.Remove(0, szBuf.Length); + IntPtr strPtr = Marshal.ReadIntPtr(buf, (field * requestFieldSize) + requestFieldDataOffset); + string str = Marshal.PtrToStringUni(strPtr); + if (str != null) + { + szBuf.Append(str); + } + cchBuf = (uint) szBuf.Length; + } + + private static void FreeString(IntPtr buf, int field) + { + IntPtr stringPtr = Marshal.ReadIntPtr(buf, (field * requestFieldSize) + requestFieldDataOffset); + if (stringPtr != IntPtr.Zero) + { + Marshal.FreeHGlobal(stringPtr); + } + } + + private static void ReadStream(IntPtr buf, int field, byte[] sBuf, int count) + { + VarEnum vt = (VarEnum) Marshal.ReadInt32(buf, (field * requestFieldSize)); + if (vt != VarEnum.VT_STREAM) + { + throw new InstallerException("Invalid data received from remote MSI function invocation."); + } + + IntPtr sPtr = Marshal.ReadIntPtr(buf, (field * requestFieldSize) + requestFieldDataOffset); + Marshal.Copy(sPtr, sBuf, 0, count); + } + + private static uint MsiFunc_III(RemoteMsiFunctionId id, int in1, int in2, int in3) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteInt(requestBuf, 1, in2); + WriteInt(requestBuf, 2, in3); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + return unchecked ((uint) ReadInt(resp, 0)); + } + } + + private static uint MsiFunc_IIS(RemoteMsiFunctionId id, int in1, int in2, string in3) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteInt(requestBuf, 1, in2); + WriteString(requestBuf, 2, in3); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 2); + return unchecked ((uint) ReadInt(resp, 0)); + } + } + + private static uint MsiFunc_ISI(RemoteMsiFunctionId id, int in1, string in2, int in3) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + WriteInt(requestBuf, 2, in3); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 2); + return unchecked ((uint) ReadInt(resp, 0)); + } + } + + private static uint MsiFunc_ISS(RemoteMsiFunctionId id, int in1, string in2, string in3) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + WriteString(requestBuf, 2, in3); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 1); + FreeString(requestBuf, 2); + return unchecked ((uint) ReadInt(resp, 0)); + } + } + + private static uint MsiFunc_II_I(RemoteMsiFunctionId id, int in1, int in2, out int out1) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteInt(requestBuf, 1, in2); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + out1 = ReadInt(resp, 1); + return ret; + } + } + + private static uint MsiFunc_ISII_I(RemoteMsiFunctionId id, int in1, string in2, int in3, int in4, out int out1) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + WriteInt(requestBuf, 2, in3); + WriteInt(requestBuf, 3, in4); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 1); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + out1 = ReadInt(resp, 1); + return ret; + } + } + + private static uint MsiFunc_IS_II(RemoteMsiFunctionId id, int in1, string in2, out int out1, out int out2) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 1); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + out1 = ReadInt(resp, 1); + out2 = ReadInt(resp, 2); + return ret; + } + } + + private static uint MsiFunc_II_S(RemoteMsiFunctionId id, int in1, int in2, StringBuilder out1, ref uint cchOut1) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteInt(requestBuf, 1, in2); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + if (ret == 0) ReadString(resp, 1, out1, ref cchOut1); + return ret; + } + } + + private static uint MsiFunc_IS_S(RemoteMsiFunctionId id, int in1, string in2, StringBuilder out1, ref uint cchOut1) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 1); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + if (ret == 0) ReadString(resp, 1, out1, ref cchOut1); + return ret; + } + } + + private static uint MsiFunc_ISII_SII(RemoteMsiFunctionId id, int in1, string in2, int in3, int in4, StringBuilder out1, ref uint cchOut1, out int out2, out int out3) + { + lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, in1); + WriteString(requestBuf, 1, in2); + WriteInt(requestBuf, 2, in3); + WriteInt(requestBuf, 3, in4); + IntPtr resp; + remotingDelegate(id, requestBuf, out resp); + FreeString(requestBuf, 1); + uint ret = unchecked ((uint) ReadInt(resp, 0)); + if (ret == 0) ReadString(resp, 1, out1, ref cchOut1); + out2 = ReadInt(resp, 2); + out3 = ReadInt(resp, 3); + return ret; + } + } + + internal static int MsiProcessMessage(int hInstall, uint eMessageType, int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + { + return NativeMethods.MsiProcessMessage(hInstall, eMessageType, hRecord); + } + else lock (remotingDelegate) + { + // I don't understand why, but this particular function doesn't work + // when using the static requestBuf -- some data doesn't make it through. + // But it works when a fresh buffer is allocated here every call. + IntPtr buf = Marshal.AllocHGlobal( + requestFieldSize * MAX_REQUEST_FIELDS); + ClearData(buf); + WriteInt(buf, 0, RemotableNativeMethods.GetRemoteHandle(hInstall)); + WriteInt(buf, 1, unchecked ((int) eMessageType)); + WriteInt(buf, 2, RemotableNativeMethods.GetRemoteHandle(hRecord)); + IntPtr resp; + remotingDelegate(RemoteMsiFunctionId.MsiProcessMessage, buf, out resp); + Marshal.FreeHGlobal(buf); + return ReadInt(resp, 0); + } + } + + internal static uint MsiCloseHandle(int hAny) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hAny)) + return NativeMethods.MsiCloseHandle(hAny); + else + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiCloseHandle, RemotableNativeMethods.GetRemoteHandle(hAny), 0, 0); + } + + internal static uint MsiGetProperty(int hInstall, string szName, StringBuilder szValueBuf, ref uint cchValueBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetProperty(hInstall, szName, szValueBuf, ref cchValueBuf); + else + { + return RemotableNativeMethods.MsiFunc_IS_S( + RemoteMsiFunctionId.MsiGetProperty, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szName, + szValueBuf, + ref cchValueBuf); + } + } + + internal static uint MsiSetProperty(int hInstall, string szName, string szValue) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetProperty(hInstall, szName, szValue); + else + { + return RemotableNativeMethods.MsiFunc_ISS( + RemoteMsiFunctionId.MsiSetProperty, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szName, + szValue); + } + } + + internal static int MsiCreateRecord(uint cParams, int hAny) + { + // When remoting is enabled, we might need to create either a local or + // remote record, depending on the handle it is to have an affinity with. + // If no affinity handle is specified, create a remote record (the 99% case). + if (!RemotingEnabled || + (hAny != 0 && !RemotableNativeMethods.IsRemoteHandle(hAny))) + { + return NativeMethods.MsiCreateRecord(cParams); + } + else + { + int hRecord = unchecked((int)RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiCreateRecord, (int) cParams, 0, 0)); + return RemotableNativeMethods.MakeRemoteHandle(hRecord); + } + } + + internal static uint MsiRecordGetFieldCount(int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordGetFieldCount(hRecord); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordGetFieldCount, + RemotableNativeMethods.GetRemoteHandle(hRecord), + 0, + 0); + } + } + + internal static int MsiRecordGetInteger(int hRecord, uint iField) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordGetInteger(hRecord, iField); + else + { + return unchecked ((int) RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordGetInteger, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + 0)); + } + } + + internal static uint MsiRecordGetString(int hRecord, uint iField, StringBuilder szValueBuf, ref uint cchValueBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + { + return NativeMethods.MsiRecordGetString(hRecord, iField, szValueBuf, ref cchValueBuf); + } + else + { + return RemotableNativeMethods.MsiFunc_II_S( + RemoteMsiFunctionId.MsiRecordGetString, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + szValueBuf, + ref cchValueBuf); + } + } + + internal static uint MsiRecordSetInteger(int hRecord, uint iField, int iValue) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordSetInteger(hRecord, iField, iValue); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordSetInteger, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + iValue); + } + } + + internal static uint MsiRecordSetString(int hRecord, uint iField, string szValue) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordSetString(hRecord, iField, szValue); + else + { + return RemotableNativeMethods.MsiFunc_IIS( + RemoteMsiFunctionId.MsiRecordSetString, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + szValue); + } + } + + internal static int MsiGetActiveDatabase(int hInstall) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetActiveDatabase(hInstall); + else + { + int hDatabase = (int)RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiGetActiveDatabase, + RemotableNativeMethods.GetRemoteHandle(hInstall), + 0, + 0); + return RemotableNativeMethods.MakeRemoteHandle(hDatabase); + } + } + + internal static uint MsiDatabaseOpenView(int hDatabase, string szQuery, out int hView) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hDatabase)) + return NativeMethods.MsiDatabaseOpenView(hDatabase, szQuery, out hView); + else + { + uint err = RemotableNativeMethods.MsiFunc_ISII_I( + RemoteMsiFunctionId.MsiDatabaseOpenView, + RemotableNativeMethods.GetRemoteHandle(hDatabase), + szQuery, + 0, + 0, + out hView); + hView = RemotableNativeMethods.MakeRemoteHandle(hView); + return err; + } + } + + internal static uint MsiViewExecute(int hView, int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView)) + return NativeMethods.MsiViewExecute(hView, hRecord); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiViewExecute, + RemotableNativeMethods.GetRemoteHandle(hView), + RemotableNativeMethods.GetRemoteHandle(hRecord), + 0); + } + } + + internal static uint MsiViewFetch(int hView, out int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView)) + return NativeMethods.MsiViewFetch(hView, out hRecord); + else + { + uint err = RemotableNativeMethods.MsiFunc_II_I( + RemoteMsiFunctionId.MsiViewFetch, + RemotableNativeMethods.GetRemoteHandle(hView), + 0, + out hRecord); + hRecord = RemotableNativeMethods.MakeRemoteHandle(hRecord); + return err; + } + } + + internal static uint MsiViewModify(int hView, int iModifyMode, int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView)) + return NativeMethods.MsiViewModify(hView, iModifyMode, hRecord); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiViewModify, + RemotableNativeMethods.GetRemoteHandle(hView), + iModifyMode, + RemotableNativeMethods.GetRemoteHandle(hRecord)); + } + } + + internal static int MsiViewGetError(int hView, StringBuilder szColumnNameBuffer, ref uint cchBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView)) + return NativeMethods.MsiViewGetError(hView, szColumnNameBuffer, ref cchBuf); + else + { + return unchecked ((int) RemotableNativeMethods.MsiFunc_II_S( + RemoteMsiFunctionId.MsiViewGetError, + RemotableNativeMethods.GetRemoteHandle(hView), + 0, + szColumnNameBuffer, + ref cchBuf)); + } + } + + internal static uint MsiViewGetColumnInfo(int hView, uint eColumnInfo, out int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView)) + return NativeMethods.MsiViewGetColumnInfo(hView, eColumnInfo, out hRecord); + else + { + uint err = RemotableNativeMethods.MsiFunc_II_I( + RemoteMsiFunctionId.MsiViewGetColumnInfo, + RemotableNativeMethods.GetRemoteHandle(hView), + (int) eColumnInfo, + out hRecord); + hRecord = RemotableNativeMethods.MakeRemoteHandle(hRecord); + return err; + } + } + + internal static uint MsiFormatRecord(int hInstall, int hRecord, StringBuilder szResultBuf, ref uint cchResultBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiFormatRecord(hInstall, hRecord, szResultBuf, ref cchResultBuf); + else + { + return RemotableNativeMethods.MsiFunc_II_S( + RemoteMsiFunctionId.MsiFormatRecord, + RemotableNativeMethods.GetRemoteHandle(hInstall), + RemotableNativeMethods.GetRemoteHandle(hRecord), + szResultBuf, + ref cchResultBuf); + } + } + + internal static uint MsiRecordClearData(int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordClearData(hRecord); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordClearData, + RemotableNativeMethods.GetRemoteHandle(hRecord), + 0, + 0); + } + } + + internal static bool MsiRecordIsNull(int hRecord, uint iField) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordIsNull(hRecord, iField); + else + { + return 0 != RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordIsNull, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + 0); + } + } + + internal static uint MsiDatabaseGetPrimaryKeys(int hDatabase, string szTableName, out int hRecord) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hDatabase)) + return NativeMethods.MsiDatabaseGetPrimaryKeys(hDatabase, szTableName, out hRecord); + else + { + uint err = RemotableNativeMethods.MsiFunc_ISII_I( + RemoteMsiFunctionId.MsiDatabaseGetPrimaryKeys, + RemotableNativeMethods.GetRemoteHandle(hDatabase), + szTableName, + 0, + 0, + out hRecord); + hRecord = RemotableNativeMethods.MakeRemoteHandle(hRecord); + return err; + } + } + + internal static uint MsiDatabaseIsTablePersistent(int hDatabase, string szTableName) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hDatabase)) + return NativeMethods.MsiDatabaseIsTablePersistent(hDatabase, szTableName); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiDatabaseIsTablePersistent, + RemotableNativeMethods.GetRemoteHandle(hDatabase), + szTableName, + 0); + } + } + + internal static uint MsiDoAction(int hInstall, string szAction) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiDoAction(hInstall, szAction); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiDoAction, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szAction, + 0); + } + } + + internal static uint MsiEnumComponentCosts(int hInstall, string szComponent, uint dwIndex, int iState, StringBuilder lpDriveBuf, ref uint cchDriveBuf, out int iCost, out int iTempCost) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiEnumComponentCosts(hInstall, szComponent, dwIndex, iState, lpDriveBuf, ref cchDriveBuf, out iCost, out iTempCost); + else + { + return RemotableNativeMethods.MsiFunc_ISII_SII( + RemoteMsiFunctionId.MsiEvaluateCondition, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szComponent, (int) dwIndex, iState, lpDriveBuf, ref cchDriveBuf, out iCost, out iTempCost); + } + } + + internal static uint MsiEvaluateCondition(int hInstall, string szCondition) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiEvaluateCondition(hInstall, szCondition); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiEvaluateCondition, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szCondition, + 0); + } + } + + internal static uint MsiGetComponentState(int hInstall, string szComponent, out int iInstalled, out int iAction) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetComponentState(hInstall, szComponent, out iInstalled, out iAction); + else + { + return RemotableNativeMethods.MsiFunc_IS_II( + RemoteMsiFunctionId.MsiGetComponentState, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szComponent, + out iInstalled, + out iAction); + } + } + + internal static uint MsiGetFeatureCost(int hInstall, string szFeature, int iCostTree, int iState, out int iCost) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetFeatureCost(hInstall, szFeature, iCostTree, iState, out iCost); + else + { + return RemotableNativeMethods.MsiFunc_ISII_I( + RemoteMsiFunctionId.MsiGetFeatureCost, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFeature, + iCostTree, + iState, + out iCost); + } + } + + internal static uint MsiGetFeatureState(int hInstall, string szFeature, out int iInstalled, out int iAction) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetFeatureState(hInstall, szFeature, out iInstalled, out iAction); + else + { + return RemotableNativeMethods.MsiFunc_IS_II( + RemoteMsiFunctionId.MsiGetFeatureState, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFeature, + out iInstalled, + out iAction); + } + } + + internal static uint MsiGetFeatureValidStates(int hInstall, string szFeature, out uint dwInstalledState) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetFeatureValidStates(hInstall, szFeature, out dwInstalledState); + else + { + int iTemp; + uint ret = RemotableNativeMethods.MsiFunc_ISII_I( + RemoteMsiFunctionId.MsiGetFeatureValidStates, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFeature, + 0, + 0, + out iTemp); + dwInstalledState = (uint) iTemp; + return ret; + } + } + + internal static int MsiGetLanguage(int hInstall) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetLanguage(hInstall); + else + { + return unchecked((int)RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiGetLanguage, + RemotableNativeMethods.GetRemoteHandle(hInstall), + 0, + 0)); + } + } + + internal static int MsiGetLastErrorRecord(int hAny) + { + // When remoting is enabled, we might need to create either a local or + // remote record, depending on the handle it is to have an affinity with. + // If no affinity handle is specified, create a remote record (the 99% case). + if (!RemotingEnabled || + (hAny != 0 && !RemotableNativeMethods.IsRemoteHandle(hAny))) + { + return NativeMethods.MsiGetLastErrorRecord(); + } + else + { + int hRecord = unchecked((int) RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiGetLastErrorRecord, 0, 0, 0)); + return RemotableNativeMethods.MakeRemoteHandle(hRecord); + } + } + + internal static bool MsiGetMode(int hInstall, uint iRunMode) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetMode(hInstall, iRunMode); + else + { + return 0 != RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiGetMode, + RemotableNativeMethods.GetRemoteHandle(hInstall), + (int) iRunMode, + 0); + } + } + + internal static uint MsiGetSourcePath(int hInstall, string szFolder, StringBuilder szPathBuf, ref uint cchPathBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetSourcePath(hInstall, szFolder, szPathBuf, ref cchPathBuf); + else + { + return RemotableNativeMethods.MsiFunc_IS_S( + RemoteMsiFunctionId.MsiGetSourcePath, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFolder, + szPathBuf, + ref cchPathBuf); + } + } + + internal static uint MsiGetSummaryInformation(int hDatabase, string szDatabasePath, uint uiUpdateCount, out int hSummaryInfo) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hDatabase)) + return NativeMethods.MsiGetSummaryInformation(hDatabase, szDatabasePath, uiUpdateCount, out hSummaryInfo); + else + { + uint err = RemotableNativeMethods.MsiFunc_ISII_I( + RemoteMsiFunctionId.MsiGetSummaryInformation, + RemotableNativeMethods.GetRemoteHandle(hDatabase), + szDatabasePath, + (int)uiUpdateCount, + 0, + out hSummaryInfo); + hSummaryInfo = RemotableNativeMethods.MakeRemoteHandle(hSummaryInfo); + return err; + } + } + + internal static uint MsiGetTargetPath(int hInstall, string szFolder, StringBuilder szPathBuf, ref uint cchPathBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiGetTargetPath(hInstall, szFolder, szPathBuf, ref cchPathBuf); + else + { + return RemotableNativeMethods.MsiFunc_IS_S( + RemoteMsiFunctionId.MsiGetTargetPath, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFolder, + szPathBuf, + ref cchPathBuf); + } + } + + internal static uint MsiRecordDataSize(int hRecord, uint iField) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordDataSize(hRecord, iField); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiRecordDataSize, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, 0); + } + } + + internal static uint MsiRecordReadStream(int hRecord, uint iField, byte[] szDataBuf, ref uint cbDataBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + { + return NativeMethods.MsiRecordReadStream(hRecord, iField, szDataBuf, ref cbDataBuf); + } + else lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + unchecked + { + WriteInt(requestBuf, 0, RemotableNativeMethods.GetRemoteHandle(hRecord)); + WriteInt(requestBuf, 1, (int) iField); + WriteInt(requestBuf, 2, (int) cbDataBuf); + IntPtr resp; + remotingDelegate(RemoteMsiFunctionId.MsiRecordReadStream, requestBuf, out resp); + uint ret = (uint) ReadInt(resp, 0); + if (ret == 0) + { + cbDataBuf = (uint) ReadInt(resp, 2); + if (cbDataBuf > 0) + { + RemotableNativeMethods.ReadStream(resp, 1, szDataBuf, (int) cbDataBuf); + } + } + return ret; + } + } + } + + internal static uint MsiRecordSetStream(int hRecord, uint iField, string szFilePath) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord)) + return NativeMethods.MsiRecordSetStream(hRecord, iField, szFilePath); + else + { + return RemotableNativeMethods.MsiFunc_IIS( + RemoteMsiFunctionId.MsiRecordSetStream, + RemotableNativeMethods.GetRemoteHandle(hRecord), + (int) iField, + szFilePath); + } + } + + internal static uint MsiSequence(int hInstall, string szTable, int iSequenceMode) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSequence(hInstall, szTable, iSequenceMode); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiSequence, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szTable, + iSequenceMode); + } + } + + internal static uint MsiSetComponentState(int hInstall, string szComponent, int iState) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetComponentState(hInstall, szComponent, iState); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiSetComponentState, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szComponent, + iState); + } + } + + internal static uint MsiSetFeatureAttributes(int hInstall, string szFeature, uint dwAttributes) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetFeatureAttributes(hInstall, szFeature, dwAttributes); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiSetFeatureAttributes, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFeature, + (int) dwAttributes); + } + } + + internal static uint MsiSetFeatureState(int hInstall, string szFeature, int iState) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetFeatureState(hInstall, szFeature, iState); + else + { + return RemotableNativeMethods.MsiFunc_ISI( + RemoteMsiFunctionId.MsiSetFeatureState, + RemotableNativeMethods.GetRemoteHandle(hInstall), szFeature, iState); + } + } + + internal static uint MsiSetInstallLevel(int hInstall, int iInstallLevel) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetInstallLevel(hInstall, iInstallLevel); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiSetInstallLevel, + RemotableNativeMethods.GetRemoteHandle(hInstall), + iInstallLevel, + 0); + } + } + + internal static uint MsiSetMode(int hInstall, uint iRunMode, bool fState) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetMode(hInstall, iRunMode, fState); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiSetMode, + RemotableNativeMethods.GetRemoteHandle(hInstall), + (int) iRunMode, + fState ? 1 : 0); + } + } + + internal static uint MsiSetTargetPath(int hInstall, string szFolder, string szFolderPath) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiSetTargetPath(hInstall, szFolder, szFolderPath); + else + { + return RemotableNativeMethods.MsiFunc_ISS( + RemoteMsiFunctionId.MsiSetTargetPath, + RemotableNativeMethods.GetRemoteHandle(hInstall), + szFolder, + szFolderPath); + } + } + + internal static uint MsiSummaryInfoGetProperty(int hSummaryInfo, uint uiProperty, out uint uiDataType, out int iValue, ref long ftValue, StringBuilder szValueBuf, ref uint cchValueBuf) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hSummaryInfo)) + { + return NativeMethods.MsiSummaryInfoGetProperty(hSummaryInfo, uiProperty, out uiDataType, out iValue, ref ftValue, szValueBuf, ref cchValueBuf); + } + else lock (RemotableNativeMethods.remotingDelegate) + { + ClearData(requestBuf); + WriteInt(requestBuf, 0, RemotableNativeMethods.GetRemoteHandle(hSummaryInfo)); + WriteInt(requestBuf, 1, (int) uiProperty); + IntPtr resp; + remotingDelegate(RemoteMsiFunctionId.MsiSummaryInfoGetProperty, requestBuf, out resp); + unchecked + { + uint ret = (uint) ReadInt(resp, 0); + if (ret == 0) + { + uiDataType = (uint) ReadInt(resp, 1); + switch ((VarEnum) uiDataType) + { + case VarEnum.VT_I2: + case VarEnum.VT_I4: + iValue = ReadInt(resp, 2); + break; + + case VarEnum.VT_FILETIME: + uint ftHigh = (uint) ReadInt(resp, 2); + uint ftLow = (uint) ReadInt(resp, 3); + ftValue = ((long) ftHigh) << 32 | ((long) ftLow); + iValue = 0; + break; + + case VarEnum.VT_LPSTR: + ReadString(resp, 2, szValueBuf, ref cchValueBuf); + iValue = 0; + break; + + default: + iValue = 0; + break; + } + } + else + { + uiDataType = 0; + iValue = 0; + } + return ret; + } + } + } + + internal static uint MsiVerifyDiskSpace(int hInstall) + { + if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall)) + return NativeMethods.MsiVerifyDiskSpace(hInstall); + else + { + return RemotableNativeMethods.MsiFunc_III( + RemoteMsiFunctionId.MsiVerifyDiskSpace, + RemotableNativeMethods.GetRemoteHandle(hInstall), + 0, + 0); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Session.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Session.cs new file mode 100644 index 00000000..875e49a6 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Session.cs @@ -0,0 +1,946 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; + + /// + /// The Session object controls the installation process. It opens the + /// install database, which contains the installation tables and data. + /// + ///

+ /// This object is associated with a standard set of action functions, + /// each performing particular operations on data from one or more tables. Additional + /// custom actions may be added for particular product installations. The basic engine + /// function is a sequencer that fetches sequential records from a designated sequence + /// table, evaluates any specified condition expression, and executes the designated + /// action. Actions not recognized by the engine are deferred to the UI handler object + /// for processing, usually dialog box sequences. + ///

+ /// Note that only one Session object can be opened by a single process. + ///

+ public sealed class Session : InstallerHandle, IFormatProvider + { + private Database database; + private CustomActionData customActionData; + private bool sessionAccessValidated = false; + + internal Session(IntPtr handle, bool ownsHandle) + : base(handle, ownsHandle) + { + } + + /// + /// Gets the Database for the install session. + /// + /// the Session handle is invalid + /// the Database cannot be accessed + ///

+ /// Normally there is no need to close this Database object. The same object can be + /// used throughout the lifetime of the Session, and it will be closed when the Session + /// is closed. + ///

+ /// Win32 MSI API: + /// MsiGetActiveDatabase + ///

+ [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] + public Database Database + { + get + { + if (this.database == null || this.database.IsClosed) + { + lock (this.Sync) + { + if (this.database == null || this.database.IsClosed) + { + this.ValidateSessionAccess(); + + int hDb = RemotableNativeMethods.MsiGetActiveDatabase((int) this.Handle); + if (hDb == 0) + { + throw new InstallerException(); + } + this.database = new Database((IntPtr) hDb, true, "", DatabaseOpenMode.ReadOnly); + } + } + } + return this.database; + } + } + + /// + /// Gets the numeric language ID used by the current install session. + /// + ///

+ /// Win32 MSI API: + /// MsiGetLanguage + ///

+ public int Language + { + get + { + return (int) RemotableNativeMethods.MsiGetLanguage((int) this.Handle); + } + } + + /// + /// Gets or sets the string value of a named installer property, as maintained by the + /// Session object in the in-memory Property table, or, if it is prefixed with a percent + /// sign (%), the value of a system environment variable for the current process. + /// + /// the Session handle is invalid + ///

+ /// Win32 MSI APIs: + /// MsiGetProperty, + /// MsiSetProperty + ///

+ public string this[string property] + { + get + { + if (String.IsNullOrEmpty(property)) + { + throw new ArgumentNullException("property"); + } + + if (!this.sessionAccessValidated && + !Session.NonImmediatePropertyNames.Contains(property)) + { + this.ValidateSessionAccess(); + } + + StringBuilder buf = new StringBuilder(); + uint bufSize = 0; + uint ret = RemotableNativeMethods.MsiGetProperty((int) this.Handle, property, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = RemotableNativeMethods.MsiGetProperty((int) this.Handle, property, buf, ref bufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return buf.ToString(); + } + + set + { + if (String.IsNullOrEmpty(property)) + { + throw new ArgumentNullException("property"); + } + + this.ValidateSessionAccess(); + + if (value == null) + { + value = String.Empty; + } + + uint ret = RemotableNativeMethods.MsiSetProperty((int) this.Handle, property, value); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Creates a new Session object from an integer session handle. + /// + /// Integer session handle + /// true to close the handle when this object is disposed or finalized + ///

+ /// This method is only provided for interop purposes. A Session object + /// should normally be obtained by calling + /// or . + ///

+ public static Session FromHandle(IntPtr handle, bool ownsHandle) + { + return new Session(handle, ownsHandle); + } + + /// + /// Performs any enabled logging operations and defers execution to the UI handler + /// object associated with the engine. + /// + /// Type of message to be processed + /// Contains message-specific fields + /// A message-dependent return value + /// the Session or Record handle is invalid + /// an invalid message kind is specified + /// the user exited the installation + /// the message-handler failed for an unknown reason + ///

+ /// Logging may be selectively enabled for the various message types. + /// See the method. + ///

+ /// If record field 0 contains a formatting string, it is used to format the data in + /// the other fields. Else if the message is an error, warning, or user message, an attempt + /// is made to find a message template in the Error table for the current database using the + /// error number found in field 1 of the record for message types and return values. + ///

+ /// The parameter may also include message-box flags from + /// the following enumerations: System.Windows.Forms.MessageBoxButtons, + /// System.Windows.Forms.MessageBoxDefaultButton, System.Windows.Forms.MessageBoxIcon. These + /// flags can be combined with the InstallMessage with a bitwise OR. + ///

+ /// Note, this method never returns Cancel or Error values. Instead, appropriate + /// exceptions are thrown in those cases. + ///

+ /// Win32 MSI API: + /// MsiProcessMessage + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public MessageResult Message(InstallMessage messageType, Record record) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + int ret = RemotableNativeMethods.MsiProcessMessage((int) this.Handle, (uint) messageType, (int) record.Handle); + if (ret < 0) + { + throw new InstallerException(); + } + else if (ret == (int) MessageResult.Cancel) + { + throw new InstallCanceledException(); + } + return (MessageResult) ret; + } + + /// + /// Writes a message to the log, if logging is enabled. + /// + /// The line to be written to the log + ///

+ /// Win32 MSI API: + /// MsiProcessMessage + ///

+ public void Log(string msg) + { + if (msg == null) + { + throw new ArgumentNullException("msg"); + } + + using (Record rec = new Record(0)) + { + rec.FormatString = msg; + this.Message(InstallMessage.Info, rec); + } + } + + /// + /// Writes a formatted message to the log, if logging is enabled. + /// + /// The line to be written to the log, containing 0 or more format specifiers + /// An array containing 0 or more objects to be formatted + ///

+ /// Win32 MSI API: + /// MsiProcessMessage + ///

+ public void Log(string format, params object[] args) + { + this.Log(String.Format(CultureInfo.InvariantCulture, format, args)); + } + + /// + /// Evaluates a logical expression containing symbols and values. + /// + /// conditional expression + /// The result of the condition evaluation + /// the Session handle is invalid + /// the condition is null or empty + /// the conditional expression is invalid + ///

+ /// Win32 MSI API: + /// MsiEvaluateCondition + ///

+ public bool EvaluateCondition(string condition) + { + if (String.IsNullOrEmpty(condition)) + { + throw new ArgumentNullException("condition"); + } + + uint value = RemotableNativeMethods.MsiEvaluateCondition((int) this.Handle, condition); + if (value == 0) + { + return false; + } + else if (value == 1) + { + return true; + } + else + { + throw new InvalidOperationException(); + } + } + + /// + /// Evaluates a logical expression containing symbols and values, specifying a default + /// value to be returned in case the condition is empty. + /// + /// conditional expression + /// value to return if the condition is empty + /// The result of the condition evaluation + /// the Session handle is invalid + /// the conditional expression is invalid + ///

+ /// Win32 MSI API: + /// MsiEvaluateCondition + ///

+ public bool EvaluateCondition(string condition, bool defaultValue) + { + if (condition == null) + { + throw new ArgumentNullException("condition"); + } + else if (condition.Length == 0) + { + return defaultValue; + } + else + { + this.ValidateSessionAccess(); + return this.EvaluateCondition(condition); + } + } + + /// + /// Formats a string containing installer properties. + /// + /// A format string containing property tokens + /// A formatted string containing property data + /// the Record handle is invalid + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ [SuppressMessage("Microsoft.Naming", "CA1719:ParameterNamesShouldNotMatchMemberNames")] + public string Format(string format) + { + if (format == null) + { + throw new ArgumentNullException("format"); + } + + using (Record formatRec = new Record(0)) + { + formatRec.FormatString = format; + return formatRec.ToString(this); + } + } + + /// + /// Returns a formatted string from record data. + /// + /// Record object containing a template and data to be formatted. + /// The template string must be set in field 0 followed by any referenced data parameters. + /// A formatted string containing the record data + /// the Record handle is invalid + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ public string FormatRecord(Record record) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + return record.ToString(this); + } + + /// + /// Returns a formatted string from record data using a specified format. + /// + /// Record object containing a template and data to be formatted + /// Format string to be used instead of field 0 of the Record + /// A formatted string containing the record data + /// the Record handle is invalid + ///

+ /// Win32 MSI API: + /// MsiFormatRecord + ///

+ [Obsolete("This method is obsolete because it has undesirable side-effects. As an alternative, set the Record's " + + "FormatString property separately before calling the FormatRecord() override that takes only the Record parameter.")] + public string FormatRecord(Record record, string format) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + return record.ToString(format, this); + } + + /// + /// Retrieves product properties (not session properties) from the product database. + /// + /// Value of the property, or an empty string if the property is not set. + ///

+ /// Note this is not the correct method for getting ordinary session properties. For that, + /// see the indexer on the Session class. + ///

+ /// Win32 MSI API: + /// MsiGetProductProperty + ///

+ public string GetProductProperty(string property) + { + if (String.IsNullOrEmpty(property)) + { + throw new ArgumentNullException("property"); + } + + this.ValidateSessionAccess(); + + StringBuilder buf = new StringBuilder(); + uint bufSize = (uint) buf.Capacity; + uint ret = NativeMethods.MsiGetProductProperty((int) this.Handle, property, buf, ref bufSize); + + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiGetProductProperty((int) this.Handle, property, buf, ref bufSize); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return buf.ToString(); + } + + /// + /// Gets an accessor for components in the current session. + /// + public ComponentInfoCollection Components + { + get + { + this.ValidateSessionAccess(); + return new ComponentInfoCollection(this); + } + } + + /// + /// Gets an accessor for features in the current session. + /// + public FeatureInfoCollection Features + { + get + { + this.ValidateSessionAccess(); + return new FeatureInfoCollection(this); + } + } + + /// + /// Checks to see if sufficient disk space is present for the current installation. + /// + /// True if there is sufficient disk space; false otherwise. + ///

+ /// Win32 MSI API: + /// MsiVerifyDiskSpace + ///

+ public bool VerifyDiskSpace() + { + this.ValidateSessionAccess(); + + uint ret = RemotableNativeMethods.MsiVerifyDiskSpace((int)this.Handle); + if (ret == (uint) NativeMethods.Error.DISK_FULL) + { + return false; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + /// + /// Gets the total disk space per drive required for the installation. + /// + /// A list of InstallCost structures, specifying the cost for each drive + ///

+ /// Win32 MSI API: + /// MsiEnumComponentCosts + ///

+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + public IList GetTotalCost() + { + this.ValidateSessionAccess(); + + IList costs = new List(); + StringBuilder driveBuf = new StringBuilder(20); + for (uint i = 0; true; i++) + { + int cost, tempCost; + uint driveBufSize = (uint) driveBuf.Capacity; + uint ret = RemotableNativeMethods.MsiEnumComponentCosts( + (int) this.Handle, + null, + i, + (int) InstallState.Default, + driveBuf, + ref driveBufSize, + out cost, + out tempCost); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) break; + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + driveBuf.Capacity = (int) ++driveBufSize; + ret = RemotableNativeMethods.MsiEnumComponentCosts( + (int) this.Handle, + null, + i, + (int) InstallState.Default, + driveBuf, + ref driveBufSize, + out cost, + out tempCost); + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + costs.Add(new InstallCost(driveBuf.ToString(), cost * 512L, tempCost * 512L)); + } + return costs; + } + + /// + /// Gets the designated mode flag for the current install session. + /// + /// The type of mode to be checked. + /// The value of the designated mode flag. + /// the Session handle is invalid + /// an invalid mode flag was specified + ///

+ /// Note that only the following run modes are available to read from + /// a deferred custom action: + /// + /// + /// + /// + ///

+ /// Win32 MSI API: + /// MsiGetMode + ///

+ public bool GetMode(InstallRunMode mode) + { + return RemotableNativeMethods.MsiGetMode((int) this.Handle, (uint) mode); + } + + /// + /// Sets the designated mode flag for the current install session. + /// + /// The type of mode to be set. + /// The desired value of the mode. + /// the Session handle is invalid + /// an invalid mode flag was specified + /// the mode cannot not be set + ///

+ /// Win32 MSI API: + /// MsiSetMode + ///

+ public void SetMode(InstallRunMode mode, bool value) + { + this.ValidateSessionAccess(); + + uint ret = RemotableNativeMethods.MsiSetMode((int) this.Handle, (uint) mode, value); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.ACCESS_DENIED) + { + throw new InvalidOperationException(); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Gets the full path to the designated folder on the source media or server image. + /// + /// the folder was not found in the Directory table + /// the Session handle is invalid + ///

+ /// Win32 MSI API: + /// MsiGetSourcePath + ///

+ public string GetSourcePath(string directory) + { + if (String.IsNullOrEmpty(directory)) + { + throw new ArgumentNullException("directory"); + } + + this.ValidateSessionAccess(); + + StringBuilder buf = new StringBuilder(); + uint bufSize = 0; + uint ret = RemotableNativeMethods.MsiGetSourcePath((int) this.Handle, directory, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = ret = RemotableNativeMethods.MsiGetSourcePath((int) this.Handle, directory, buf, ref bufSize); + } + + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.DIRECTORY) + { + throw InstallerException.ExceptionFromReturnCode(ret, directory); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return buf.ToString(); + } + + /// + /// Gets the full path to the designated folder on the installation target drive. + /// + /// the folder was not found in the Directory table + /// the Session handle is invalid + ///

+ /// Win32 MSI API: + /// MsiGetTargetPath + ///

+ public string GetTargetPath(string directory) + { + if (String.IsNullOrEmpty(directory)) + { + throw new ArgumentNullException("directory"); + } + + this.ValidateSessionAccess(); + + StringBuilder buf = new StringBuilder(); + uint bufSize = 0; + uint ret = RemotableNativeMethods.MsiGetTargetPath((int) this.Handle, directory, buf, ref bufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = ret = RemotableNativeMethods.MsiGetTargetPath((int) this.Handle, directory, buf, ref bufSize); + } + + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.DIRECTORY) + { + throw InstallerException.ExceptionFromReturnCode(ret, directory); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return buf.ToString(); + } + + /// + /// Sets the full path to the designated folder on the installation target drive. + /// + /// the folder was not found in the Directory table + /// the Session handle is invalid + ///

+ /// Setting the target path of a directory changes the path specification for the directory + /// in the in-memory Directory table. Also, the path specifications of all other path objects + /// in the table that are either subordinate or equivalent to the changed path are updated + /// to reflect the change. The properties for each affected path are also updated. + ///

+ /// If an error occurs in this function, all updated paths and properties revert to + /// their previous values. Therefore, it is safe to treat errors returned by this function + /// as non-fatal. + ///

+ /// Do not attempt to configure the target path if the components using those paths + /// are already installed for the current user or for a different user. Check the + /// ProductState property before setting the target path to determine if the product + /// containing this component is installed. + ///

+ /// Win32 MSI API: + /// MsiSetTargetPath + ///

+ public void SetTargetPath(string directory, string value) + { + if (String.IsNullOrEmpty(directory)) + { + throw new ArgumentNullException("directory"); + } + + if (value == null) + { + throw new ArgumentNullException("value"); + } + + this.ValidateSessionAccess(); + + uint ret = RemotableNativeMethods.MsiSetTargetPath((int) this.Handle, directory, value); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.DIRECTORY) + { + throw InstallerException.ExceptionFromReturnCode(ret, directory); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + /// + /// Sets the install level for the current installation to a specified value and + /// recalculates the Select and Installed states for all features in the Feature + /// table. Also sets the Action state of each component in the Component table based + /// on the new level. + /// + /// New install level + /// the Session handle is invalid + ///

+ /// The SetInstallLevel method sets the following: + /// The installation level for the current installation to a specified value + /// The Select and Installed states for all features in the Feature table + /// The Action state of each component in the Component table, based on the new level + /// + /// If 0 or a negative number is passed in the ilnstallLevel parameter, + /// the current installation level does not change, but all features are still + /// updated based on the current installation level. + ///

+ /// Win32 MSI API: + /// MsiSetInstallLevel + ///

+ public void SetInstallLevel(int installLevel) + { + this.ValidateSessionAccess(); + + uint ret = RemotableNativeMethods.MsiSetInstallLevel((int) this.Handle, installLevel); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Executes a built-in action, custom action, or user-interface wizard action. + /// + /// Name of the action to execute. Case-sensitive. + /// the Session handle is invalid + /// the user exited the installation + ///

+ /// The DoAction method executes the action that corresponds to the name supplied. If the + /// name is not recognized by the installer as a built-in action or as a custom action in + /// the CustomAction table, the name is passed to the user-interface handler object, which + /// can invoke a function or a dialog box. If a null action name is supplied, the installer + /// uses the upper-case value of the ACTION property as the action to perform. If no property + /// value is defined, the default action is performed, defined as "INSTALL". + ///

+ /// Actions that update the system, such as the InstallFiles and WriteRegistryValues + /// actions, cannot be run by calling MsiDoAction. The exception to this rule is if DoAction + /// is called from a custom action that is scheduled in the InstallExecuteSequence table + /// between the InstallInitialize and InstallFinalize actions. Actions that do not update the + /// system, such as AppSearch or CostInitialize, can be called. + ///

+ /// Win32 MSI API: + /// MsiDoAction + ///

+ public void DoAction(string action) + { + this.DoAction(action, null); + } + + /// + /// Executes a built-in action, custom action, or user-interface wizard action. + /// + /// Name of the action to execute. Case-sensitive. + /// Optional data to be passed to a deferred custom action. + /// the Session handle is invalid + /// the user exited the installation + ///

+ /// The DoAction method executes the action that corresponds to the name supplied. If the + /// name is not recognized by the installer as a built-in action or as a custom action in + /// the CustomAction table, the name is passed to the user-interface handler object, which + /// can invoke a function or a dialog box. If a null action name is supplied, the installer + /// uses the upper-case value of the ACTION property as the action to perform. If no property + /// value is defined, the default action is performed, defined as "INSTALL". + ///

+ /// Actions that update the system, such as the InstallFiles and WriteRegistryValues + /// actions, cannot be run by calling MsiDoAction. The exception to this rule is if DoAction + /// is called from a custom action that is scheduled in the InstallExecuteSequence table + /// between the InstallInitialize and InstallFinalize actions. Actions that do not update the + /// system, such as AppSearch or CostInitialize, can be called. + ///

+ /// If the called action is a deferred, rollback, or commit custom action, then the supplied + /// will be available via the + /// property of that custom action's session. + ///

+ /// Win32 MSI API: + /// MsiDoAction + ///

+ public void DoAction(string action, CustomActionData actionData) + { + if (String.IsNullOrEmpty(action)) + { + throw new ArgumentNullException("action"); + } + + this.ValidateSessionAccess(); + + if (actionData != null) + { + this[action] = actionData.ToString(); + } + + uint ret = RemotableNativeMethods.MsiDoAction((int) this.Handle, action); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Executes an action sequence described in the specified table. + /// + /// Name of the table containing the action sequence. + /// the Session handle is invalid + /// the user exited the installation + ///

+ /// This method queries the specified table, ordering the actions by the numbers in the Sequence column. + /// For each row retrieved, an action is executed, provided that any supplied condition expression does + /// not evaluate to FALSE. + ///

+ /// An action sequence containing any actions that update the system, such as the InstallFiles and + /// WriteRegistryValues actions, cannot be run by calling DoActionSequence. The exception to this rule is if + /// DoActionSequence is called from a custom action that is scheduled in the InstallExecuteSequence table + /// between the InstallInitialize and InstallFinalize actions. Actions that do not update the system, such + /// as AppSearch or CostInitialize, can be called. + ///

+ /// Win32 MSI API: + /// MsiSequence + ///

+ public void DoActionSequence(string sequenceTable) + { + if (String.IsNullOrEmpty(sequenceTable)) + { + throw new ArgumentNullException("sequenceTable"); + } + + this.ValidateSessionAccess(); + + uint ret = RemotableNativeMethods.MsiSequence((int) this.Handle, sequenceTable, 0); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Gets custom action data for the session that was supplied by the caller. + /// + /// + public CustomActionData CustomActionData + { + get + { + if (this.customActionData == null) + { + this.customActionData = new CustomActionData(this[CustomActionData.PropertyName]); + } + + return this.customActionData; + } + } + + /// + /// Implements formatting for data. + /// + /// Type of format object to get. + /// The the current instance, if is the same type + /// as the current instance; otherwise, null. + object IFormatProvider.GetFormat(Type formatType) + { + return formatType == typeof(Session) ? this : null; + } + + /// + /// Closes the session handle. Also closes the active database handle, if it is open. + /// After closing a handle, further method calls may throw an . + /// + /// If true, the method has been called directly + /// or indirectly by a user's code, so managed and unmanaged resources will + /// be disposed. If false, only unmanaged resources will be disposed. + protected override void Dispose(bool disposing) + { + try + { + if (disposing) + { + if (this.database != null) + { + this.database.Dispose(); + this.database = null; + } + } + } + finally + { + base.Dispose(disposing); + } + } + + /// + /// Gets the (short) list of properties that are available from non-immediate custom actions. + /// + private static IList NonImmediatePropertyNames + { + get + { + return new string[] { + CustomActionData.PropertyName, + "ProductCode", + "UserSID" + }; + } + } + + /// + /// Throws an exception if the custom action is not able to access immedate session details. + /// + private void ValidateSessionAccess() + { + if (!this.sessionAccessValidated) + { + if (this.GetMode(InstallRunMode.Scheduled) || + this.GetMode(InstallRunMode.Rollback) || + this.GetMode(InstallRunMode.Commit)) + { + throw new InstallerException("Cannot access session details from a non-immediate custom action"); + } + + this.sessionAccessValidated = true; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs new file mode 100644 index 00000000..4c043bf2 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ShortcutTarget.cs @@ -0,0 +1,104 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + /// + /// Holds information about the target of a shortcut file. + /// + public struct ShortcutTarget + { + private string productCode; + private string feature; + private string componentCode; + + internal ShortcutTarget(string productCode, string feature, string componentCode) + { + this.productCode = productCode; + this.feature = feature; + this.componentCode = componentCode; + } + + /// + /// Gets the target product code of the shortcut, or null if not available. + /// + public string ProductCode + { + get + { + return this.productCode; + } + } + + /// + /// Gets the name of the target feature of the shortcut, or null if not available. + /// + public string Feature + { + get + { + return this.feature; + } + } + + /// + /// Gets the target component code of the shortcut, or null if not available. + /// + public string ComponentCode + { + get + { + return this.componentCode; + } + } + + /// + /// Tests whether two shortcut targets have the same product code, feature, and/or component code. + /// + /// The first shortcut target to compare. + /// The second shortcut target to compare. + /// True if all parts of the targets are the same, else false. + public static bool operator ==(ShortcutTarget st1, ShortcutTarget st2) + { + return st1.Equals(st2); + } + + /// + /// Tests whether two shortcut targets have the same product code, feature, and/or component code. + /// + /// The first shortcut target to compare. + /// The second shortcut target to compare. + /// True if any parts of the targets are different, else false. + public static bool operator !=(ShortcutTarget st1, ShortcutTarget st2) + { + return !st1.Equals(st2); + } + + /// + /// Tests whether two shortcut targets have the same product code, feature, and/or component code. + /// + /// The shortcut target to compare to the current object. + /// True if is a shortcut target and all parts of the targets are the same, else false. + public override bool Equals(object obj) + { + if (obj == null || obj.GetType() != typeof(ShortcutTarget)) + { + return false; + } + ShortcutTarget st = (ShortcutTarget) obj; + return this.productCode == st.productCode + && this.feature == st.feature + && this.componentCode == st.componentCode; + } + + /// + /// Generates a hash code using all parts of the shortcut target. + /// + /// An integer suitable for hashing the shortcut target. + public override int GetHashCode() + { + return (this.productCode != null ? this.productCode.GetHashCode() : 0) + ^ (this.feature != null ? this.feature.GetHashCode() : 0) + ^ (this.componentCode != null ? this.componentCode.GetHashCode() : 0); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceList.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceList.cs new file mode 100644 index 00000000..16ec22e8 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceList.cs @@ -0,0 +1,525 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// A list of sources for an installed product or patch. + /// + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + public class SourceList : ICollection + { + private Installation installation; + private SourceMediaList mediaList; + + internal SourceList(Installation installation) + { + this.installation = installation; + } + + /// + /// Gets the list of disks registered for the media source of + /// the patch or product installation. + /// + public SourceMediaList MediaList + { + get + { + if (this.mediaList == null) + { + this.mediaList = new SourceMediaList(this.installation); + } + return this.mediaList; + } + } + + /// + /// Gets the number of network and URL sources in the list. + /// + public int Count + { + get + { + int count = 0; + IEnumerator e = this.GetEnumerator(); + while (e.MoveNext()) + { + count++; + } + return count; + } + } + + /// + /// Gets a boolean value indicating whether the list is read-only. + /// A SourceList is never read-only. + /// + /// read-only status of the list + public bool IsReadOnly + { + get { return false; } + } + + /// + /// Adds a network or URL source to the source list of the installed product. + /// + /// Path to the source to be added. This parameter is + /// expected to contain only the path without the filename. + ///

+ /// If this method is called with a new source, the installer adds the source + /// to the end of the source list. + ///

+ /// If this method is called with a source already existing in the source + /// list, it has no effect. + ///

+ /// Win32 MSI APIs: + /// MsiSourceListAddSource, + /// MsiSourceListAddSourceEx + ///

+ /// + public void Add(string item) + { + if (!this.Contains(item)) + { + this.Insert(item, 0); + } + } + + /// + /// Adds or reorders a network or URL source for the product or patch. + /// + /// Path to the source to be added. This parameter is + /// expected to contain only the path without the filename. + /// Specifies the priority order in which the source + /// will be inserted + ///

+ /// If this method is called with a new source and + /// is set to 0, the installer adds the source to the end of the source list. + ///

+ /// If this method is called with a source already existing in the source + /// list and is set to 0, the installer retains the + /// source's existing index. + ///

+ /// If the method is called with an existing source in the source list + /// and is set to a non-zero value, the source is + /// removed from its current location in the list and inserted at the position + /// specified by Index, before any source that already exists at that position. + ///

+ /// If the method is called with a new source and Index is set to a + /// non-zero value, the source is inserted at the position specified by + /// , before any source that already exists at + /// that position. The index value for all sources in the list after the + /// index specified by Index are updated to ensure unique index values and + /// the pre-existing order is guaranteed to remain unchanged. + ///

+ /// If is greater than the number of sources + /// in the list, the source is placed at the end of the list with an index + /// value one larger than any existing source. + ///

+ /// Win32 MSI API: + /// MsiSourceListAddSourceEx + ///

+ public void Insert(string item, int index) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + + NativeMethods.SourceType type = item.Contains("://") ? NativeMethods.SourceType.Url : NativeMethods.SourceType.Network; + + uint ret = NativeMethods.MsiSourceListAddSourceEx( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) type | (uint) this.installation.InstallationType, + item, + (uint) index); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Clears sources of all types: network, url, and media. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListClearAll + ///

+ public void Clear() + { + this.ClearSourceType(NativeMethods.SourceType.Url); + this.ClearSourceType(NativeMethods.SourceType.Network); + this.MediaList.Clear(); + } + + /// + /// Removes all network sources from the list. URL sources are not affected. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListClearAllEx + ///

+ public void ClearNetworkSources() + { + this.ClearSourceType(NativeMethods.SourceType.Network); + } + + /// + /// Removes all URL sources from the list. Network sources are not affected. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListClearAllEx + ///

+ public void ClearUrlSources() + { + this.ClearSourceType(NativeMethods.SourceType.Url); + } + + /// + /// Checks if the specified source exists in the list. + /// + /// case-insensitive source to look for + /// true if the source exists in the list, false otherwise + public bool Contains(string item) + { + if (String.IsNullOrEmpty(item)) + { + throw new ArgumentNullException("item"); + } + + foreach (string s in this) + { + if (s.Equals(item, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; + } + + /// + /// Copies the network and URL sources from this list into an array. + /// + /// destination array to be filed + /// offset into the destination array where copying begins + public void CopyTo(string[] array, int arrayIndex) + { + foreach (string source in this) + { + array[arrayIndex++] = source; + } + } + + /// + /// Removes a network or URL source. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListClearSource + ///

+ public bool Remove(string item) + { + if (String.IsNullOrEmpty(item)) + { + throw new ArgumentNullException("item"); + } + + NativeMethods.SourceType type = item.Contains("://") ? NativeMethods.SourceType.Url : NativeMethods.SourceType.Network; + + uint ret = NativeMethods.MsiSourceListClearSource( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) type | (uint) this.installation.InstallationType, + item); + if (ret != 0) + { + // TODO: Figure out when to return false. + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + /// + /// Enumerates the network and URL sources in the source list of the patch or product installation. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListEnumSources + ///

+ public IEnumerator GetEnumerator() + { + StringBuilder sourceBuf = new StringBuilder(256); + uint sourceBufSize = (uint) sourceBuf.Capacity; + for (uint i = 0; true; i++) + { + uint ret = this.EnumSources(sourceBuf, i, NativeMethods.SourceType.Network); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + else + { + yield return sourceBuf.ToString(); + } + } + + for (uint i = 0; true; i++) + { + uint ret = this.EnumSources(sourceBuf, i, NativeMethods.SourceType.Url); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + else + { + yield return sourceBuf.ToString(); + } + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + /// + /// Forces the installer to search the source list for a valid + /// source the next time a source is required. For example, when the + /// installer performs an installation or reinstallation, or when it + /// requires the path for a component that is set to run from source. + /// + ///

+ /// Win32 MSI APIs: + /// MsiSourceListForceResolution, + /// MsiSourceListForceResolutionEx + ///

+ public void ForceResolution() + { + uint ret = NativeMethods.MsiSourceListForceResolutionEx( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Gets or sets the path relative to the root of the installation media. + /// + public string MediaPackagePath + { + get + { + return this["MediaPackagePath"]; + } + set + { + this["MediaPackagePath"] = value; + } + } + + /// + /// Gets or sets the prompt template that is used when prompting the user + /// for installation media. + /// + public string DiskPrompt + { + get + { + return this["DiskPrompt"]; + } + set + { + this["DiskPrompt"] = value; + } + } + + /// + /// Gets or sets the most recently used source location for the product. + /// + public string LastUsedSource + { + get + { + return this["LastUsedSource"]; + } + set + { + this["LastUsedSource"] = value; + } + } + + /// + /// Gets or sets the name of the Windows Installer package or patch package + /// on the source. + /// + public string PackageName + { + get + { + return this["PackageName"]; + } + set + { + this["PackageName"] = value; + } + } + + /// + /// Gets the type of the last-used source. + /// + ///

+ ///

    + ///
  • "n" = network location
  • + ///
  • "u" = URL location
  • + ///
  • "m" = media location
  • + ///
  • (empty string) = no last used source
  • + ///
+ ///

+ public string LastUsedType + { + get + { + return this["LastUsedType"]; + } + } + + /// + /// Gets or sets source list information properties of a product or patch installation. + /// + /// The source list information property name. + /// An unknown product, patch, or property was requested + ///

+ /// Win32 MSI API: + /// MsiSourceListGetInfo + ///

+ public string this[string property] + { + get + { + StringBuilder buf = new StringBuilder(""); + uint bufSize = 0; + uint ret = NativeMethods.MsiSourceListGetInfo( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + property, + buf, + ref bufSize); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + buf.Capacity = (int) ++bufSize; + ret = NativeMethods.MsiSourceListGetInfo( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + property, + buf, + ref bufSize); + } + + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_PRODUCT || + ret == (uint) NativeMethods.Error.UNKNOWN_PROPERTY) + { + throw new ArgumentOutOfRangeException("property"); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + return buf.ToString(); + } + set + { + uint ret = NativeMethods.MsiSourceListSetInfo( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + property, + value); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.UNKNOWN_PRODUCT || + ret == (uint) NativeMethods.Error.UNKNOWN_PROPERTY) + { + throw new ArgumentOutOfRangeException("property"); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + } + + private void ClearSourceType(NativeMethods.SourceType type) + { + uint ret = NativeMethods.MsiSourceListClearAllEx( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) type | (uint) this.installation.InstallationType); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + private uint EnumSources(StringBuilder sourceBuf, uint i, NativeMethods.SourceType sourceType) + { + int enumType = (this.installation.InstallationType | (int) sourceType); + uint sourceBufSize = (uint) sourceBuf.Capacity; + uint ret = NativeMethods.MsiSourceListEnumSources( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) enumType, + i, + sourceBuf, + ref sourceBufSize); + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + sourceBuf.Capacity = (int) ++sourceBufSize; + ret = NativeMethods.MsiSourceListEnumSources( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) enumType, + i, + sourceBuf, + ref sourceBufSize); + } + return ret; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceMediaList.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceMediaList.cs new file mode 100644 index 00000000..cf7b7ec5 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SourceMediaList.cs @@ -0,0 +1,229 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections.Generic; + using System.Text; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// A list of source media for an installed product or patch. + /// + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + public class SourceMediaList : ICollection + { + private Installation installation; + + internal SourceMediaList(Installation installation) + { + this.installation = installation; + } + + /// + /// Gets the number of source media in the list. + /// + public int Count + { + get + { + int count = 0; + IEnumerator e = this.GetEnumerator(); + while (e.MoveNext()) + { + count++; + } + return count; + } + } + + /// + /// Gets a boolean value indicating whether the list is read-only. + /// A SourceMediaList is never read-only. + /// + /// read-only status of the list + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Adds or updates a disk of the media source for the product or patch. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListAddMediaDisk + ///

+ public void Add(MediaDisk item) + { + uint ret = NativeMethods.MsiSourceListAddMediaDisk( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + (uint) item.DiskId, + item.VolumeLabel, + item.DiskPrompt); + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Removes all source media from the list. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListClearAllEx + ///

+ public void Clear() + { + uint ret = NativeMethods.MsiSourceListClearAllEx( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) NativeMethods.SourceType.Media | (uint) this.installation.InstallationType); + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Checks if the specified media disk id exists in the list. + /// + /// disk id of the media to look for + /// true if the media exists in the list, false otherwise + public bool Contains(int diskId) + { + foreach (MediaDisk mediaDisk in this) + { + if (mediaDisk.DiskId == diskId) + { + return true; + } + } + return false; + } + + bool ICollection.Contains(MediaDisk mediaDisk) + { + return this.Contains(mediaDisk.DiskId); + } + + /// + /// Copies the source media info from this list into an array. + /// + /// destination array to be filed + /// offset into the destination array where copying begins + public void CopyTo(MediaDisk[] array, int arrayIndex) + { + foreach (MediaDisk mediaDisk in this) + { + array[arrayIndex++] = mediaDisk; + } + } + + /// + /// Removes a specified disk from the set of registered disks. + /// + /// ID of the disk to remove + ///

+ /// Win32 MSI API: + /// MsiSourceListClearMediaDisk + ///

+ public bool Remove(int diskId) + { + uint ret = NativeMethods.MsiSourceListClearMediaDisk( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + (uint) diskId); + + if (ret != 0) + { + // TODO: Figure out when to return false. + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + bool ICollection.Remove(MediaDisk mediaDisk) + { + return this.Remove(mediaDisk.DiskId); + } + + /// + /// Enumerates the source media in the source list of the patch or product installation. + /// + ///

+ /// Win32 MSI API: + /// MsiSourceListEnumMediaDisks + ///

+ public IEnumerator GetEnumerator() + { + uint diskId; + StringBuilder volumeBuf = new StringBuilder(40); + uint volumeBufSize = (uint) volumeBuf.Capacity; + StringBuilder promptBuf = new StringBuilder(80); + uint promptBufSize = (uint) promptBuf.Capacity; + for (uint i = 0; true; i++) + { + uint ret = NativeMethods.MsiSourceListEnumMediaDisks( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + i, + out diskId, + volumeBuf, + ref volumeBufSize, + promptBuf, + ref promptBufSize); + + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + volumeBuf.Capacity = (int) ++volumeBufSize; + promptBuf.Capacity = (int) ++promptBufSize; + + ret = NativeMethods.MsiSourceListEnumMediaDisks( + this.installation.InstallationCode, + this.installation.UserSid, + this.installation.Context, + (uint) this.installation.InstallationType, + i, + out diskId, + volumeBuf, + ref volumeBufSize, + promptBuf, + ref promptBufSize); + } + + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + break; + } + + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + yield return new MediaDisk((int) diskId, volumeBuf.ToString(), promptBuf.ToString()); + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SummaryInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SummaryInfo.cs new file mode 100644 index 00000000..4dbff93f --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/SummaryInfo.cs @@ -0,0 +1,612 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Text; + using System.Globalization; + using System.Runtime.InteropServices; + + /// + /// Provides access to summary information of a Windows Installer database. + /// + public class SummaryInfo : InstallerHandle + { + internal const int MAX_PROPERTIES = 20; + + /// + /// Gets a SummaryInfo object that can be used to examine, update, and add + /// properties to the summary information stream of a package or transform. + /// + /// Path to the package (database) or transform + /// True to reserve resources for writing summary information properties. + /// the package does not exist or could not be read + /// the package is an invalid format + ///

+ /// The SummaryInfo object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiGetSummaryInformation + ///

+ public SummaryInfo(string packagePath, bool enableWrite) + : base((IntPtr) SummaryInfo.OpenSummaryInfo(packagePath, enableWrite), true) + { + } + + internal SummaryInfo(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle) + { + } + + /// Gets or sets the Title summary information property. + ///

+ /// The Title summary information property briefly describes the type of installer package. Phrases + /// such as "Installation Database" or "Transform" or "Patch" may be used for this property. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Title + { + get { return this[2]; } + set { this[2] = value; } + } + + /// Gets or sets the Subject summary information property. + ///

+ /// The Subject summary information property conveys to a file browser the product that can be installed using + /// the logic and data in this installer database. For example, the value of the summary property for + /// Microsoft Office 97 would be "Microsoft Office 97 Professional". This value is typically set from the + /// installer property ProductName. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Subject + { + get { return this[3]; } + set { this[3] = value; } + } + + /// Gets or sets the Author summary information property. + ///

+ /// The Author summary information property conveys to a file browser the manufacturer of the installation + /// database. This value is typically set from the installer property Manufacturer. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Author + { + get { return this[4]; } + set { this[4] = value; } + } + + /// Gets or sets the Keywords summary information property. + ///

+ /// The Keywords summary information property is used by file browsers to hold keywords that permit the + /// database file to be found in a keyword search. The set of keywords typically includes "Installer" as + /// well as product-specific keywords, and may be localized. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Keywords + { + get { return this[5]; } + set { this[5] = value; } + } + + /// Gets or sets the Comments summary information property. + ///

+ /// The Comments summary information property conveys the general purpose of the installer database. By convention, + /// the value for this summary property is set to the following: + ///

+ /// "This installer database contains the logic and data required to install <product name>." + ///

+ /// where <product name> is the name of the product being installed. In general the value for this summary + /// property only changes in the product name, nothing else. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Comments + { + get { return this[6]; } + set { this[6] = value; } + } + + /// Gets or sets the Template summary information property. + ///

+ /// The Template summary information propery indicates the platform and language versions supported by the database. + ///

+ /// The syntax of the Template Summary property information is: + /// [platform property][,platform property][,...];[language id][,language id][,...] + ///

+ /// For example, the following are all valid values for the Template Summary property: + /// + /// Intel;1033 + /// Intel64;1033 + /// ;1033 + /// ; + /// Intel ;1033,2046 + /// Intel64;1033,2046 + /// Intel;0 + /// + ///

+ /// If this is a 64-bit Windows Installer, enter Intel64 in the Template summary information property. Note that an + /// installation package cannot have both the Intel and Intel64 properties set. + ///

+ /// If the current platform does not match one of the platforms specified then the installer will not process the + /// package. Not specifying a platform implies that the package is platform-independent. + ///

+ /// Entering 0 in the language ID field of the Template summary information property, or leaving this field empty, + /// indicates that the package is language neutral. + ///

+ /// There are variations of this property depending on whether it is in a source installer database or a transform. + ///

+ /// Source Installer Database - Only one language can be specified in a source installer database. Merge Modules are + /// the only packages that may have multiple languages. For more information, see Multiple Language Merge Modules. + ///

+ /// Transform - In a transform file, only one language may be specified. The specified platform and language determine + /// whether a transform can be applied to a particular database. The platform property and the language property can + /// be left blank if no transform restriction relies on them to validate the transform. + ///

+ /// This summary property is REQUIRED. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string Template + { + get { return this[7]; } + set { this[7] = value; } + } + + /// Gets or sets the LastSavedBy summary information property. + ///

+ /// The installer sets the Last Saved By summary information property to the value of the LogonUser property during + /// an administrative installation. The installer never uses this property and a user never needs to modify it. + /// Developers of a database editing tool may use this property to track the last person to modify the database. + /// This property should be left set to null in a final shipping database. + ///

+ /// In a transform, this summary property contains the platform and language ID(s) that a database should have + /// after it has been transformed. The property specifies to what the Template should be set in the new database. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string LastSavedBy + { + get { return this[8]; } + set { this[8] = value; } + } + + /// Gets or sets the RevisionNumber summary information property. + ///

+ /// The Revision Number summary information property contains the package code for the installer package. The + /// package code is a unique identifier of the installer package. + ///

+ /// The Revision Number summary information property of a patch package specifies the GUID patch code for + /// the patch. This is followed by a list of patch code GUIDs for obsolete patches that are removed when this + /// patch is applied. The patch codes are concatenated with no delimiters separating GUIDs in the list. + ///

+ /// The Revision Number summary information property of a transform package lists the product code GUIDs + /// and version of the new and original products and the upgrade code GUID. The list is separated with + /// semicolons as follows. + ///

+ /// Original-Product-Code Original-Product-Version ; New-Product Code New-Product-Version; Upgrade-Code + ///

+ /// This summary property is REQUIRED. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string RevisionNumber + { + get { return this[9]; } + set { this[9] = value; } + } + + /// Gets or sets the CreatingApp summary information property. + ///

+ /// The CreatingApp summary information property conveys which application created the installer database. + /// In general the value for this summary property is the name of the software used to author this database. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public string CreatingApp + { + get { return this[18]; } + set { this[18] = value; } + } + + /// Gets or sets the LastPrintTime summary information property. + ///

+ /// The LastPrintTime summary information property can be set to the date and time during an administrative + /// installation to record when the administrative image was created. For non-administrative installations + /// this property is the same as the CreateTime summary information property. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public DateTime LastPrintTime + { + get { return (DateTime) this[11, typeof(DateTime)]; } + set { this[11, typeof(DateTime)] = value; } + } + + /// Gets or sets the CreateTime summary information property. + ///

+ /// The CreateTime summary information property conveys when the installer database was created. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public DateTime CreateTime + { + get { return (DateTime) this[12, typeof(DateTime)]; } + set { this[12, typeof(DateTime)] = value; } + } + + /// Gets or sets the LastSaveTime summary information property. + ///

+ /// The LastSaveTime summary information property conveys when the last time the installer database was + /// modified. Each time a user changes an installation the value for this summary property is updated to + /// the current system time/date at the time the installer database was saved. Initially the value for + /// this summary property is set to null to indicate that no changes have yet been made. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public DateTime LastSaveTime + { + get { return (DateTime) this[13, typeof(DateTime)]; } + set { this[13, typeof(DateTime)] = value; } + } + + /// Gets or sets the CodePage summary information property. + ///

+ /// The Codepage summary information property is the numeric value of the ANSI code page used for any + /// strings that are stored in the summary information. Note that this is not the same code page for + /// strings in the installation database. The Codepage summary information property is used to translate + /// the strings in the summary information into Unicode when calling the Unicode API functions. The + /// Codepage summary information property must be set before any string properties are set in the + /// summary information. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public short CodePage + { + get { return (short) this[1, typeof(short)]; } + set { this[1, typeof(short)] = value; } + } + + /// Gets or sets the PageCount summary information property. + ///

+ /// For an installation package, the PageCount summary information property contains the minimum + /// installer version required. For Windows Installer version 1.0, this property must be set to the + /// integer 100. For 64-bit Windows Installer Packages, this property must be set to the integer 200. + ///

+ /// For a transform package, the PageCount summary information property contains minimum installer + /// version required to process the transform. Set to the greater of the two PageCount summary information + /// property values belonging to the databases used to generate the transform. + ///

+ /// The PageCount summary information property is set to null in patch packages. + ///

+ /// This summary property is REQUIRED. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public int PageCount + { + get { return (int) this[14, typeof(int)]; } + set { this[14, typeof(int)] = value; } + } + + /// Gets or sets the WordCount summary information property. + ///

+ /// The WordCount summary information property indicates the type of source file image. If this property is + /// not present, it defaults to 0. Note that this property is stored in place of the standard Count property. + ///

+ /// This property is a bit field. New bits may be added in the future. At present the following bits are + /// available: + /// + /// Bit 0: 0 = long file names, 1 = short file names + /// Bit 1: 0 = source is uncompressed, 1 = source is compressed + /// Bit 2: 0 = source is original media, 1 = source is administrative installation + /// [MSI 4.0] Bit 3: 0 = elevated privileges can be required to install, 1 = elevated privileges are not required to install + /// + ///

+ /// These are combined to give the WordCount summary information property one of the following values + /// indicating a type of source file image: + /// + /// 0 - Original source using long file names. Matches tree in Directory table. + /// 1 - Original source using short file names. Matches tree in Directory table. + /// 2 - Compressed source files using long file names. Matches cabinets and files in the Media table. + /// 3 - Compressed source files using short file names. Matches cabinets and files in the Media table. + /// 4 - Administrative image using long file names. Matches tree in Directory table. + /// 5 - Administrative image using short file names. Matches tree in Directory table. + /// + ///

+ /// Note that if the package is marked as compressed (bit 1 is set), the installer only installs files + /// located at the root of the source. In this case, even files marked as uncompressed in the File table must + /// be located at the root to be installed. To specify a source image that has both a cabinet file (compressed + /// files) and uncompressed files that match the tree in the Directory table, mark the package as uncompressed + /// by leaving bit 1 unset (value=0) in the WordCount summary information property and set + /// (value=16384) in the Attributes column of the File table + /// for each file in the cabinet. + ///

+ /// For a patch package, the WordCount summary information property specifies the patch engine that was used + /// to create the patch files. The default value is 1 and indicates that MSPATCH was used to create the patch + /// A value of "2" means that the patch is using smaller, optimized, files available only with Windows Installer + /// version 1.2 or later. A patch with a WordCount of "2" fails immediately if used with a Windows Installer + /// version earlier than 1.2. A patch with a WordCount of "3" fails immediately if used with a Windows Installer + /// version earlier than 2.0. + ///

+ /// This summary property is REQUIRED. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public int WordCount + { + get { return (int) this[15, typeof(int)]; } + set { this[15, typeof(int)] = value; } + } + + /// Gets or sets the CharacterCount summary information property. + ///

+ /// The CharacterCount summary information property is only used in transforms. This part of the summary + /// information stream is divided into two 16-bit words. The upper word contains the transform validation + /// flags. The lower word contains the transform error condition flags. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public int CharacterCount + { + get { return (int) this[16, typeof(int)]; } + set { this[16, typeof(int)] = value; } + } + + /// Gets or sets the Security summary information property. + ///

+ /// The Security summary information property conveys whether the package should be opened as read-only. The database + /// editing tool should not modify a read-only enforced database and should issue a warning at attempts to modify a + /// read-only recommended database. The following values of this property are applicable to Windows Installer files: + /// + /// 0 - no restriction + /// 2 - read only recommended + /// 4 - read only enforced + /// + ///

+ /// This property should be set to read-only recommended (2) for an installation database and to read-only + /// enforced (4) for a transform or patch. + ///

+ /// Win32 MSI APIs: + /// MsiSummaryInfoGetProperty, + /// MsiSummaryInfoSetProperty + ///

+ public int Security + { + get { return (int) this[19, typeof(int)]; } + set { this[19, typeof(int)] = value; } + } + + private object this[uint property, Type type] + { + get + { + uint dataType; + StringBuilder stringValue = new StringBuilder(""); + uint bufSize = 0; + int intValue; + long timeValue = 0; + + uint ret = RemotableNativeMethods.MsiSummaryInfoGetProperty( + (int) this.Handle, + property, + out dataType, + out intValue, + ref timeValue, + stringValue, + ref bufSize); + if (ret != 0 && dataType != (uint) VarEnum.VT_LPSTR) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + switch ((VarEnum) dataType) + { + case VarEnum.VT_EMPTY: + { + if (type == typeof(DateTime)) + { + return DateTime.MinValue; + } + else if (type == typeof(string)) + { + return String.Empty; + } + else if (type == typeof(short)) + { + return (short) 0; + } + else + { + return (int) 0; + } + } + + case VarEnum.VT_LPSTR: + { + if (ret == (uint) NativeMethods.Error.MORE_DATA) + { + stringValue.Capacity = (int) ++bufSize; + ret = RemotableNativeMethods.MsiSummaryInfoGetProperty( + (int) this.Handle, + property, + out dataType, + out intValue, + ref timeValue, + stringValue, + ref bufSize); + } + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return stringValue.ToString(); + } + + case VarEnum.VT_I2: + case VarEnum.VT_I4: + { + if (type == typeof(string)) + { + return intValue.ToString(CultureInfo.InvariantCulture); + } + else if (type == typeof(short)) + { + return (short) intValue; + } + else + { + return intValue; + } + } + + case VarEnum.VT_FILETIME: + { + if (type == typeof(string)) + { + return DateTime.FromFileTime(timeValue).ToString(CultureInfo.InvariantCulture); + } + else + { + return DateTime.FromFileTime(timeValue); + } + } + + default: + { + throw new InstallerException(); + } + } + } + + set + { + uint dataType = (uint) VarEnum.VT_NULL; + string stringValue = ""; + int intValue = 0; + long timeValue = 0; + + if (type == typeof(short)) + { + dataType = (uint) VarEnum.VT_I2; + intValue = (int)(short) value; // Double cast because value is a *boxed* short. + } + else if (type == typeof(int)) + { + dataType = (uint) VarEnum.VT_I4; + intValue = (int) value; + } + else if (type == typeof(string)) + { + dataType = (uint) VarEnum.VT_LPSTR; + stringValue = (string) value; + } + else // (type == typeof(DateTime)) + { + dataType = (uint) VarEnum.VT_FILETIME; + timeValue = ((DateTime) value).ToFileTime(); + } + + uint ret = NativeMethods.MsiSummaryInfoSetProperty( + (int) this.Handle, + property, + dataType, + intValue, + ref timeValue, + stringValue); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } + + private string this[uint property] + { + get { return (string) this[property, typeof(string)]; } + set { this[property, typeof(string)] = value; } + } + + /// + /// Formats and writes the previously stored properties into the standard summary information stream. + /// + /// The stream cannot be successfully written. + ///

+ /// This method may only be called once after all the property values have been set. Properties may + /// still be read after the stream is written. + ///

+ /// Win32 MSI API: + /// MsiSummaryInfoPersist + ///

+ public void Persist() + { + uint ret = NativeMethods.MsiSummaryInfoPersist((int) this.Handle); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + private static int OpenSummaryInfo(string packagePath, bool enableWrite) + { + int summaryInfoHandle; + int maxProperties = !enableWrite ? 0 : SummaryInfo.MAX_PROPERTIES; + uint ret = RemotableNativeMethods.MsiGetSummaryInformation( + 0, + packagePath, + (uint) maxProperties, + out summaryInfoHandle); + if (ret != 0) + { + if (ret == (uint) NativeMethods.Error.FILE_NOT_FOUND || + ret == (uint) NativeMethods.Error.ACCESS_DENIED) + { + throw new FileNotFoundException(null, packagePath); + } + else + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + return summaryInfoHandle; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableCollection.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableCollection.cs new file mode 100644 index 00000000..95176ea0 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableCollection.cs @@ -0,0 +1,192 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections.Generic; + using System.Text; + + /// + /// Contains information about all the tables in a Windows Installer database. + /// + public class TableCollection : ICollection + { + private Database db; + + internal TableCollection(Database db) + { + this.db = db; + } + + /// + /// Gets the number of tables in the database. + /// + public int Count + { + get + { + return this.GetTables().Count; + } + } + + /// + /// Gets a boolean value indicating whether the collection is read-only. + /// A TableCollection is read-only when the database is read-only. + /// + /// read-only status of the collection + public bool IsReadOnly + { + get + { + return this.db.IsReadOnly; + } + } + + /// + /// Gets information about a given table. + /// + /// case-sensitive name of the table + /// information about the requested table, or null if the table does not exist in the database + public TableInfo this[string table] + { + get + { + if (String.IsNullOrEmpty(table)) + { + throw new ArgumentNullException("table"); + } + + if (!this.Contains(table)) + { + return null; + } + + return new TableInfo(this.db, table); + } + } + + /// + /// Adds a new table to the database. + /// + /// information about the table to be added + /// a table with the same name already exists in the database + public void Add(TableInfo item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + + if (this.Contains(item.Name)) + { + throw new InvalidOperationException(); + } + + this.db.Execute(item.SqlCreateString); + } + + /// + /// Removes all tables (and all data) from the database. + /// + public void Clear() + { + foreach (string table in this.GetTables()) + { + this.Remove(table); + } + } + + /// + /// Checks if the database contains a table with the given name. + /// + /// case-sensitive name of the table to search for + /// True if the table exists, false otherwise. + public bool Contains(string item) + { + if (String.IsNullOrEmpty(item)) + { + throw new ArgumentNullException("item"); + } + uint ret = RemotableNativeMethods.MsiDatabaseIsTablePersistent((int) this.db.Handle, item); + if (ret == 3) // MSICONDITION_ERROR + { + throw new InstallerException(); + } + return ret != 2; // MSICONDITION_NONE + } + + bool ICollection.Contains(TableInfo item) + { + return this.Contains(item.Name); + } + + /// + /// Copies the table information from this collection into an array. + /// + /// destination array to be filed + /// offset into the destination array where copying begins + public void CopyTo(TableInfo[] array, int arrayIndex) + { + if (array == null) + { + throw new ArgumentNullException("array"); + } + + foreach (string table in this.GetTables()) + { + array[arrayIndex++] = new TableInfo(this.db, table); + } + } + + /// + /// Removes a table from the database. + /// + /// case-sensitive name of the table to be removed + /// true if the table was removed, false if the table did not exist + public bool Remove(string item) + { + if (String.IsNullOrEmpty(item)) + { + throw new ArgumentNullException("item"); + } + + if (!this.Contains(item)) + { + return false; + } + this.db.Execute("DROP TABLE `{0}`", item); + return true; + } + + bool ICollection.Remove(TableInfo item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + + return this.Remove(item.Name); + } + + /// + /// Enumerates the tables in the database. + /// + public IEnumerator GetEnumerator() + { + foreach (string table in this.GetTables()) + { + yield return new TableInfo(this.db, table); + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + private IList GetTables() + { + return this.db.ExecuteStringQuery("SELECT `Name` FROM `_Tables`"); + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableInfo.cs new file mode 100644 index 00000000..e5a850b0 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/TableInfo.cs @@ -0,0 +1,264 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Collections.ObjectModel; + + /// + /// Defines a table in an installation database. + /// + public class TableInfo + { + private string name; + private ColumnCollection columns; + private ReadOnlyCollection primaryKeys; + + /// + /// Creates a table definition. + /// + /// Name of the table. + /// Columns in the table. + /// The primary keys of the table. + public TableInfo(string name, ICollection columns, IList primaryKeys) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + + if (columns == null || columns.Count == 0) + { + throw new ArgumentNullException("columns"); + } + + if (primaryKeys == null || primaryKeys.Count == 0) + { + throw new ArgumentNullException("primaryKeys"); + } + + this.name = name; + this.columns = new ColumnCollection(columns); + this.primaryKeys = new List(primaryKeys).AsReadOnly(); + foreach (string primaryKey in this.primaryKeys) + { + if (!this.columns.Contains(primaryKey)) + { + throw new ArgumentOutOfRangeException("primaryKeys"); + } + } + } + + internal TableInfo(Database db, string name) + { + if (db == null) + { + throw new ArgumentNullException("db"); + } + + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + + this.name = name; + + using (View columnsView = db.OpenView("SELECT * FROM `{0}`", name)) + { + this.columns = new ColumnCollection(columnsView); + } + + this.primaryKeys = new ReadOnlyCollection( + TableInfo.GetTablePrimaryKeys(db, name)); + } + + /// + /// Gets the name of the table. + /// + public string Name + { + get + { + return this.name; + } + } + + /// + /// Gets information about the columns in this table. + /// + ///

+ /// This property queries the database every time it is called, + /// to ensure the returned values are up-to-date. For best performance, + /// hold onto the returned collection if using it more than once. + ///

+ public ColumnCollection Columns + { + get + { + return this.columns; + } + } + + /// + /// Gets the names of the columns that are primary keys of the table. + /// + public IList PrimaryKeys + { + get + { + return this.primaryKeys; + } + } + + /// + /// Gets an SQL CREATE string that can be used to create the table. + /// + public string SqlCreateString + { + get + { + StringBuilder s = new StringBuilder("CREATE TABLE `"); + s.Append(this.name); + s.Append("` ("); + int count = 0; + foreach (ColumnInfo col in this.Columns) + { + if (count > 0) + { + s.Append(", "); + } + s.Append(col.SqlCreateString); + count++; + } + s.Append(" PRIMARY KEY "); + count = 0; + foreach (string key in this.PrimaryKeys) + { + if (count > 0) + { + s.Append(", "); + } + s.AppendFormat("`{0}`", key); + count++; + } + s.Append(')'); + return s.ToString(); + } + } + + /// + /// Gets an SQL INSERT string that can be used insert a new record into the table. + /// + ///

+ /// The values are expressed as question-mark tokens, to be supplied by the record. + ///

+ public string SqlInsertString + { + get + { + StringBuilder s = new StringBuilder("INSERT INTO `"); + s.Append(this.name); + s.Append("` ("); + int count = 0; + foreach (ColumnInfo col in this.Columns) + { + if (count > 0) + { + s.Append(", "); + } + + s.AppendFormat("`{0}`", col.Name); + count++; + } + s.Append(") VALUES ("); + while (count > 0) + { + count--; + s.Append("?"); + + if (count > 0) + { + s.Append(", "); + } + } + s.Append(')'); + return s.ToString(); + } + } + + /// + /// Gets an SQL SELECT string that can be used to select all columns of the table. + /// + ///

+ /// The columns are listed explicitly in the SELECT string, as opposed to using "SELECT *". + ///

+ public string SqlSelectString + { + get + { + StringBuilder s = new StringBuilder("SELECT "); + int count = 0; + foreach (ColumnInfo col in this.Columns) + { + if (count > 0) s.Append(", "); + s.AppendFormat("`{0}`", col.Name); + count++; + } + s.AppendFormat(" FROM `{0}`", this.Name); + return s.ToString(); + } + } + + /// + /// Gets a string representation of the table. + /// + /// The name of the table. + public override string ToString() + { + return this.name; + } + + private static IList GetTablePrimaryKeys(Database db, string table) + { + if (table == "_Tables") + { + return new string[] { "Name" }; + } + else if (table == "_Columns") + { + return new string[] { "Table", "Number" }; + } + else if (table == "_Storages") + { + return new string[] { "Name" }; + } + else if (table == "_Streams") + { + return new string[] { "Name" }; + } + else + { + int hrec; + uint ret = RemotableNativeMethods.MsiDatabaseGetPrimaryKeys( + (int) db.Handle, table, out hrec); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + using (Record rec = new Record((IntPtr) hrec, true, null)) + { + string[] keys = new string[rec.FieldCount]; + for (int i = 0; i < keys.Length; i++) + { + keys[i] = rec.GetString(i + 1); + } + + return keys; + } + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Transaction.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Transaction.cs new file mode 100644 index 00000000..798dc79e --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/Transaction.cs @@ -0,0 +1,201 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + using System.Threading; + + /// + /// [MSI 4.5] Handle to a multi-session install transaction. + /// + ///

+ /// Win32 MSI APIs: + /// MsiBeginTransaction + /// MsiJoinTransaction + /// MsiEndTransaction + ///

+ public class Transaction : InstallerHandle + { + private string name; + private IntPtr ownerChangeEvent; + private IList> ownerChangeListeners; + + /// + /// [MSI 4.5] Begins transaction processing of a multi-package installation. + /// + /// Name of the multi-package installation. + /// Select optional behavior when beginning the transaction. + /// The transaction could not be initialized. + ///

+ /// Win32 MSI API: + /// MsiBeginTransaction + ///

+ public Transaction(string name, TransactionAttributes attributes) + : this(name, Transaction.Begin(name, attributes), true) + { + } + + /// + /// Internal constructor. + /// + /// + /// The second parameter is an array in order to receive multiple values from the initialization method. + /// + private Transaction(string name, IntPtr[] handles, bool ownsHandle) + : base(handles[0], ownsHandle) + { + this.name = name; + this.ownerChangeEvent = handles[1]; + this.ownerChangeListeners = new List>(); + } + + /// + /// Creates a new Transaction object from an integer handle. + /// + /// Integer transaction handle + /// true to close the handle when this object is disposed + public static Transaction FromHandle(IntPtr handle, bool ownsHandle) + { + return new Transaction(handle.ToString(), new IntPtr[] { handle, IntPtr.Zero }, ownsHandle); + } + + /// + /// Gets the name of the transaction. + /// + public string Name + { + get + { + return name; + } + } + + /// + /// Notifies listeners when the process that owns the transaction changed. + /// + public event EventHandler OwnerChanged + { + add + { + this.ownerChangeListeners.Add(value); + + if (this.ownerChangeEvent != IntPtr.Zero && this.ownerChangeListeners.Count == 1) + { + new Thread(this.WaitForOwnerChange).Start(); + } + } + remove + { + this.ownerChangeListeners.Remove(value); + } + } + + private void OnOwnerChanged() + { + EventArgs e = new EventArgs(); + foreach (EventHandler handler in this.ownerChangeListeners) + { + handler(this, e); + } + } + + private void WaitForOwnerChange() + { + int ret = NativeMethods.WaitForSingleObject(this.ownerChangeEvent, -1); + if (ret == 0) + { + this.OnOwnerChanged(); + } + else + { + throw new InstallerException(); + } + } + + /// + /// Makes the current process the owner of the multi-package installation transaction. + /// + /// Select optional behavior when joining the transaction. + /// The transaction handle is not valid. + /// The transaction could not be joined. + ///

+ /// Win32 MSI API: + /// MsiJoinTransaction + ///

+ public void Join(TransactionAttributes attributes) + { + IntPtr hChangeOfOwnerEvent; + uint ret = NativeMethods.MsiJoinTransaction((int) this.Handle, (int) attributes, out hChangeOfOwnerEvent); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + this.ownerChangeEvent = hChangeOfOwnerEvent; + if (this.ownerChangeEvent != IntPtr.Zero && this.ownerChangeListeners.Count >= 1) + { + new Thread(this.WaitForOwnerChange).Start(); + } + } + + /// + /// Ends the install transaction and commits all changes to the system belonging to the transaction. + /// + /// The transaction could not be committed. + ///

+ /// Runs any Commit Custom Actions and commits to the system any changes to Win32 or common language + /// runtime assemblies. Deletes the rollback script, and after using this option, the transaction's + /// changes can no longer be undone with a Rollback Installation. + ///

+ /// This method can only be called by the current owner of the transaction. + ///

+ /// Win32 MSI API: + /// MsiEndTransaction + ///

+ public void Commit() + { + this.End(true); + } + + /// + /// Ends the install transaction and undoes changes to the system belonging to the transaction. + /// + /// The transaction could not be rolled back. + ///

+ /// This method can only be called by the current owner of the transaction. + ///

+ /// Win32 MSI API: + /// MsiEndTransaction + ///

+ public void Rollback() + { + this.End(false); + } + + private static IntPtr[] Begin(string transactionName, TransactionAttributes attributes) + { + int hTransaction; + IntPtr hChangeOfOwnerEvent; + uint ret = NativeMethods.MsiBeginTransaction(transactionName, (int) attributes, out hTransaction, out hChangeOfOwnerEvent); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + return new IntPtr[] { (IntPtr) hTransaction, hChangeOfOwnerEvent }; + } + + [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] + private void End(bool commit) + { + uint ret = NativeMethods.MsiEndTransaction(commit ? 1 : 0); + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ValidationErrorInfo.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ValidationErrorInfo.cs new file mode 100644 index 00000000..3f75326e --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/ValidationErrorInfo.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System.Diagnostics.CodeAnalysis; + + /// + /// Contains specific information about an error encountered by the , + /// , or methods of the + /// class. + /// + [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + public struct ValidationErrorInfo + { + private ValidationError error; + private string column; + + internal ValidationErrorInfo(ValidationError error, string column) + { + this.error = error; + this.column = column; + } + + /// + /// Gets the type of validation error encountered. + /// + public ValidationError Error + { + get + { + return this.error; + } + } + + /// + /// Gets the column containing the error, or null if the error applies to the whole row. + /// + public string Column + { + get + { + return this.column; + } + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/View.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/View.cs new file mode 100644 index 00000000..21e8543e --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/View.cs @@ -0,0 +1,625 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// A View represents a result set obtained when processing a query using the + /// method of a + /// . Before any data can be transferred, + /// the query must be executed using the method, passing to + /// it all replaceable parameters designated within the SQL query string. + /// + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + public class View : InstallerHandle, IEnumerable + { + private Database database; + private string sql; + private IList tables; + private ColumnCollection columns; + + internal View(IntPtr handle, string sql, Database database) + : base(handle, true) + { + this.sql = sql; + this.database = database; + } + + /// + /// Gets the Database on which this View was opened. + /// + public Database Database + { + get { return this.database; } + } + + /// + /// Gets the SQL query string used to open this View. + /// + public string QueryString + { + get { return this.sql; } + } + + /// + /// Gets the set of tables that were included in the SQL query for this View. + /// + public IList Tables + { + get + { + if (this.tables == null) + { + if (this.sql == null) + { + return null; + } + + // Parse the table names out of the SQL query string by looking + // for tokens that can come before or after the list of tables. + + string parseSql = this.sql.Replace('\t', ' ').Replace('\r', ' ').Replace('\n', ' '); + string upperSql = parseSql.ToUpper(CultureInfo.InvariantCulture); + + string[] prefixes = new string[] { " FROM ", " INTO ", " TABLE " }; + string[] suffixes = new string[] { " WHERE ", " ORDER ", " SET ", " (", " ADD " }; + + int index; + + for (int i = 0; i < prefixes.Length; i++) + { + if ((index = upperSql.IndexOf(prefixes[i], StringComparison.Ordinal)) > 0) + { + parseSql = parseSql.Substring(index + prefixes[i].Length); + upperSql = upperSql.Substring(index + prefixes[i].Length); + } + } + + if (upperSql.StartsWith("UPDATE ", StringComparison.Ordinal)) + { + parseSql = parseSql.Substring(7); + upperSql = upperSql.Substring(7); + } + + for (int i = 0; i < suffixes.Length; i++) + { + if ((index = upperSql.IndexOf(suffixes[i], StringComparison.Ordinal)) > 0) + { + parseSql = parseSql.Substring(0, index); + upperSql = upperSql.Substring(0, index); + } + } + + if (upperSql.EndsWith(" HOLD", StringComparison.Ordinal) || + upperSql.EndsWith(" FREE", StringComparison.Ordinal)) + { + parseSql = parseSql.Substring(0, parseSql.Length - 5); + upperSql = upperSql.Substring(0, upperSql.Length - 5); + } + + // At this point we should be left with a comma-separated list of table names, + // optionally quoted with grave accent marks (`). + + string[] tableNames = parseSql.Split(','); + IList tableList = new List(tableNames.Length); + for (int i = 0; i < tableNames.Length; i++) + { + string tableName = tableNames[i].Trim(' ', '`'); + tableList.Add(new TableInfo(this.database, tableName)); + } + this.tables = tableList; + } + return new List(this.tables); + } + } + + /// + /// Gets the set of columns that were included in the query for this View, + /// or null if this view is not a SELECT query. + /// + /// the View is not in an active state + /// the View handle is invalid + ///

+ /// Win32 MSI API: + /// MsiViewGetColumnInfo + ///

+ public ColumnCollection Columns + { + get + { + if (this.columns == null) + { + this.columns = new ColumnCollection(this); + } + return this.columns; + } + } + + /// + /// Executes a SQL View query and supplies any required parameters. The query uses the + /// question mark token to represent parameters as described in SQL Syntax. The values of + /// these parameters are passed in as the corresponding fields of a parameter record. + /// + /// Optional Record that supplies the parameters. This + /// Record contains values to replace the parameter tokens in the SQL query. + /// the View could not be executed + /// the View handle is invalid + ///

+ /// Win32 MSI API: + /// MsiViewExecute + ///

+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Params"), SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public void Execute(Record executeParams) + { + uint ret = RemotableNativeMethods.MsiViewExecute( + (int) this.Handle, + (executeParams != null ? (int) executeParams.Handle : 0)); + if (ret == (uint) NativeMethods.Error.BAD_QUERY_SYNTAX) + { + throw new BadQuerySyntaxException(this.sql); + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Executes a SQL View query. + /// + /// the View could not be executed + /// the View handle is invalid + ///

+ /// Win32 MSI API: + /// MsiViewExecute + ///

+ public void Execute() { this.Execute(null); } + + /// + /// Fetches the next sequential record from the view, or null if there are no more records. + /// + /// the View is not in an active state + /// the View handle is invalid + ///

+ /// The Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + ///

+ /// Win32 MSI API: + /// MsiViewFetch + ///

+ public Record Fetch() + { + int recordHandle; + uint ret = RemotableNativeMethods.MsiViewFetch((int) this.Handle, out recordHandle); + if (ret == (uint) NativeMethods.Error.NO_MORE_ITEMS) + { + return null; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + Record r = new Record((IntPtr) recordHandle, true, this); + r.IsFormatStringInvalid = true; + return r; + } + + /// + /// Updates a fetched Record. + /// + /// specifies the modify mode + /// the Record to modify + /// the modification failed, + /// or a validation was requested and the data did not pass + /// the View handle is invalid + ///

+ /// You can update or delete a record immediately after inserting, or seeking provided you + /// have NOT modified the 0th field of the inserted or sought record. + ///

+ /// To execute any SQL statement, a View must be created. However, a View that does not + /// create a result set, such as CREATE TABLE, or INSERT INTO, cannot be used with any of + /// the Modify methods to update tables though the view. + ///

+ /// You cannot fetch a record containing binary data from one database and then use + /// that record to insert the data into another database. To move binary data from one database + /// to another, you should export the data to a file and then import it into the new database + /// using a query and the . This ensures that each database has + /// its own copy of the binary data. + ///

+ /// Note that custom actions can only add, modify, or remove temporary rows, columns, + /// or tables from a database. Custom actions cannot modify persistent data in a database, + /// such as data that is a part of the database stored on disk. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public void Modify(ViewModifyMode mode, Record record) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + uint ret = RemotableNativeMethods.MsiViewModify((int) this.Handle, (int) mode, (int) record.Handle); + if (mode == ViewModifyMode.Insert || mode == ViewModifyMode.InsertTemporary) + { + record.IsFormatStringInvalid = true; + } + if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + } + + /// + /// Refreshes the data in a Record. + /// + /// the Record to be refreshed + /// the refresh failed + /// the View handle is invalid + ///

+ /// The Record must have been obtained by calling . Fails with + /// a deleted Record. Works only with read-write Records. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Refresh(Record record) { this.Modify(ViewModifyMode.Refresh, record); } + + /// + /// Inserts a Record into the view. + /// + /// the Record to be inserted + /// the insertion failed + /// the View handle is invalid + ///

+ /// Fails if a row with the same primary keys exists. Fails with a read-only database. + /// This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Insert(Record record) { this.Modify(ViewModifyMode.Insert, record); } + + /// + /// Updates the View with new data from the Record. + /// + /// the new data + /// the update failed + /// the View handle is invalid + ///

+ /// Only non-primary keys can be updated. The Record must have been obtained by calling + /// . Fails with a deleted Record. Works only with read-write Records. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Update(Record record) { this.Modify(ViewModifyMode.Update, record); } + + /// + /// Updates or inserts a Record into the View. + /// + /// the Record to be assigned + /// the assignment failed + /// the View handle is invalid + ///

+ /// Updates record if the primary keys match an existing row and inserts if they do not match. + /// Fails with a read-only database. This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Assign(Record record) { this.Modify(ViewModifyMode.Assign, record); } + + /// + /// Updates or deletes and inserts a Record into the View. + /// + /// the Record to be replaced + /// the replacement failed + /// the View handle is invalid + ///

+ /// The Record must have been obtained by calling . Updates record if the + /// primary keys are unchanged. Deletes old row and inserts new if primary keys have changed. + /// Fails with a read-only database. This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Replace(Record record) { this.Modify(ViewModifyMode.Replace, record); } + + /// + /// Deletes a Record from the View. + /// + /// the Record to be deleted + /// the deletion failed + /// the View handle is invalid + ///

+ /// The Record must have been obtained by calling . Fails if the row has been + /// deleted. Works only with read-write records. This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void Delete(Record record) { this.Modify(ViewModifyMode.Delete, record); } + + /// + /// Inserts a Record into the View. The inserted data is not persistent. + /// + /// the Record to be inserted + /// the insertion failed + /// the View handle is invalid + ///

+ /// Fails if a row with the same primary key exists. Works only with read-write records. + /// This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ public void InsertTemporary(Record record) { this.Modify(ViewModifyMode.InsertTemporary, record); } + + /// + /// Refreshes the information in the supplied record without changing the position + /// in the result set and without affecting subsequent fetch operations. + /// + /// the Record to be filled with the result of the seek + /// the seek failed + /// the View handle is invalid + ///

+ /// After seeking, the Record may then be used for subsequent Update, Delete, and Refresh + /// operations. All primary key columns of the table must be in the query and the Record must + /// have at least as many fields as the query. Seek cannot be used with multi-table queries. + /// This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public bool Seek(Record record) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + uint ret = RemotableNativeMethods.MsiViewModify((int) this.Handle, (int) ViewModifyMode.Seek, (int) record.Handle); + record.IsFormatStringInvalid = true; + if (ret == (uint) NativeMethods.Error.FUNCTION_FAILED) + { + return false; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + + return true; + } + + /// + /// Inserts or validates a record. + /// + /// the Record to be merged + /// true if the record was inserted or validated, false if there is an existing + /// record with the same primary keys that is not identical + /// the merge failed (for a reason other than invalid data) + /// the View handle is invalid + ///

+ /// Works only with read-write records. This method cannot be used with a + /// View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI API: + /// MsiViewModify + ///

+ [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] + public bool Merge(Record record) + { + if (record == null) + { + throw new ArgumentNullException("record"); + } + + uint ret = RemotableNativeMethods.MsiViewModify((int) this.Handle, (int) ViewModifyMode.Merge, (int) record.Handle); + if (ret == (uint) NativeMethods.Error.FUNCTION_FAILED) + { + return false; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return true; + } + + /// + /// Validates a record, returning information about any errors. + /// + /// the Record to be validated + /// null if the record was validated; if there is an existing record with + /// the same primary keys that has conflicting data then error information is returned + /// the validation failed (for a reason other than invalid data) + /// the View handle is invalid + ///

+ /// The Record must have been obtained by calling . + /// Works with read-write and read-only records. This method cannot be used + /// with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI APIs: + /// MsiViewModify, + /// MsiViewGetError + ///

+ public ICollection Validate(Record record) { return this.InternalValidate(ViewModifyMode.Validate, record); } + + /// + /// Validates a new record, returning information about any errors. + /// + /// the Record to be validated + /// null if the record was validated; if there is an existing + /// record with the same primary keys then error information is returned + /// the validation failed (for a reason other than invalid data) + /// the View handle is invalid + ///

+ /// Checks for duplicate keys. The Record must have been obtained by + /// calling . Works with read-write and read-only records. + /// This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI APIs: + /// MsiViewModify, + /// MsiViewGetError + ///

+ [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] + public ICollection ValidateNew(Record record) { return this.InternalValidate(ViewModifyMode.ValidateNew, record); } + + /// + /// Validates fields of a fetched or new record, returning information about any errors. + /// Can validate one or more fields of an incomplete record. + /// + /// the Record to be validated + /// null if the record was validated; if there is an existing record with + /// the same primary keys that has conflicting data then error information is returned + /// the validation failed (for a reason other than invalid data) + /// the View handle is invalid + ///

+ /// Works with read-write and read-only records. This method cannot be used with + /// a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI APIs: + /// MsiViewModify, + /// MsiViewGetError + ///

+ public ICollection ValidateFields(Record record) { return this.InternalValidate(ViewModifyMode.ValidateField, record); } + + /// + /// Validates a record that will be deleted later, returning information about any errors. + /// + /// the Record to be validated + /// null if the record is safe to delete; if another row refers to + /// the primary keys of this row then error information is returned + /// the validation failed (for a reason other than invalid data) + /// the View handle is invalid + ///

+ /// Validation does not check for the existence of the primary keys of this row in properties + /// or strings. Does not check if a column is a foreign key to multiple tables. Works with + /// read-write and read-only records. This method cannot be used with a View containing joins. + ///

+ /// See for more remarks. + ///

+ /// Win32 MSI APIs: + /// MsiViewModify, + /// MsiViewGetError + ///

+ public ICollection ValidateDelete(Record record) { return this.InternalValidate(ViewModifyMode.ValidateDelete, record); } + + /// + /// Enumerates over the Records retrieved by the View. + /// + /// An enumerator of Record objects. + /// The View was not d before attempting the enumeration. + ///

+ /// Each Record object should be d after use. + /// It is best that the handle be closed manually as soon as it is no longer + /// needed, as leaving lots of unused handles open can degrade performance. + /// However, note that it is not necessary to complete the enumeration just + /// for the purpose of closing handles, because Records are fetched lazily + /// on each step of the enumeration. + ///

+ /// Win32 MSI API: + /// MsiViewFetch + ///

+ public IEnumerator GetEnumerator() + { + Record rec; + while ((rec = this.Fetch()) != null) + { + yield return rec; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + private ICollection InternalValidate(ViewModifyMode mode, Record record) + { + uint ret = RemotableNativeMethods.MsiViewModify((int) this.Handle, (int) mode, (int) record.Handle); + if (ret == (uint) NativeMethods.Error.INVALID_DATA) + { + ICollection errorInfo = new List(); + while (true) + { + uint bufSize = 40; + StringBuilder column = new StringBuilder("", (int) bufSize); + int error = RemotableNativeMethods.MsiViewGetError((int) this.Handle, column, ref bufSize); + if (error == -2 /*MSIDBERROR_MOREDATA*/) + { + column.Capacity = (int) ++bufSize; + error = RemotableNativeMethods.MsiViewGetError((int) this.Handle, column, ref bufSize); + } + + if (error == -3 /*MSIDBERROR_INVALIDARG*/) + { + throw InstallerException.ExceptionFromReturnCode((uint) NativeMethods.Error.INVALID_PARAMETER); + } + else if (error == 0 /*MSIDBERROR_NOERROR*/) + { + break; + } + + errorInfo.Add(new ValidationErrorInfo((ValidationError) error, column.ToString())); + } + + return errorInfo; + } + else if (ret != 0) + { + throw InstallerException.ExceptionFromReturnCode(ret); + } + return null; + } + } +} diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/WindowsInstaller.cd b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/WindowsInstaller.cd new file mode 100644 index 00000000..01b68153 --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/WindowsInstaller.cd @@ -0,0 +1,943 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QABACUgAACAAIAVUIAgQREACAAIAk0ABAIhmoEAAAAA= + Database.cs + + + + + + + + + + + + + + AAAAAAAAACAAAACAgAAAAAAAAAAAAMIAAAACAACAAAA= + Handle.cs + + + + + + + + + IAQBiIgAgAKAAAAELEAAPBgJAUAAYAAAAOQDagAgAQE= + ExternalUIHandler.cs + + + + + + + + + + + + + + + + AIAAAAAAAAAAAIAEiEIAJAAAAQgIEIAIIQCAAABIAAA= + Record.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAAAEAAAKGAAAoDADIBBAAAAAAgIEABBEIAAIAAACAA= + Session.cs + + + + + + + + + + + + + + + + + + + + + + + AQAAAAAAAEAAAEAAjMgAAJIAAAEAAAAAAAAEhAAAoCI= + SummaryInfo.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICQAIEQAAEDgABRACQEAQECBAAEAAQAACAAAAAgAACA= + View.cs + + + + + + + + + + + + + + + + + + + + + + + + + AAAAAAAAAEAAAAAEACAAAAQAQAAEAAAASAAAAAgAAAA= + TableInfo.cs + + + + + + + + + + + AgAAAAAAAAAAgCAEEIAAABQgQAAFIAAAAQAAAAIAEAA= + ColumnInfo.cs + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAA= + CustomActionAttribute.cs + + + + + + + + + + + + + + + + + + AAACIhAAAoAQAACACAAAAABAAAAAAAAAAAAEAAAAAAA= + Installation.cs + + + + + + + + + + + + + + + + + + + + + + + AAAiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAIgA= + InstallationPart.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UAIEYrAGAAAACQBAKEABAAoASA0ARQAASUIGBAAIIAA= + ProductInstallation.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAAgsgCACAAAAAAAKEAAAgAAAgAAAAAAAgIAFAAAIAA= + PatchInstallation.cs + + + + + + + + + + + + + + + + ComponentInstallation.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AUAAAAACAAAAAAIAEAgQAAQAAAAAAAAEAAAABAAAAAA= + ComponentInstallation.cs + + + + + + + + + + + + + + + + + FeatureInstallation.cs + + + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAEAAAAACAAAAAABAAAAAA= + FeatureInstallation.cs + + + + + + + + + + + + + + + + + + BCIAAEAAEABAABgQCAAABIQAAFAQAAAAAAAABARwIgA= + SourceList.cs + + + + + + + + + + + + AQAAAAIAAAAAAAAAAAEAACQAAAAEAAAAAAAAAAAAAAA= + ComponentInfo.cs + + + + + + + + AQAAAAIAAAggAEAAAAEAACQQAAAEAAAAAAAAAAAAAAA= + FeatureInfo.cs + + + + + + + + hAAAAAAAAAAAAAQAAAAAAAAgAAgIAAAIAAABIAAAQAA= + Exceptions.cs + + + + + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Exceptions.cs + + + + + + + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Exceptions.cs + + + + + + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Exceptions.cs + + + + + + + + + + + + + + AAAAAAAAAAAAAEAAEABAABAgAAAAAAAAAAAAIAAAAAA= + Exceptions.cs + + + + + + + + AgAAAAAAAAAAAAAAAgAAIAAAACAAAAAEAAAABAAAAAA= + MediaDisk.cs + + + + + + + + AAAAAAAAAgAAAAIAAAAACBAAAAgQAAAAAAAAAAAAAAA= + InstallCost.cs + + + + + + + + AAAgAAACAAAAAAAAgAAAAAAAAAAAAIAIAAIACAAAIiA= + ShortcutTarget.cs + + + + + + AAAAAAAAAAAAAAQgAAAAAAAAAgAAAACAAAAAAAACAAA= + Enums.cs + + + + + + AADAAlQAAAEgAoNFAAgAACAgAQAAAooMAAAAgCkCAkA= + ColumnEnums.cs + + + + + + AABCCFAAAAAhJAAHAAAAAoAAAAAAAAABCAIEEQEAgAA= + ColumnEnums.cs + + + + + + AAAKAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAYAAAAAAA= + Enums.cs + + + + + + AAABgEBAAIAAAQBAAAAAABEAAQAAABSAgAAEAEWQAAA= + Enums.cs + + + + + + AAABgABAAAAAAQBAAAAAABEAAQAAABSAgAAEAECAAAA= + Enums.cs + + + + + + AAAABAAAQAAAAAAAAAAAIAAAACAAAAAAAAAAAAAAAAA= + Enums.cs + + + + + + AAgAIEACAAQAAAQCAAAAAQAACEAABAQAgAECAAAAAgA= + Enums.cs + + + + + + AAAAABAAAgAAAFACgACQJAAAAABQAAQAAAAAAAAAABA= + Enums.cs + + + + + + AAAAAAAAAAAAAAAAIAAAIAAAAAAAAAAAAgAAAAAAAAA= + Enums.cs + + + + + + AAAAAAAIACAAAAAAQAAAIACEAAAAAAAAAgIAAAGAAAA= + Enums.cs + + + + + + AAAAAAAASAAQASBAAAAAAAAAACAAAAAAAAABAAEAAAA= + Enums.cs + + + + + + IAAAAAAAAACAAAAAAAAQAAAQBAAAABAAAAEAAgAIABA= + Enums.cs + + + + + + AAIEAAAAAAABAAAAAAAAAAQAAAAAAAACAAAgAAEAABA= + Enums.cs + + + + + + AAACAAAACAQIAAAAAAAAAAAAAEgAAAQAAIAQAQEAAAQ= + Enums.cs + + + + + + AAAAAAgAAAAAAAAEAAAAAAIAAAAAAAAAAIAAQAEAAAA= + Enums.cs + + + + + + oCMBAAABEAMAAAAAAAAQAAIASigAABKBABgCgEEAAA4= + Enums.cs + + + + + + IAQAAEQAAADgAAAACAAAAACAAAEAAQAAAAAAAAAAACA= + Enums.cs + + + + + + AAABAAAAIAAAAAAAEAAACAAAIAAAgQCAAAAgAAEAAAA= + ColumnEnums.cs + + + + + + AAAIAAQAAAAAAQIEAAAAACAAEAAAAAAIgAAggAAAAgA= + ColumnEnums.cs + + + + + + AAAAQEAAAEAAAAAAAAAAAAAAEAAAAAABABAAAAEAAAA= + ColumnEnums.cs + + + + + + AAAAAABAAIAIAAAAAAAAAgAAAAAEAAAAAAEIAAEEAAA= + ColumnEnums.cs + + + + + + AggAAAAAAAAAEAEAAAAAAAAAAAABAAAAAAAAAAAAAAA= + ColumnEnums.cs + + + + + + ABAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAABAAAA= + ColumnEnums.cs + + + + + + AACgACAAAIAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAA= + ColumnEnums.cs + + + + + + AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAACAAAEAAAA= + ColumnEnums.cs + + + + + + AQCAAAAAQAAAAAAAAACAAAgAAAAAAAAAAgAAABEAAAI= + ColumnEnums.cs + + + + + + AAAAAAAAACAAAAAAAAAAEAAAAAEAAgAAJAAAAAEAAAA= + ColumnEnums.cs + + + + + + AAAAAAAAAAAAACAAAIAAAAAAAAACAAAAAAAAAAAAAAE= + ColumnEnums.cs + + + + + + AEAAAAAAAAAAAAAQAAAAAAAAAAgIAAAAABAAAAAAIAA= + ColumnEnums.cs + + + + + + AAAAAAAAAACAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAA= + Installer.cs + + + + + + AAAEAAAAAAAAABAAAAAABAAAAACBAAAAAAAAAAAAAAA= + ExternalUIHandler.cs + + + + + + AAAEAAAAAAAAAAAAAAAABAAAAACBAAAAAAAAAAAAAAA= + ExternalUIHandler.cs + + + + \ No newline at end of file diff --git a/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/customactiondata.cs b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/customactiondata.cs new file mode 100644 index 00000000..88a0295d --- /dev/null +++ b/BurnOutSharp/External/WixToolset/WixToolset.Dtf.WindowsInstaller/customactiondata.cs @@ -0,0 +1,469 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Dtf.WindowsInstaller +{ + using System; + using System.IO; + using System.Xml; + using System.Xml.Serialization; + using System.Text; + using System.Collections.Generic; + using System.Globalization; + using System.Diagnostics.CodeAnalysis; + + /// + /// Contains a collection of key-value pairs suitable for passing between + /// immediate and deferred/rollback/commit custom actions. + /// + /// + /// Call the method to get a string + /// suitable for storing in a property and reconstructing the custom action data later. + /// + /// + /// + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + public sealed class CustomActionData : IDictionary + { + /// + /// "CustomActionData" literal property name. + /// + public const string PropertyName = "CustomActionData"; + + private const char DataSeparator = ';'; + private const char KeyValueSeparator = '='; + + private IDictionary data; + + /// + /// Creates a new empty custom action data object. + /// + public CustomActionData() : this(null) + { + } + + /// + /// Reconstructs a custom action data object from data that was previously + /// persisted in a string. + /// + /// Previous output from . + public CustomActionData(string keyValueList) + { + this.data = new Dictionary(); + + if (keyValueList != null) + { + this.Parse(keyValueList); + } + } + + /// + /// Adds a key and value to the data collection. + /// + /// Case-sensitive data key. + /// Data value (may be null). + /// the key does not consist solely of letters, + /// numbers, and the period, underscore, and space characters. + public void Add(string key, string value) + { + CustomActionData.ValidateKey(key); + this.data.Add(key, value); + } + + /// + /// Adds a value to the data collection, using XML serialization to persist the object as a string. + /// + /// Case-sensitive data key. + /// Data value (may be null). + /// the key does not consist solely of letters, + /// numbers, and the period, underscore, and space characters. + /// The value type does not support XML serialization. + /// The value could not be serialized. + public void AddObject(string key, T value) + { + if (value == null) + { + this.Add(key, null); + } + else if (typeof(T) == typeof(string) || + typeof(T) == typeof(CustomActionData)) // Serialize nested CustomActionData + { + this.Add(key, value.ToString()); + } + else + { + string valueString = CustomActionData.Serialize(value); + this.Add(key, valueString); + } + } + + /// + /// Gets a value from the data collection, using XML serialization to load the object from a string. + /// + /// Case-sensitive data key. + /// The value could not be deserialized. + [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")] + public T GetObject(string key) + { + string value = this[key]; + if (value == null) + { + return default(T); + } + else if (typeof(T) == typeof(string)) + { + // Funny casting because the compiler doesn't know T is string here. + return (T) (object) value; + } + else if (typeof(T) == typeof(CustomActionData)) + { + // Deserialize nested CustomActionData. + return (T) (object) new CustomActionData(value); + } + else if (value.Length == 0) + { + return default(T); + } + else + { + return CustomActionData.Deserialize(value); + } + } + + /// + /// Determines whether the data contains an item with the specified key. + /// + /// Case-sensitive data key. + /// true if the data contains an item with the key; otherwise, false + public bool ContainsKey(string key) + { + return this.data.ContainsKey(key); + } + + /// + /// Gets a collection object containing all the keys of the data. + /// + public ICollection Keys + { + get + { + return this.data.Keys; + } + } + + /// + /// Removes the item with the specified key from the data. + /// + /// Case-sensitive data key. + /// true if the item was successfully removed from the data; + /// false if an item with the specified key was not found + public bool Remove(string key) + { + return this.data.Remove(key); + } + + /// + /// Gets the value with the specified key. + /// + /// Case-sensitive data key. + /// Value associated with the specified key, or + /// null if an item with the specified key was not found + /// true if the data contains an item with the specified key; otherwise, false. + public bool TryGetValue(string key, out string value) + { + return this.data.TryGetValue(key, out value); + } + + /// + /// Gets a collection containing all the values of the data. + /// + public ICollection Values + { + get + { + return this.data.Values; + } + } + + /// + /// Gets or sets a data value with a specified key. + /// + /// Case-sensitive data key. + /// the key does not consist solely of letters, + /// numbers, and the period, underscore, and space characters. + public string this[string key] + { + get + { + return this.data[key]; + } + set + { + CustomActionData.ValidateKey(key); + this.data[key] = value; + } + } + + /// + /// Adds an item with key and value to the data collection. + /// + /// Case-sensitive data key, with a data value that may be null. + /// the key does not consist solely of letters, + /// numbers, and the period, underscore, and space characters. + public void Add(KeyValuePair item) + { + CustomActionData.ValidateKey(item.Key); + this.data.Add(item); + } + + /// + /// Removes all items from the data. + /// + public void Clear() + { + if (this.data.Count > 0) + { + this.data.Clear(); + } + } + + /// + /// Determines whether the data contains a specified item. + /// + /// The data item to locate. + /// true if the data contains the item; otherwise, false + public bool Contains(KeyValuePair item) + { + return this.data.Contains(item); + } + + /// + /// Copies the data to an array, starting at a particular array index. + /// + /// Destination array. + /// Index in the array at which copying begins. + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + this.data.CopyTo(array, arrayIndex); + } + + /// + /// Gets the number of items in the data. + /// + public int Count + { + get + { + return this.data.Count; + } + } + + /// + /// Gets a value indicating whether the data is read-only. + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Removes an item from the data. + /// + /// The item to remove. + /// true if the item was successfully removed from the data; + /// false if the item was not found + public bool Remove(KeyValuePair item) + { + return this.data.Remove(item); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// An enumerator that can be used to iterate through the collection. + public IEnumerator> GetEnumerator() + { + return this.data.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// An enumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return ((System.Collections.IEnumerable) this.data).GetEnumerator(); + } + + /// + /// Gets a string representation of the data suitable for persisting in a property. + /// + /// Data string in the form "Key1=Value1;Key2=Value2" + public override string ToString() + { + StringBuilder buf = new StringBuilder(); + + foreach (KeyValuePair item in this.data) + { + if (buf.Length > 0) + { + buf.Append(CustomActionData.DataSeparator); + } + + buf.Append(item.Key); + + if (item.Value != null) + { + buf.Append(CustomActionData.KeyValueSeparator); + buf.Append(CustomActionData.Escape(item.Value)); + } + } + + return buf.ToString(); + } + + /// + /// Ensures that a key contains valid characters. + /// + /// key to be validated + /// the key does not consist solely of letters, + /// numbers, and the period, underscore, and space characters. + private static void ValidateKey(string key) + { + if (String.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + + for (int i = 0; i < key.Length; i++) + { + char c = key[i]; + if (!Char.IsLetterOrDigit(c) && c != '_' && c != '.' && + !(i > 0 && i < key.Length - 1 && c == ' ')) + { + throw new ArgumentOutOfRangeException("key"); + } + } + } + + /// + /// Serializes a value into an XML string. + /// + /// Type of the value. + /// Value to be serialized. + /// Serialized value data as a string. + private static string Serialize(T value) + { + XmlWriterSettings xws = new XmlWriterSettings(); + xws.OmitXmlDeclaration = true; + + StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); + using (XmlWriter xw = XmlWriter.Create(sw, xws)) + { + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add(string.Empty, String.Empty); // Prevent output of any namespaces + + XmlSerializer ser = new XmlSerializer(typeof(T)); + ser.Serialize(xw, value, ns); + + return sw.ToString(); + } + } + + /// + /// Deserializes a value from an XML string. + /// + /// Expected type of the value. + /// Serialized value data. + /// Deserialized value object. + private static T Deserialize(string value) + { + StringReader sr = new StringReader(value); + using (XmlReader xr = XmlReader.Create(sr)) + { + XmlSerializer ser = new XmlSerializer(typeof(T)); + return (T) ser.Deserialize(xr); + } + } + + /// + /// Escapes a value string by doubling any data-separator (semicolon) characters. + /// + /// + /// Escaped value string + private static string Escape(string value) + { + value = value.Replace(String.Empty + CustomActionData.DataSeparator, String.Empty + CustomActionData.DataSeparator + CustomActionData.DataSeparator); + return value; + } + + /// + /// Unescapes a value string by undoubling any doubled data-separator (semicolon) characters. + /// + /// + /// Unescaped value string + private static string Unescape(string value) + { + value = value.Replace(String.Empty + CustomActionData.DataSeparator + CustomActionData.DataSeparator, String.Empty + CustomActionData.DataSeparator); + return value; + } + + /// + /// Loads key-value pairs from a string into the data collection. + /// + /// key-value pair list of the form returned by + private void Parse(string keyValueList) + { + int itemStart = 0; + while (itemStart < keyValueList.Length) + { + // Find the next non-escaped data separator. + int semi = itemStart - 2; + do + { + semi = keyValueList.IndexOf(CustomActionData.DataSeparator, semi + 2); + } + while (semi >= 0 && semi < keyValueList.Length - 1 && keyValueList[semi + 1] == CustomActionData.DataSeparator); + + if (semi < 0) + { + semi = keyValueList.Length; + } + + // Find the next non-escaped key-value separator. + int equals = itemStart - 2; + do + { + equals = keyValueList.IndexOf(CustomActionData.KeyValueSeparator, equals + 2); + } + while (equals >= 0 && equals < keyValueList.Length - 1 && keyValueList[equals + 1] == CustomActionData.KeyValueSeparator); + + if (equals < 0 || equals > semi) + { + equals = semi; + } + + string key = keyValueList.Substring(itemStart, equals - itemStart); + string value = null; + + // If there's a key-value separator before the next data separator, then the item has a value. + if (equals < semi) + { + value = keyValueList.Substring(equals + 1, semi - (equals + 1)); + value = CustomActionData.Unescape(value); + } + + // Add non-duplicate items to the collection. + if (key.Length > 0 && !this.data.ContainsKey(key)) + { + this.data.Add(key, value); + } + + // Move past the data separator to the next item. + itemStart = semi + 1; + } + } + } +} diff --git a/BurnOutSharp/FileType/MSI.cs b/BurnOutSharp/FileType/MSI.cs index 9c129e2f..23dd897d 100644 --- a/BurnOutSharp/FileType/MSI.cs +++ b/BurnOutSharp/FileType/MSI.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.IO; -#if NET_FRAMEWORK -using Microsoft.Deployment.WindowsInstaller; -#endif +using WixToolset.Dtf.WindowsInstaller; namespace BurnOutSharp.FileType { @@ -12,10 +10,8 @@ namespace BurnOutSharp.FileType /// public bool ShouldScan(byte[] magic) { -#if NET_FRAMEWORK if (magic.StartsWith(new byte[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 })) return true; -#endif return false; } @@ -36,7 +32,6 @@ namespace BurnOutSharp.FileType /// public Dictionary> Scan(Scanner scanner, Stream stream, string file) { -#if NET_FRAMEWORK // If the MSI file itself fails try { @@ -64,7 +59,6 @@ namespace BurnOutSharp.FileType return protections; } catch { } -#endif return null; } diff --git a/BurnOutSharp/FileType/MicrosoftCAB.cs b/BurnOutSharp/FileType/MicrosoftCAB.cs index 15af2669..a2c46205 100644 --- a/BurnOutSharp/FileType/MicrosoftCAB.cs +++ b/BurnOutSharp/FileType/MicrosoftCAB.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.IO; -#if NET_FRAMEWORK using LibMSPackN; -#endif namespace BurnOutSharp.FileType { @@ -13,10 +11,8 @@ namespace BurnOutSharp.FileType /// public bool ShouldScan(byte[] magic) { -#if NET_FRAMEWORK if (magic.StartsWith(new byte[] { 0x4d, 0x53, 0x43, 0x46 })) return true; -#endif return false; } @@ -37,7 +33,6 @@ namespace BurnOutSharp.FileType /// public Dictionary> Scan(Scanner scanner, Stream stream, string file) { -#if NET_FRAMEWORK // If the cab file itself fails try { @@ -75,7 +70,6 @@ namespace BurnOutSharp.FileType return protections; } catch { } -#endif return null; } diff --git a/README.md b/README.md index cb875671..dedcb629 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ In addition to the original BurnOut code, the following libraries (or ports ther - [StormLibSharp](https://github.com/robpaveza/stormlibsharp) - MPQ extraction - [UnshieldSharp](https://github.com/mnadareski/UnshieldSharp) - InstallShield CAB extraction - [WiseUnpacker](https://github.com/mnadareski/WiseUnpacker) - Wise Installer extraction -- [wix-libs](https://wixtoolset.org/) - MSI extraction +- [WixToolset.Dtf](https://github.com/wixtoolset/Dtf) - MSI extraction ## Protections Detected @@ -105,7 +105,7 @@ Below is a list of archive or archive-like formats that can be extracted and hav - InstallShield CAB - Microsoft CAB - MPQ -- Microsoft Installer (MSI) (.NET Framework 4.7.2 and 4.8 only) +- Microsoft Installer (MSI) - PKZIP and derived files - RAR - TAR