aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2020-10-08 15:12:30 -0400
committerBob Arnson <bob@firegiant.com>2020-10-08 15:15:37 -0400
commitac70afc7ec180ed192c54502035721446e831f49 (patch)
tree843df07b65e63992d421322ffc551083f94836fc
parent7a7f88c3009ad824852322682cc8cfd3173c2e02 (diff)
downloadwix-ac70afc7ec180ed192c54502035721446e831f49.tar.gz
wix-ac70afc7ec180ed192c54502035721446e831f49.tar.bz2
wix-ac70afc7ec180ed192c54502035721446e831f49.zip
Add the decompiled package's platform to the DecompileResult.
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs14
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs55
-rw-r--r--src/WixToolset.Core/DecompileResult.cs3
3 files changed, 47 insertions, 25 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs
index 2ec39583..45b669b9 100644
--- a/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs
@@ -6,8 +6,10 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.ComponentModel; 7 using System.ComponentModel;
8 using System.IO; 8 using System.IO;
9 using System.Linq;
9 using WixToolset.Core.WindowsInstaller.Msi; 10 using WixToolset.Core.WindowsInstaller.Msi;
10 using WixToolset.Data; 11 using WixToolset.Data;
12 using WixToolset.Data.WindowsInstaller;
11 using WixToolset.Extensibility; 13 using WixToolset.Extensibility;
12 using WixToolset.Extensibility.Data; 14 using WixToolset.Extensibility.Data;
13 using WixToolset.Extensibility.Services; 15 using WixToolset.Extensibility.Services;
@@ -41,13 +43,15 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
41 Directory.Delete(this.Context.ExtractFolder, true); 43 Directory.Delete(this.Context.ExtractFolder, true);
42 } 44 }
43 45
44 var unbindCommand = new UnbindDatabaseCommand(this.Messaging, database, this.Context.DecompilePath, this.Context.DecompileType, this.Context.ExtractFolder, this.Context.IntermediateFolder, this.Context.IsAdminImage, false, skipSummaryInfo: false); 46 var unbindCommand = new UnbindDatabaseCommand(this.Messaging, database, this.Context.DecompilePath, this.Context.DecompileType, this.Context.ExtractFolder, this.Context.IntermediateFolder, this.Context.IsAdminImage, suppressDemodularization: false, skipSummaryInfo: false);
45 var output = unbindCommand.Execute(); 47 var output = unbindCommand.Execute();
46 var extractedFilePaths = new List<string>(unbindCommand.ExportedFiles); 48 var extractedFilePaths = new List<string>(unbindCommand.ExportedFiles);
47 49
48 var decompiler = new Decompiler(this.Messaging, this.Extensions, this.Context.BaseSourcePath, this.Context.SuppressCustomTables, this.Context.SuppressDroppingEmptyTables, this.Context.SuppressUI, this.Context.TreatProductAsModule); 50 var decompiler = new Decompiler(this.Messaging, this.Extensions, this.Context.BaseSourcePath, this.Context.SuppressCustomTables, this.Context.SuppressDroppingEmptyTables, this.Context.SuppressUI, this.Context.TreatProductAsModule);
49 result.Document = decompiler.Decompile(output); 51 result.Document = decompiler.Decompile(output);
50 52
53 result.Platform = GetPlatformFromOutput(output);
54
51 // extract the files from the cabinets 55 // extract the files from the cabinets
52 if (!String.IsNullOrEmpty(this.Context.ExtractFolder) && !this.Context.SuppressExtractCabinets) 56 if (!String.IsNullOrEmpty(this.Context.ExtractFolder) && !this.Context.SuppressExtractCabinets)
53 { 57 {
@@ -77,5 +81,13 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
77 81
78 return result; 82 return result;
79 } 83 }
84
85 private static Platform? GetPlatformFromOutput(WindowsInstallerData output)
86 {
87 var template = output.Tables["_SummaryInformation"]?.Rows.SingleOrDefault(row => row.FieldAsInteger(0) == 7)?.FieldAsString(1);
88
89 return Decompiler.GetPlatformFromTemplateSummaryInformation(template?.Split(';'));
90
91 }
80 } 92 }
81} 93}
diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
index 40643abd..a0146fda 100644
--- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
@@ -93,7 +93,7 @@ namespace WixToolset.Core.WindowsInstaller
93 93
94 private string ModularizationGuid { get; set; } 94 private string ModularizationGuid { get; set; }
95 95
96 public XElement UIElement 96 private XElement UIElement
97 { 97 {
98 get 98 get
99 { 99 {
@@ -107,12 +107,11 @@ namespace WixToolset.Core.WindowsInstaller
107 } 107 }
108 } 108 }
109 109
110 public Dictionary<string, XElement> Singletons { get; } = new Dictionary<string, XElement>(); 110 private Dictionary<string, XElement> Singletons { get; } = new Dictionary<string, XElement>();
111 111
112 public Dictionary<string, XElement> IndexedElements { get; } = new Dictionary<string, XElement>(); 112 private Dictionary<string, XElement> IndexedElements { get; } = new Dictionary<string, XElement>();
113
114 public Dictionary<string, XElement> PatchTargetFiles { get; } = new Dictionary<string, XElement>();
115 113
114 private Dictionary<string, XElement> PatchTargetFiles { get; } = new Dictionary<string, XElement>();
116 115
117 /// <summary> 116 /// <summary>
118 /// Decompile the database file. 117 /// Decompile the database file.
@@ -215,12 +214,30 @@ namespace WixToolset.Core.WindowsInstaller
215 } 214 }
216#endif 215#endif
217 216
217 internal static Platform? GetPlatformFromTemplateSummaryInformation(string[] template)
218 {
219 if (null != template && 1 < template.Length && null != template[0] && 0 < template[0].Length)
220 {
221 switch (template[0])
222 {
223 case "Intel":
224 return Platform.X86;
225 case "x64":
226 return Platform.X64;
227 case "Arm64":
228 return Platform.ARM64;
229 }
230 }
231
232 return null;
233 }
234
218 /// <summary> 235 /// <summary>
219 /// Gets the element corresponding to the row it came from. 236 /// Gets the element corresponding to the row it came from.
220 /// </summary> 237 /// </summary>
221 /// <param name="row">The row corresponding to the element.</param> 238 /// <param name="row">The row corresponding to the element.</param>
222 /// <returns>The indexed element.</returns> 239 /// <returns>The indexed element.</returns>
223 public XElement GetIndexedElement(WixToolset.Data.WindowsInstaller.Row row) => this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)); 240 private XElement GetIndexedElement(WixToolset.Data.WindowsInstaller.Row row) => this.GetIndexedElement(row.TableDefinition.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter));
224 241
225 /// <summary> 242 /// <summary>
226 /// Gets the element corresponding to the primary key of the given table. 243 /// Gets the element corresponding to the primary key of the given table.
@@ -228,7 +245,7 @@ namespace WixToolset.Core.WindowsInstaller
228 /// <param name="table">The table corresponding to the element.</param> 245 /// <param name="table">The table corresponding to the element.</param>
229 /// <param name="primaryKey">The primary key corresponding to the element.</param> 246 /// <param name="primaryKey">The primary key corresponding to the element.</param>
230 /// <returns>The indexed element.</returns> 247 /// <returns>The indexed element.</returns>
231 public XElement GetIndexedElement(string table, params string[] primaryKey) => this.IndexedElements[String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey))]; 248 private XElement GetIndexedElement(string table, params string[] primaryKey) => this.IndexedElements[String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey))];
232 249
233 /// <summary> 250 /// <summary>
234 /// Gets the element corresponding to the primary key of the given table. 251 /// Gets the element corresponding to the primary key of the given table.
@@ -236,7 +253,7 @@ namespace WixToolset.Core.WindowsInstaller
236 /// <param name="table">The table corresponding to the element.</param> 253 /// <param name="table">The table corresponding to the element.</param>
237 /// <param name="primaryKey">The primary key corresponding to the element.</param> 254 /// <param name="primaryKey">The primary key corresponding to the element.</param>
238 /// <returns>The indexed element.</returns> 255 /// <returns>The indexed element.</returns>
239 public bool TryGetIndexedElement(WixToolset.Data.WindowsInstaller.Row row, out XElement xElement) => this.TryGetIndexedElement(row.TableDefinition.Name, out xElement, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)); 256 private bool TryGetIndexedElement(WixToolset.Data.WindowsInstaller.Row row, out XElement xElement) => this.TryGetIndexedElement(row.TableDefinition.Name, out xElement, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter));
240 257
241 /// <summary> 258 /// <summary>
242 /// Gets the element corresponding to the primary key of the given table. 259 /// Gets the element corresponding to the primary key of the given table.
@@ -244,14 +261,14 @@ namespace WixToolset.Core.WindowsInstaller
244 /// <param name="table">The table corresponding to the element.</param> 261 /// <param name="table">The table corresponding to the element.</param>
245 /// <param name="primaryKey">The primary key corresponding to the element.</param> 262 /// <param name="primaryKey">The primary key corresponding to the element.</param>
246 /// <returns>The indexed element.</returns> 263 /// <returns>The indexed element.</returns>
247 public bool TryGetIndexedElement(string table, out XElement xElement, params string[] primaryKey) => this.IndexedElements.TryGetValue(String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey)), out xElement); 264 private bool TryGetIndexedElement(string table, out XElement xElement, params string[] primaryKey) => this.IndexedElements.TryGetValue(String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey)), out xElement);
248 265
249 /// <summary> 266 /// <summary>
250 /// Index an element by its corresponding row. 267 /// Index an element by its corresponding row.
251 /// </summary> 268 /// </summary>
252 /// <param name="row">The row corresponding to the element.</param> 269 /// <param name="row">The row corresponding to the element.</param>
253 /// <param name="element">The element to index.</param> 270 /// <param name="element">The element to index.</param>
254 public void IndexElement(WixToolset.Data.WindowsInstaller.Row row, XElement element) 271 private void IndexElement(WixToolset.Data.WindowsInstaller.Row row, XElement element)
255 { 272 {
256 this.IndexedElements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element); 273 this.IndexedElements.Add(String.Concat(row.TableDefinition.Name, ':', row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter)), element);
257 } 274 }
@@ -261,7 +278,7 @@ namespace WixToolset.Core.WindowsInstaller
261 /// </summary> 278 /// </summary>
262 /// <param name="row">The row corresponding to the element.</param> 279 /// <param name="row">The row corresponding to the element.</param>
263 /// <param name="element">The element to index.</param> 280 /// <param name="element">The element to index.</param>
264 public void IndexElement(XElement element, string table, params string[] primaryKey) 281 private void IndexElement(XElement element, string table, params string[] primaryKey)
265 { 282 {
266 this.IndexedElements.Add(String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey)), element); 283 this.IndexedElements.Add(String.Concat(table, ':', String.Join(DecompilerConstants.PrimaryKeyDelimiterString, primaryKey)), element);
267 } 284 }
@@ -3004,20 +3021,10 @@ namespace WixToolset.Core.WindowsInstaller
3004 xPackage.SetAttributeValue("Languages", template[template.Length - 1]); 3021 xPackage.SetAttributeValue("Languages", template[template.Length - 1]);
3005 } 3022 }
3006 3023
3007 if (1 < template.Length && null != template[0] && 0 < template[0].Length) 3024 var platform = GetPlatformFromTemplateSummaryInformation(template).ToString().ToLowerInvariant();
3025 if (!String.IsNullOrEmpty(platform))
3008 { 3026 {
3009 switch (template[0]) 3027 xPackage.SetAttributeValue("Platform", platform);
3010 {
3011 case "Intel":
3012 xPackage.SetAttributeValue("Platform", "x86");
3013 break;
3014 case "x64":
3015 xPackage.SetAttributeValue("Platform", "x64");
3016 break;
3017 case "Arm64":
3018 xPackage.SetAttributeValue("Platform", "arm64");
3019 break;
3020 }
3021 } 3028 }
3022 break; 3029 break;
3023 case 9: 3030 case 9:
diff --git a/src/WixToolset.Core/DecompileResult.cs b/src/WixToolset.Core/DecompileResult.cs
index 120d099d..8c9285ba 100644
--- a/src/WixToolset.Core/DecompileResult.cs
+++ b/src/WixToolset.Core/DecompileResult.cs
@@ -4,6 +4,7 @@ namespace WixToolset.Core
4{ 4{
5 using System.Collections.Generic; 5 using System.Collections.Generic;
6 using System.Xml.Linq; 6 using System.Xml.Linq;
7 using WixToolset.Data;
7 using WixToolset.Extensibility.Data; 8 using WixToolset.Extensibility.Data;
8 9
9 internal class DecompileResult : IDecompileResult 10 internal class DecompileResult : IDecompileResult
@@ -11,5 +12,7 @@ namespace WixToolset.Core
11 public XDocument Document { get; set; } 12 public XDocument Document { get; set; }
12 13
13 public IEnumerable<string> ExtractedFilePaths { get; set; } 14 public IEnumerable<string> ExtractedFilePaths { get; set; }
15
16 public Platform? Platform { get; set; }
14 } 17 }
15} 18}