aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Util/wixext/UtilDecompiler.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2023-01-14 17:29:40 -0800
committerRob Mensching <rob@firegiant.com>2023-01-16 00:54:06 -0800
commit5f744a8c7da649721f7022dc174febd79e7e3e14 (patch)
tree643db84523bda1a2eae6dbeb02557e69f4e445e1 /src/ext/Util/wixext/UtilDecompiler.cs
parentecbaffc08239e061a7dbaa92ff3c72acd53a0bae (diff)
downloadwix-5f744a8c7da649721f7022dc174febd79e7e3e14.tar.gz
wix-5f744a8c7da649721f7022dc174febd79e7e3e14.tar.bz2
wix-5f744a8c7da649721f7022dc174febd79e7e3e14.zip
Remove extension data after extensions get PreDecompileTables callback
Also update Util.wixext decompiler extension to handle the new elements that compile into CustomActions with no additional table data. These exposed the weakness in the decompiler where extension data was removed before extensions got a chance to pre-decompile. Fixes 7151
Diffstat (limited to 'src/ext/Util/wixext/UtilDecompiler.cs')
-rw-r--r--src/ext/Util/wixext/UtilDecompiler.cs58
1 files changed, 50 insertions, 8 deletions
diff --git a/src/ext/Util/wixext/UtilDecompiler.cs b/src/ext/Util/wixext/UtilDecompiler.cs
index 1201fdd5..0a78201e 100644
--- a/src/ext/Util/wixext/UtilDecompiler.cs
+++ b/src/ext/Util/wixext/UtilDecompiler.cs
@@ -3,16 +3,15 @@
3namespace WixToolset.Util 3namespace WixToolset.Util
4{ 4{
5 using System; 5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
6 using System.IO; 8 using System.IO;
9 using System.Linq;
7 using System.Text; 10 using System.Text;
8 using System.Collections; 11 using System.Xml.Linq;
9 using System.Diagnostics;
10
11 using WixToolset.Data; 12 using WixToolset.Data;
12 using WixToolset.Extensibility;
13 using WixToolset.Data.WindowsInstaller; 13 using WixToolset.Data.WindowsInstaller;
14 using System.Collections.Generic; 14 using WixToolset.Extensibility;
15 using System.Xml.Linq;
16 using WixToolset.Util.Symbols; 15 using WixToolset.Util.Symbols;
17 16
18 /// <summary> 17 /// <summary>
@@ -22,16 +21,47 @@ namespace WixToolset.Util
22 { 21 {
23 public override IReadOnlyCollection<TableDefinition> TableDefinitions => UtilTableDefinitions.All; 22 public override IReadOnlyCollection<TableDefinition> TableDefinitions => UtilTableDefinitions.All;
24 23
24 private static readonly Dictionary<string, XName> CustomActionMapping = new Dictionary<string, XName>()
25 {
26 { "Wix4BroadcastEnvironmentChange_X86", UtilConstants.BroadcastEnvironmentChange },
27 { "Wix4BroadcastEnvironmentChange_X64", UtilConstants.BroadcastEnvironmentChange },
28 { "Wix4BroadcastEnvironmentChange_ARM64", UtilConstants.BroadcastEnvironmentChange },
29 { "Wix4BroadcastSettingChange_X86", UtilConstants.BroadcastSettingChange },
30 { "Wix4BroadcastSettingChange_X64", UtilConstants.BroadcastSettingChange },
31 { "Wix4BroadcastSettingChange_ARM64", UtilConstants.BroadcastSettingChange },
32 { "Wix4CheckRebootRequired_X86", UtilConstants.CheckRebootRequired },
33 { "Wix4CheckRebootRequired_X64", UtilConstants.CheckRebootRequired },
34 { "Wix4CheckRebootRequired_ARM64", UtilConstants.CheckRebootRequired },
35 { "Wix4QueryNativeMachine_X86", UtilConstants.QueryNativeMachine },
36 { "Wix4QueryNativeMachine_X64", UtilConstants.QueryNativeMachine },
37 { "Wix4QueryNativeMachine_ARM64", UtilConstants.QueryNativeMachine },
38 { "Wix4QueryOsDriverInfo_X86", UtilConstants.QueryWindowsDriverInfo },
39 { "Wix4QueryOsDriverInfo_X64", UtilConstants.QueryWindowsDriverInfo },
40 { "Wix4QueryOsDriverInfo_ARM64", UtilConstants.QueryWindowsDriverInfo },
41 { "Wix4QueryOsInfo_X86", UtilConstants.QueryWindowsSuiteInfo },
42 { "Wix4QueryOsInfo_X64", UtilConstants.QueryWindowsSuiteInfo },
43 { "Wix4QueryOsInfo_ARM64", UtilConstants.QueryWindowsSuiteInfo },
44 };
45
46 private IReadOnlyCollection<string> customActionNames;
47
25 /// <summary> 48 /// <summary>
26 /// Called at the beginning of the decompilation of a database. 49 /// Called at the beginning of the decompilation of a database.
27 /// </summary> 50 /// </summary>
28 /// <param name="tables">The collection of all tables.</param> 51 /// <param name="tables">The collection of all tables.</param>
29 public override void PreDecompileTables(TableIndexedCollection tables) 52 public override void PreDecompileTables(TableIndexedCollection tables)
30 { 53 {
54 this.RememberCustomActionNames(tables);
31 this.CleanupSecureCustomProperties(tables); 55 this.CleanupSecureCustomProperties(tables);
32 this.CleanupInternetShortcutRemoveFileTables(tables); 56 this.CleanupInternetShortcutRemoveFileTables(tables);
33 } 57 }
34 58
59 private void RememberCustomActionNames(TableIndexedCollection tables)
60 {
61 var customActionTable = tables["CustomAction"];
62 this.customActionNames = customActionTable?.Rows.Select(r => r.GetPrimaryKey()).Distinct().ToList() ?? (IReadOnlyCollection<string>)Array.Empty<string>();
63 }
64
35 /// <summary> 65 /// <summary>
36 /// Decompile the SecureCustomProperties field to PropertyRefs for known extension properties. 66 /// Decompile the SecureCustomProperties field to PropertyRefs for known extension properties.
37 /// </summary> 67 /// </summary>
@@ -195,6 +225,7 @@ namespace WixToolset.Util
195 /// <param name="tables">The collection of all tables.</param> 225 /// <param name="tables">The collection of all tables.</param>
196 public override void PostDecompileTables(TableIndexedCollection tables) 226 public override void PostDecompileTables(TableIndexedCollection tables)
197 { 227 {
228 this.FinalizeCustomActions();
198 this.FinalizePerfmonTable(tables); 229 this.FinalizePerfmonTable(tables);
199 this.FinalizePerfmonManifestTable(tables); 230 this.FinalizePerfmonManifestTable(tables);
200 this.FinalizeSecureObjectsTable(tables); 231 this.FinalizeSecureObjectsTable(tables);
@@ -223,7 +254,7 @@ namespace WixToolset.Util
223 AttributeIfNotNull("RebootPrompt", 0x2 == (attribute & 0x2)), 254 AttributeIfNotNull("RebootPrompt", 0x2 == (attribute & 0x2)),
224 AttributeIfNotNull("ElevatedCloseMessage", 0x4 == (attribute & 0x4)), 255 AttributeIfNotNull("ElevatedCloseMessage", 0x4 == (attribute & 0x4)),
225 NumericAttributeIfNotNull("Sequence", row, 5), 256 NumericAttributeIfNotNull("Sequence", row, 5),
226 NumericAttributeIfNotNull("Property", row, 6) 257 AttributeIfNotNull("Property", row, 6)
227 ); 258 );
228 } 259 }
229 } 260 }
@@ -379,7 +410,7 @@ namespace WixToolset.Util
379 if (this.DecompilerHelper.TryGetIndexedElement("Wix4FileShare", row.FieldAsString(0), out var fileShare) || 410 if (this.DecompilerHelper.TryGetIndexedElement("Wix4FileShare", row.FieldAsString(0), out var fileShare) ||
380 this.DecompilerHelper.TryGetIndexedElement("FileShare", row.FieldAsString(0), out fileShare)) 411 this.DecompilerHelper.TryGetIndexedElement("FileShare", row.FieldAsString(0), out fileShare))
381 { 412 {
382 fileShare.Add(fileSharePermission); 413 fileShare.Add(fileSharePermission);
383 } 414 }
384 else 415 else
385 { 416 {
@@ -695,6 +726,17 @@ namespace WixToolset.Util
695 } 726 }
696 } 727 }
697 728
729 private void FinalizeCustomActions()
730 {
731 foreach (var customActionName in this.customActionNames)
732 {
733 if (CustomActionMapping.TryGetValue(customActionName, out var elementName))
734 {
735 this.DecompilerHelper.AddElementToRoot(elementName);
736 }
737 }
738 }
739
698 /// <summary> 740 /// <summary>
699 /// Finalize the Perfmon table. 741 /// Finalize the Perfmon table.
700 /// </summary> 742 /// </summary>