/// <summary> /// Decompile the WixHttpUrlAce table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileWixHttpUrlAceTable(Table table) { foreach (Row row in table.Rows) { Http.UrlAce urlace = new Http.UrlAce(); urlace.Id = (string)row[0]; urlace.SecurityPrincipal = (string)row[2]; switch (Convert.ToInt32(row[3])) { case HttpConstants.GENERIC_ALL: default: urlace.Rights = Http.UrlAce.RightsType.all; break; case HttpConstants.GENERIC_EXECUTE: urlace.Rights = Http.UrlAce.RightsType.register; break; case HttpConstants.GENERIC_WRITE: urlace.Rights = Http.UrlAce.RightsType.@delegate; break; } string reservationId = (string)row[1]; Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId); if (null != urlReservation) { urlReservation.AddChild(urlace); } else { this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation")); } } }
/// <summary> /// Decompile the WixHttpUrlReservation table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileWixHttpUrlReservationTable(Table table) { foreach (Row row in table.Rows) { Http.UrlReservation urlReservation = new Http.UrlReservation(); urlReservation.Id = (string)row[0]; switch((int)row[1]) { case HttpConstants.heReplace: default: urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace; break; case HttpConstants.heIgnore: urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore; break; case HttpConstants.heFail: urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail; break; } urlReservation.Sddl = (string)row[2]; urlReservation.Url = (string)row[3]; Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); if (null != component) { component.AddChild(urlReservation); } else { this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); } this.Core.IndexElement(row, urlReservation); } }
/// <summary> /// Adds a table to the collection. /// </summary> /// <param name="table">Table to add to the collection.</param> /// <remarks>Indexes the table by name.</remarks> public void Add(Table table) { if (null == table) { throw new ArgumentNullException("table"); } this.collection.Add(table.Name, table); }
/// <summary> /// Creates a row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this row belongs to and should get its column definitions from.</param> /// <remarks>The compiler should use this constructor exclusively.</remarks> public Row(SourceLineNumberCollection sourceLineNumbers, Table table) : this(sourceLineNumbers, (null != table ? table.Definition : null)) { if (null == table) { throw new ArgumentNullException("table"); } this.table = table; }
/// <summary> /// Decompile the SoftwareIdentificationTag table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileSoftwareIdentificationTag(Table table) { foreach (Row row in table.Rows) { Tag.Tag tag = new Tag.Tag(); tag.Regid = (string)row[1]; this.Core.RootElement.AddChild(tag); } }
/// <summary> /// Creates a File row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this File row belongs to and should get its column definitions from.</param> public FileRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { this.assemblyType = FileAssemblyType.NotAnAssembly; this.previousSource = new string[1]; this.previousSymbols = new string[1]; this.previousRetainOffsets = new string[1]; this.previousRetainLengths = new string[1]; this.previousIgnoreOffsets = new string[1]; this.previousIgnoreLengths = new string[1]; }
/// <summary> /// Decompiles an extension table. /// </summary> /// <param name="table">The table to decompile.</param> public override void DecompileTable(Table table) { switch (table.Name) { case "SoftwareIdentificationTag": this.DecompileSoftwareIdentificationTag(table); break; default: base.DecompileTable(table); break; } }
/// <summary> /// Decompile the SoftwareIdentificationTag table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileSoftwareIdentificationTag(Table table) { foreach (Row row in table.Rows) { Tag.Tag tag= new Tag.Tag(); tag.Regid = (string)row[1]; tag.Name = (string)row[2]; tag.Licensed = null == row[3] ? Tag.YesNoType.NotSet : 1 == (int)row[3] ? Tag.YesNoType.yes : Tag.YesNoType.no; this.Core.RootElement.AddChild(tag); } }
/// <summary> /// Decompiles an extension table. /// </summary> /// <param name="table">The table to decompile.</param> public override void DecompileTable(Table table) { switch (table.Name) { case "WixHttpUrlReservation": this.DecompileWixHttpUrlReservationTable(table); break; case "WixHttpUrlAce": this.DecompileWixHttpUrlAceTable(table); break; default: base.DecompileTable(table); break; } }
/// <summary> /// Decompile the Verb table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileVerbTable(Table table) { foreach (Row row in table.Rows) { Wix.Verb verb = new Wix.Verb(); verb.Id = Convert.ToString(row[1]); if (null != row[2]) { verb.Sequence = Convert.ToInt32(row[2]); } if (null != row[3]) { verb.Command = Convert.ToString(row[3]); } if (null != row[4]) { verb.Argument = Convert.ToString(row[4]); } this.core.IndexElement(row, verb); } }
/// <summary> /// Reduce the transform according to the patch references. /// </summary> /// <param name="transform">transform generated by torch.</param> /// <param name="patchRefTable">Table contains patch family filter.</param> /// <returns>true if the transform is not empty</returns> public static bool ReduceTransform(Output transform, Table patchRefTable) { // identify sections to keep Hashtable oldSections = new Hashtable(patchRefTable.Rows.Count); Hashtable newSections = new Hashtable(patchRefTable.Rows.Count); Hashtable tableKeyRows = new Hashtable(); ArrayList sequenceList = new ArrayList(); Hashtable componentFeatureAddsIndex = new Hashtable(); Hashtable customActionTable = new Hashtable(); Hashtable directoryTableAdds = new Hashtable(); Hashtable featureTableAdds = new Hashtable(); ArrayList keptComponentTableAdds = new ArrayList(); Hashtable keptDirectories = new Hashtable(); Hashtable keptFeatures = new Hashtable(); foreach (Row patchRefRow in patchRefTable.Rows) { string tableName = (string)patchRefRow[0]; string key = (string)patchRefRow[1]; Table table = transform.Tables[tableName]; if (table == null) { // table not found continue; } // index this table if (!tableKeyRows.Contains(tableName)) { Hashtable newKeyRows = new Hashtable(); foreach (Row newRow in table.Rows) { newKeyRows[newRow.GetPrimaryKey('/')] = newRow; } tableKeyRows[tableName] = newKeyRows; } Hashtable keyRows = (Hashtable)tableKeyRows[tableName]; Row row = (Row)keyRows[key]; if (row == null) { // row not found continue; } // Differ.sectionDelimiter string[] sections = row.SectionId.Split('/'); oldSections[sections[0]] = row; newSections[sections[1]] = row; } // throw away sections not referenced int keptRows = 0; Table directoryTable = null; Table featureTable = null; foreach (Table table in transform.Tables) { if ("_SummaryInformation" == table.Name) { continue; } if (table.Name == "AdminExecuteSequence" || table.Name == "AdminUISequence" || table.Name == "AdvtExecuteSequence" || table.Name == "InstallUISequence" || table.Name == "InstallExecuteSequence") { sequenceList.Add(table); continue; } for (int i = 0; i < table.Rows.Count; i++) { Row row = table.Rows[i]; if (table.Name == "CustomAction") { customActionTable.Add(row[0], row); } if (table.Name == "Directory") { directoryTable = table; if (RowOperation.Add == row.Operation) { directoryTableAdds.Add(row[0], row); } } if (table.Name == "Feature") { featureTable = table; if (RowOperation.Add == row.Operation) { featureTableAdds.Add(row[0], row); } } if (table.Name == "FeatureComponents") { if (RowOperation.Add == row.Operation) { string featureId = (string)row[0]; string componentId = (string)row[1]; if (componentFeatureAddsIndex.ContainsKey(componentId)) { ArrayList featureList = (ArrayList)componentFeatureAddsIndex[componentId]; featureList.Add(featureId); } else { ArrayList featureList = new ArrayList(); componentFeatureAddsIndex.Add(componentId, featureList); featureList.Add(featureId); } } } if (null == row.SectionId) { table.Rows.RemoveAt(i); i--; } else { string[] sections = row.SectionId.Split('/'); // ignore the row without section id. if (0 == sections[0].Length && 0 == sections[1].Length) { table.Rows.RemoveAt(i); i--; } else if (IsInPatchFamily(sections[0], sections[1], oldSections, newSections)) { if ("Component" == table.Name) { if (RowOperation.Add == row.Operation) { keptComponentTableAdds.Add(row); } } if ("Directory" == table.Name) { keptDirectories.Add(row[0], row); } if ("Feature" == table.Name) { keptFeatures.Add(row[0], row); } keptRows++; } else { table.Rows.RemoveAt(i); i--; } } } } keptRows += ReduceTransformSequenceTable(sequenceList, oldSections, newSections, customActionTable); if (null != directoryTable) { foreach (Row componentRow in keptComponentTableAdds) { // make sure each added component has its required directory and feature heirarchy. string directoryId = (string)componentRow[2]; while (null != directoryId && directoryTableAdds.ContainsKey(directoryId)) { Row directoryRow = (Row)directoryTableAdds[directoryId]; if (!keptDirectories.ContainsKey(directoryId)) { directoryTable.Rows.Add(directoryRow); keptDirectories.Add(directoryRow[0], null); keptRows++; } directoryId = (string)directoryRow[1]; } string componentId = (string)componentRow[0]; if (componentFeatureAddsIndex.ContainsKey(componentId)) { foreach (string featureId in (ArrayList)componentFeatureAddsIndex[componentId]) { string currentFeatureId = featureId; while (null != currentFeatureId && featureTableAdds.ContainsKey(currentFeatureId)) { Row featureRow = (Row)featureTableAdds[currentFeatureId]; if (!keptFeatures.ContainsKey(currentFeatureId)) { featureTable.Rows.Add(featureRow); keptFeatures.Add(featureRow[0], null); keptRows++; } currentFeatureId = (string)featureRow[1]; } } } } } keptRows += ReduceTransformSequenceTable(sequenceList, oldSections, newSections, customActionTable); // Delete tables that are empty. ArrayList tablesToDelete = new ArrayList(); foreach (Table table in transform.Tables) { if (0 == table.Rows.Count) { tablesToDelete.Add(table.Name); } } // delete separately to avoid messing up enumeration foreach (string tableName in tablesToDelete) { transform.Tables.Remove(tableName); } return keptRows > 0; }
/// <summary> /// Decompile the UpgradedImages table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileUpgradedImagesTable(Table table) { foreach (Row row in table.Rows) { Wix.UpgradeImage upgradeImage = new Wix.UpgradeImage(); upgradeImage.Id = Convert.ToString(row[0]); upgradeImage.SourceFile = Convert.ToString(row[1]); if (null != row[2]) { upgradeImage.SourcePatch = Convert.ToString(row[2]); } if (null != row[3]) { string[] symbolPaths = (Convert.ToString(row[3])).Split(';'); foreach (string symbolPathString in symbolPaths) { Wix.SymbolPath symbolPath = new Wix.SymbolPath(); symbolPath.Path = symbolPathString; upgradeImage.AddChild(symbolPath); } } Wix.Family family = (Wix.Family)this.core.GetIndexedElement("ImageFamilies", Convert.ToString(row[4])); if (null != family) { family.AddChild(upgradeImage); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Family", Convert.ToString(row[4]), "ImageFamilies")); } this.core.IndexElement(row, upgradeImage); } }
/// <summary> /// Decompile the UIText table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileUITextTable(Table table) { foreach (Row row in table.Rows) { Wix.UIText uiText = new Wix.UIText(); uiText.Id = Convert.ToString(row[0]); uiText.Content = Convert.ToString(row[1]); this.core.UIElement.AddChild(uiText); } }
/// <summary> /// Creates a WixUpdateRegistrationRow row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this WixUpdateRegistrationRow row belongs to and should get its column definitions from.</param> public WixUpdateRegistrationRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { }
/// <summary> /// Decompile the SFPCatalog table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileSFPCatalogTable(Table table) { foreach (Row row in table.Rows) { Wix.SFPCatalog sfpCatalog = new Wix.SFPCatalog(); sfpCatalog.Name = Convert.ToString(row[0]); sfpCatalog.SourceFile = Convert.ToString(row[1]); this.core.IndexElement(row, sfpCatalog); } // nest the SFPCatalog elements foreach (Row row in table.Rows) { Wix.SFPCatalog sfpCatalog = (Wix.SFPCatalog)this.core.GetIndexedElement(row); if (null != row[2]) { Wix.SFPCatalog parentSFPCatalog = (Wix.SFPCatalog)this.core.GetIndexedElement("SFPCatalog", Convert.ToString(row[2])); if (null != parentSFPCatalog) { parentSFPCatalog.AddChild(sfpCatalog); } else { sfpCatalog.Dependency = Convert.ToString(row[2]); this.core.RootElement.AddChild(sfpCatalog); } } else { this.core.RootElement.AddChild(sfpCatalog); } } }
/// <summary> /// Creates a WixBundleRow row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this WixBundleRow row belongs to and should get its column definitions from.</param> public WixBundleRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { }
private void GetUniquePackages(HashSet <string> upgradeCodeHash, HashSet <string> noUpgradeCodeProductCodeHash, Wix.Table chainmsipackageTable, Wix.Table uxPackageBehavior) { try { Dictionary <string, string> uxPackageBehaviorDict = new Dictionary <string, string>(); if (uxPackageBehavior != null) { foreach (Wix.Row msirow in uxPackageBehavior.Rows) { string packageId = string.Empty; string reallyPerm = string.Empty; foreach (Wix.Field field in msirow.Fields) { switch (field.Column.Name.ToString(CultureInfo.InvariantCulture).ToUpperInvariant()) { case "PackageId": packageId = field.Data.ToString(); break; case "ReallyPermanent": // nullable. if (field.Data != null) { reallyPerm = field.Data.ToString(); } break; } } if (!string.IsNullOrEmpty(packageId) && !uxPackageBehaviorDict.ContainsKey(packageId)) { uxPackageBehaviorDict.Add(packageId, reallyPerm); } } } foreach (Wix.Row msirow in chainmsipackageTable.Rows) { var msi = new Package(); foreach (Wix.Field field in msirow.Fields) { switch (field.Column.Name.ToString(CultureInfo.InvariantCulture).ToUpperInvariant()) { case "CHAINPACKAGE_": msi.ChainingPackage = field.Data.ToString(); break; case "PRODUCTCODE": // id 23 msi.ProductCode = field.Data.ToString(); break; case "UPGRADECODE": // nullable. if (field.Data != null) { msi.UpgradeCode = field.Data.ToString(); } break; case "PRODUCTVERSION": msi.ProductVersion = field.Data.ToString(); break; case "PRODUCTNAME": msi.ProductName = field.Data.ToString(); break; case "PACKAGETYPE": msi.Type = Package.PackageType.MSI; break; default: break; } } // if the package is really perm, then, don't uninstall it. if (!string.IsNullOrEmpty(msi.ChainingPackage) && uxPackageBehaviorDict.ContainsKey(msi.ChainingPackage) && uxPackageBehaviorDict[msi.ChainingPackage].Equals("yes", StringComparison.OrdinalIgnoreCase)) { continue; } if (string.IsNullOrEmpty(msi.UpgradeCode)) { noUpgradeCodeProductCodeHash.Add(msi.ProductCode); } else { if (!upgradeCodeHash.Contains(msi.UpgradeCode)) { upgradeCodeHash.Add(msi.UpgradeCode); } } } // We should not be uninstalling MSU because they are usually perm and they are windows comp. } catch (Exception ex) { Logger.Log(ex); } }
/// <summary> /// Decompile the TargetImages table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileTargetImagesTable(Table table) { foreach (Row row in table.Rows) { Wix.TargetImage targetImage = new Wix.TargetImage(); targetImage.Id = Convert.ToString(row[0]); targetImage.SourceFile = Convert.ToString(row[1]); if (null != row[2]) { string[] symbolPaths = (Convert.ToString(row[3])).Split(';'); foreach (string symbolPathString in symbolPaths) { Wix.SymbolPath symbolPath = new Wix.SymbolPath(); symbolPath.Path = symbolPathString; targetImage.AddChild(symbolPath); } } targetImage.Order = Convert.ToInt32(row[4]); if (null != row[5]) { targetImage.Validation = Convert.ToString(row[5]); } if (0 != Convert.ToInt32(row[6])) { targetImage.IgnoreMissingFiles = Wix.YesNoType.yes; } Wix.UpgradeImage upgradeImage = (Wix.UpgradeImage)this.core.GetIndexedElement("UpgradedImages", Convert.ToString(row[3])); if (null != upgradeImage) { upgradeImage.AddChild(targetImage); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Upgraded", Convert.ToString(row[3]), "UpgradedImages")); } this.core.IndexElement(row, targetImage); } }
/// <summary> /// Decompile the ServiceControl table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileServiceControlTable(Table table) { foreach (Row row in table.Rows) { Wix.ServiceControl serviceControl = new Wix.ServiceControl(); serviceControl.Id = Convert.ToString(row[0]); serviceControl.Name = Convert.ToString(row[1]); int eventValue = Convert.ToInt32(row[2]); if (MsiInterop.MsidbServiceControlEventStart == (eventValue & MsiInterop.MsidbServiceControlEventStart) && MsiInterop.MsidbServiceControlEventUninstallStart == (eventValue & MsiInterop.MsidbServiceControlEventUninstallStart)) { serviceControl.Start = Wix.InstallUninstallType.both; } else if (MsiInterop.MsidbServiceControlEventStart == (eventValue & MsiInterop.MsidbServiceControlEventStart)) { serviceControl.Start = Wix.InstallUninstallType.install; } else if (MsiInterop.MsidbServiceControlEventUninstallStart == (eventValue & MsiInterop.MsidbServiceControlEventUninstallStart)) { serviceControl.Start = Wix.InstallUninstallType.uninstall; } if (MsiInterop.MsidbServiceControlEventStop == (eventValue & MsiInterop.MsidbServiceControlEventStop) && MsiInterop.MsidbServiceControlEventUninstallStop == (eventValue & MsiInterop.MsidbServiceControlEventUninstallStop)) { serviceControl.Stop = Wix.InstallUninstallType.both; } else if (MsiInterop.MsidbServiceControlEventStop == (eventValue & MsiInterop.MsidbServiceControlEventStop)) { serviceControl.Stop = Wix.InstallUninstallType.install; } else if (MsiInterop.MsidbServiceControlEventUninstallStop == (eventValue & MsiInterop.MsidbServiceControlEventUninstallStop)) { serviceControl.Stop = Wix.InstallUninstallType.uninstall; } if (MsiInterop.MsidbServiceControlEventDelete == (eventValue & MsiInterop.MsidbServiceControlEventDelete) && MsiInterop.MsidbServiceControlEventUninstallDelete == (eventValue & MsiInterop.MsidbServiceControlEventUninstallDelete)) { serviceControl.Remove = Wix.InstallUninstallType.both; } else if (MsiInterop.MsidbServiceControlEventDelete == (eventValue & MsiInterop.MsidbServiceControlEventDelete)) { serviceControl.Remove = Wix.InstallUninstallType.install; } else if (MsiInterop.MsidbServiceControlEventUninstallDelete == (eventValue & MsiInterop.MsidbServiceControlEventUninstallDelete)) { serviceControl.Remove = Wix.InstallUninstallType.uninstall; } if (null != row[3]) { string[] arguments = NullSplitter.Split(Convert.ToString(row[3])); foreach (string argument in arguments) { Wix.ServiceArgument serviceArgument = new Wix.ServiceArgument(); serviceArgument.Content = argument; serviceControl.AddChild(serviceArgument); } } if (null != row[4]) { if (0 == Convert.ToInt32(row[4])) { serviceControl.Wait = Wix.YesNoType.no; } else { serviceControl.Wait = Wix.YesNoType.yes; } } Wix.Component component = (Wix.Component)this.core.GetIndexedElement("Component", Convert.ToString(row[5])); if (null != component) { component.AddChild(serviceControl); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", Convert.ToString(row[5]), "Component")); } } }
/// <summary> /// Decompile the TargetFiles_OptionalData table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileTargetFiles_OptionalDataTable(Table table) { foreach (Row row in table.Rows) { Wix.TargetFile targetFile = (Wix.TargetFile)this.patchTargetFiles[row[0]]; if (null == targetFile) { targetFile = new Wix.TargetFile(); targetFile.Id = Convert.ToString(row[1]); Wix.TargetImage targetImage = (Wix.TargetImage)this.core.GetIndexedElement("TargetImages", Convert.ToString(row[0])); if (null != targetImage) { targetImage.AddChild(targetFile); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Target", Convert.ToString(row[0]), "TargetImages")); } this.patchTargetFiles.Add(row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), targetFile); } if (null != row[2]) { string[] symbolPaths = (Convert.ToString(row[2])).Split(';'); foreach (string symbolPathString in symbolPaths) { Wix.SymbolPath symbolPath = new Wix.SymbolPath(); symbolPath.Path = symbolPathString; targetFile.AddChild(symbolPath); } } if (null != row[3] && null != row[4]) { string[] ignoreOffsets = (Convert.ToString(row[3])).Split(','); string[] ignoreLengths = (Convert.ToString(row[4])).Split(','); if (ignoreOffsets.Length == ignoreLengths.Length) { for (int i = 0; i < ignoreOffsets.Length; i++) { Wix.IgnoreRange ignoreRange = new Wix.IgnoreRange(); if (ignoreOffsets[i].StartsWith("0x", StringComparison.Ordinal)) { ignoreRange.Offset = Convert.ToInt32(ignoreOffsets[i].Substring(2), 16); } else { ignoreRange.Offset = Convert.ToInt32(ignoreOffsets[i], CultureInfo.InvariantCulture); } if (ignoreLengths[i].StartsWith("0x", StringComparison.Ordinal)) { ignoreRange.Length = Convert.ToInt32(ignoreLengths[i].Substring(2), 16); } else { ignoreRange.Length = Convert.ToInt32(ignoreLengths[i], CultureInfo.InvariantCulture); } targetFile.AddChild(ignoreRange); } } else { // TODO: warn } } else if (null != row[3] || null != row[4]) { // TODO: warn about mismatch between columns } // the RetainOffsets column is handled in FinalizeFamilyFileRangesTable } }
/// <summary> /// Decompile the Signature table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileSignatureTable(Table table) { foreach (Row row in table.Rows) { Wix.FileSearch fileSearch = new Wix.FileSearch(); fileSearch.Id = Convert.ToString(row[0]); string[] names = Installer.GetNames(Convert.ToString(row[1])); if (null != names[0]) { // it is permissable to just have a long name if (!CompilerCore.IsValidShortFilename(names[0], false) && null == names[1]) { fileSearch.Name = names[0]; } else { fileSearch.ShortName = names[0]; } } if (null != names[1]) { fileSearch.LongName = names[1]; } if (null != row[2]) { fileSearch.MinVersion = Convert.ToString(row[2]); } if (null != row[3]) { fileSearch.MaxVersion = Convert.ToString(row[3]); } if (null != row[4]) { fileSearch.MinSize = Convert.ToInt32(row[4]); } if (null != row[5]) { fileSearch.MaxSize = Convert.ToInt32(row[5]); } if (null != row[6]) { fileSearch.MinDate = DecompilerCore.ConvertIntegerToDateTime(Convert.ToInt32(row[6])); } if (null != row[7]) { fileSearch.MaxDate = DecompilerCore.ConvertIntegerToDateTime(Convert.ToInt32(row[7])); } if (null != row[8]) { fileSearch.Languages = Convert.ToString(row[8]); } this.core.IndexElement(row, fileSearch); } }
/// <summary> /// Decompile the Shortcut table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileShortcutTable(Table table) { foreach (Row row in table.Rows) { Wix.Shortcut shortcut = new Wix.Shortcut(); shortcut.Id = Convert.ToString(row[0]); shortcut.Directory = Convert.ToString(row[1]); string[] names = Installer.GetNames(Convert.ToString(row[2])); if (null != names[0] && null != names[1]) { shortcut.ShortName = names[0]; shortcut.Name = names[1]; } else if (null != names[0]) { shortcut.Name = names[0]; } string target = Convert.ToString(row[4]); if (target.StartsWith("[", StringComparison.Ordinal) && target.EndsWith("]", StringComparison.Ordinal)) { // TODO: use this value to do a "more-correct" nesting under the indicated File or CreateDirectory element shortcut.Target = target; } else { shortcut.Advertise = Wix.YesNoType.yes; // primary feature is set in FinalizeFeatureComponentsTable } if (null != row[5]) { shortcut.Arguments = Convert.ToString(row[5]); } if (null != row[6]) { shortcut.Description = Convert.ToString(row[6]); } if (null != row[7]) { shortcut.Hotkey = Convert.ToInt32(row[7]); } if (null != row[8]) { shortcut.Icon = Convert.ToString(row[8]); } if (null != row[9]) { shortcut.IconIndex = Convert.ToInt32(row[9]); } if (null != row[10]) { switch (Convert.ToInt32(row[10])) { case 1: shortcut.Show = Wix.Shortcut.ShowType.normal; break; case 3: shortcut.Show = Wix.Shortcut.ShowType.maximized; break; case 7: shortcut.Show = Wix.Shortcut.ShowType.minimized; break; default: this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[10].Column.Name, row[10])); break; } } if (null != row[11]) { shortcut.WorkingDirectory = Convert.ToString(row[11]); } // Only try to read the MSI 4.0-specific columns if they actually exist if (15 < row.Fields.Length) { if (null != row[12]) { shortcut.DisplayResourceDll = Convert.ToString(row[12]); } if (null != row[13]) { shortcut.DisplayResourceId = Convert.ToInt32(row[13]); } if (null != row[14]) { shortcut.DescriptionResourceDll = Convert.ToString(row[14]); } if (null != row[15]) { shortcut.DescriptionResourceId = Convert.ToInt32(row[15]); } } Wix.Component component = (Wix.Component)this.core.GetIndexedElement("Component", Convert.ToString(row[3])); if (null != component) { component.AddChild(shortcut); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", Convert.ToString(row[3]), "Component")); } this.core.IndexElement(row, shortcut); } }
/// <summary> /// Creates an Upgrade row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this Upgrade row belongs to and should get its column definitions from.</param> public UpgradeRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { }
private static ICollection <Package> GetMSIDataFromTable(Bundle bundle, Wix.Table chainmsipackageTable, Wix.Table cpiTable) { try { foreach (Wix.Row msirow in chainmsipackageTable.Rows) { var msi = new Package(); foreach (Wix.Field field in msirow.Fields) { switch (field.Column.Name.ToString(CultureInfo.InvariantCulture).ToUpperInvariant()) { case "CHAINPACKAGE_": msi.ChainingPackage = field.Data.ToString(); break; case "PRODUCTCODE": // id 23 msi.ProductCode = field.Data.ToString(); break; case "PRODUCTVERSION": msi.ProductVersion = field.Data.ToString(); break; case "PRODUCTNAME": msi.ProductName = field.Data.ToString(); break; case "PACKAGETYPE": msi.Type = Package.PackageType.MSI; break; default: break; } } bundle.Packages.Add(msi); } if (cpiTable != null) { foreach (Wix.Row packageinforow in cpiTable.Rows) { if (packageinforow.Fields[1].Data.ToString().ToUpperInvariant() == "MSU") { var msu = new Package(); foreach (Wix.Field field in packageinforow.Fields) { switch (field.Column.Name.ToString(CultureInfo.InvariantCulture).ToUpperInvariant()) { case "ID": // id 0 msu.ChainingPackage = field.Data.ToString(); break; case "MSUKB": // id 13 msu.ProductCode = field.Data.ToString().Replace("KB", ""); break; case "VERSION": // id 25 msu.ProductVersion = (field.Data != null) ? field.Data.ToString() : ""; break; case "DISPLAYNAME": // id 27 msu.ProductName = (field.Data != null) ? field.Data.ToString() : ""; break; case "PACKAGETYPE": // id 1 msu.Type = Package.PackageType.MSU; break; default: break; } } bundle.Packages.Add(msu); } } } } catch (Exception ex) { Logger.Log(ex); } return(bundle.Packages); }
/// <summary> /// Copies a table's rows to an output table. /// </summary> /// <param name="table">Source table to copy rows from.</param> /// <param name="outputTable">Destination output table to copy rows into.</param> /// <param name="sectionId">Id of the section that the table lives in.</param> private void CopyTableRowsToOutputTable(Table table, OutputTable outputTable, string sectionId) { int[] localizedColumns = new int[table.Columns.Count]; int localizedColumnCount = 0; // if there are localization strings, figure out which columns can be localized in this table if (null != this.localizer) { for (int i = 0; i < table.Columns.Count; i++) { if (table.Columns[i].IsLocalizable) { localizedColumns[localizedColumnCount++] = i; } } } // process each row in the table doing the string resource substitutions // then add the row to the output foreach (Row row in table.Rows) { if (row.IsUnreal) { continue; } // localize all the values for (int i = 0; i < localizedColumnCount; i++) { object val = row[localizedColumns[i]]; if (null != val) { row[localizedColumns[i]] = this.localizer.GetLocalizedValue(val.ToString()); } } outputTable.OutputRows.Add(new OutputRow(row, this.sectionIdOnTuples ? sectionId : null)); } }
/// <summary> /// Decompile the UpgradedFiles_OptionalData table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileUpgradedFiles_OptionalDataTable(Table table) { foreach (Row row in table.Rows) { Wix.UpgradeFile upgradeFile = new Wix.UpgradeFile(); upgradeFile.File = Convert.ToString(row[1]); if (null != row[2]) { string[] symbolPaths = (Convert.ToString(row[2])).Split(';'); foreach (string symbolPathString in symbolPaths) { Wix.SymbolPath symbolPath = new Wix.SymbolPath(); symbolPath.Path = symbolPathString; upgradeFile.AddChild(symbolPath); } } if (null != row[3] && 1 == Convert.ToInt32(row[3])) { upgradeFile.AllowIgnoreOnError = Wix.YesNoType.yes; } if (null != row[4] && 0 != Convert.ToInt32(row[4])) { upgradeFile.WholeFile = Wix.YesNoType.yes; } upgradeFile.Ignore = Wix.YesNoType.no; Wix.UpgradeImage upgradeImage = (Wix.UpgradeImage)this.core.GetIndexedElement("UpgradedImages", Convert.ToString(row[0])); if (null != upgradeImage) { upgradeImage.AddChild(upgradeFile); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Upgraded", Convert.ToString(row[0]), "UpgradedImages")); } } }
/// <summary> /// Creates a Control row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this Control row belongs to and should get its column definitions from.</param> public BBControlRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { }
/// <summary> /// Decompile the UpgradedFilesToIgnore table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileUpgradedFilesToIgnoreTable(Table table) { foreach (Row row in table.Rows) { if ("*" != Convert.ToString(row[0])) { Wix.UpgradeFile upgradeFile = new Wix.UpgradeFile(); upgradeFile.File = Convert.ToString(row[1]); upgradeFile.Ignore = Wix.YesNoType.yes; Wix.UpgradeImage upgradeImage = (Wix.UpgradeImage)this.core.GetIndexedElement("UpgradedImages", Convert.ToString(row[0])); if (null != upgradeImage) { upgradeImage.AddChild(upgradeFile); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Upgraded", Convert.ToString(row[0]), "UpgradedImages")); } } else { this.core.OnMessage(WixWarnings.UnrepresentableColumnValue(row.SourceLineNumbers, table.Name, row.Fields[0].Column.Name, row[0])); } } }
/// <summary> /// Decompile the TextStyle table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileTextStyleTable(Table table) { foreach (Row row in table.Rows) { Wix.TextStyle textStyle = new Wix.TextStyle(); textStyle.Id = Convert.ToString(row[0]); textStyle.FaceName = Convert.ToString(row[1]); textStyle.Size = Convert.ToString(row[2]); if (null != row[3]) { int color = Convert.ToInt32(row[3]); textStyle.Red = color & 0xFF; textStyle.Green = (color & 0xFF00) >> 8; textStyle.Blue = (color & 0xFF0000) >> 16; } if (null != row[4]) { int styleBits = Convert.ToInt32(row[4]); if (MsiInterop.MsidbTextStyleStyleBitsBold == (styleBits & MsiInterop.MsidbTextStyleStyleBitsBold)) { textStyle.Bold = Wix.YesNoType.yes; } if (MsiInterop.MsidbTextStyleStyleBitsItalic == (styleBits & MsiInterop.MsidbTextStyleStyleBitsItalic)) { textStyle.Italic = Wix.YesNoType.yes; } if (MsiInterop.MsidbTextStyleStyleBitsUnderline == (styleBits & MsiInterop.MsidbTextStyleStyleBitsUnderline)) { textStyle.Underline = Wix.YesNoType.yes; } if (MsiInterop.MsidbTextStyleStyleBitsStrike == (styleBits & MsiInterop.MsidbTextStyleStyleBitsStrike)) { textStyle.Strike = Wix.YesNoType.yes; } } this.core.UIElement.AddChild(textStyle); } }
/// <summary> /// Decompile the ServiceInstall table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileServiceInstallTable(Table table) { foreach (Row row in table.Rows) { Wix.ServiceInstall serviceInstall = new Wix.ServiceInstall(); serviceInstall.Id = Convert.ToString(row[0]); serviceInstall.Name = Convert.ToString(row[1]); if (null != row[2]) { serviceInstall.DisplayName = Convert.ToString(row[2]); } int serviceType = Convert.ToInt32(row[3]); if (MsiInterop.MsidbServiceInstallInteractive == (serviceType & MsiInterop.MsidbServiceInstallInteractive)) { serviceInstall.Interactive = Wix.YesNoType.yes; } if (MsiInterop.MsidbServiceInstallOwnProcess == (serviceType & MsiInterop.MsidbServiceInstallOwnProcess) && MsiInterop.MsidbServiceInstallShareProcess == (serviceType & MsiInterop.MsidbServiceInstallShareProcess)) { // TODO: warn } else if (MsiInterop.MsidbServiceInstallOwnProcess == (serviceType & MsiInterop.MsidbServiceInstallOwnProcess)) { serviceInstall.Type = Wix.ServiceInstall.TypeType.ownProcess; } else if (MsiInterop.MsidbServiceInstallShareProcess == (serviceType & MsiInterop.MsidbServiceInstallShareProcess)) { serviceInstall.Type = Wix.ServiceInstall.TypeType.shareProcess; } int startType = Convert.ToInt32(row[4]); if (MsiInterop.MsidbServiceInstallDisabled == startType) { serviceInstall.Start = Wix.ServiceInstall.StartType.disabled; } else if (MsiInterop.MsidbServiceInstallDemandStart == startType) { serviceInstall.Start = Wix.ServiceInstall.StartType.demand; } else if (MsiInterop.MsidbServiceInstallAutoStart == startType) { serviceInstall.Start = Wix.ServiceInstall.StartType.auto; } else { this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[4].Column.Name, row[4])); } int errorControl = Convert.ToInt32(row[5]); if (MsiInterop.MsidbServiceInstallErrorCritical == (errorControl & MsiInterop.MsidbServiceInstallErrorCritical)) { serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.critical; } else if (MsiInterop.MsidbServiceInstallErrorNormal == (errorControl & MsiInterop.MsidbServiceInstallErrorNormal)) { serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.normal; } else { serviceInstall.ErrorControl = Wix.ServiceInstall.ErrorControlType.ignore; } if (MsiInterop.MsidbServiceInstallErrorControlVital == (errorControl & MsiInterop.MsidbServiceInstallErrorControlVital)) { serviceInstall.Vital = Wix.YesNoType.yes; } if (null != row[6]) { serviceInstall.LoadOrderGroup = Convert.ToString(row[6]); } if (null != row[7]) { string[] dependencies = NullSplitter.Split(Convert.ToString(row[7])); foreach (string dependency in dependencies) { if (0 < dependency.Length) { Wix.ServiceDependency serviceDependency = new Wix.ServiceDependency(); if (dependency.StartsWith("+", StringComparison.Ordinal)) { serviceDependency.Group = Wix.YesNoType.yes; serviceDependency.Id = dependency.Substring(1); } else { serviceDependency.Id = dependency; } serviceInstall.AddChild(serviceDependency); } } } if (null != row[8]) { serviceInstall.Account = Convert.ToString(row[8]); } if (null != row[9]) { serviceInstall.Password = Convert.ToString(row[9]); } if (null != row[10]) { serviceInstall.Arguments = Convert.ToString(row[10]); } if (null != row[12]) { serviceInstall.Description = Convert.ToString(row[12]); } Wix.Component component = (Wix.Component)this.core.GetIndexedElement("Component", Convert.ToString(row[11])); if (null != component) { component.AddChild(serviceInstall); } else { this.core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", Convert.ToString(row[11]), "Component")); } this.core.IndexElement(row, serviceInstall); } }
/// <summary> /// Decompile the TypeLib table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileTypeLibTable(Table table) { foreach (Row row in table.Rows) { Wix.TypeLib typeLib = new Wix.TypeLib(); typeLib.Id = Convert.ToString(row[0]); typeLib.Advertise = Wix.YesNoType.yes; typeLib.Language = Convert.ToInt32(row[1]); if (null != row[3]) { int version = Convert.ToInt32(row[3]); if (65536 == version) { this.core.OnMessage(WixWarnings.PossiblyIncorrectTypelibVersion(row.SourceLineNumbers, typeLib.Id)); } typeLib.MajorVersion = ((version & 0xFFFF00) >> 8); typeLib.MinorVersion = (version & 0xFF); } if (null != row[4]) { typeLib.Description = Convert.ToString(row[4]); } if (null != row[5]) { typeLib.HelpDirectory = Convert.ToString(row[5]); } if (null != row[7]) { typeLib.Cost = Convert.ToInt32(row[7]); } // nested under the appropriate File element in FinalizeFileTable this.core.IndexElement(row, typeLib); } }
/// <summary> /// Decompile the Upgrade table. /// </summary> /// <param name="table">The table to decompile.</param> private void DecompileUpgradeTable(Table table) { Hashtable upgradeElements = new Hashtable(); foreach (UpgradeRow upgradeRow in table.Rows) { if (Compiler.UpgradeDetectedProperty == upgradeRow.ActionProperty || Compiler.DowngradeDetectedProperty == upgradeRow.ActionProperty) { continue; // MajorUpgrade rows processed in FinalizeUpgradeTable } Wix.Upgrade upgrade = (Wix.Upgrade)upgradeElements[upgradeRow.UpgradeCode]; // create the parent Upgrade element if it doesn't already exist if (null == upgrade) { upgrade = new Wix.Upgrade(); upgrade.Id = upgradeRow.UpgradeCode; this.core.RootElement.AddChild(upgrade); upgradeElements.Add(upgrade.Id, upgrade); } Wix.UpgradeVersion upgradeVersion = new Wix.UpgradeVersion(); if (null != upgradeRow.VersionMin) { upgradeVersion.Minimum = upgradeRow.VersionMin; } if (null != upgradeRow.VersionMax) { upgradeVersion.Maximum = upgradeRow.VersionMax; } if (null != upgradeRow.Language) { upgradeVersion.Language = upgradeRow.Language; } if (MsiInterop.MsidbUpgradeAttributesMigrateFeatures == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesMigrateFeatures)) { upgradeVersion.MigrateFeatures = Wix.YesNoType.yes; } if (MsiInterop.MsidbUpgradeAttributesOnlyDetect == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesOnlyDetect)) { upgradeVersion.OnlyDetect = Wix.YesNoType.yes; } if (MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure)) { upgradeVersion.IgnoreRemoveFailure = Wix.YesNoType.yes; } if (MsiInterop.MsidbUpgradeAttributesVersionMinInclusive == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesVersionMinInclusive)) { upgradeVersion.IncludeMinimum = Wix.YesNoType.yes; } if (MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive)) { upgradeVersion.IncludeMaximum = Wix.YesNoType.yes; } if (MsiInterop.MsidbUpgradeAttributesLanguagesExclusive == (upgradeRow.Attributes & MsiInterop.MsidbUpgradeAttributesLanguagesExclusive)) { upgradeVersion.ExcludeLanguages = Wix.YesNoType.yes; } if (null != upgradeRow.Remove) { upgradeVersion.RemoveFeatures = upgradeRow.Remove; } upgradeVersion.Property = upgradeRow.ActionProperty; upgrade.AddChild(upgradeVersion); } }
/// <summary> /// Creates a MediaTemplate row that belongs to a table. /// </summary> /// <param name="sourceLineNumbers">Original source lines for this row.</param> /// <param name="table">Table this MediaTeplate row belongs to and should get its column definitions from.</param> public WixMediaTemplateRow(SourceLineNumberCollection sourceLineNumbers, Table table) : base(sourceLineNumbers, table) { }
/// <summary> /// Decompiles an extension table. /// </summary> /// <param name="table">The table to decompile.</param> public virtual void DecompileTable(Table table) { this.Core.OnMessage(WixErrors.TableDecompilationUnimplemented(table.Name)); }