diff options
Diffstat (limited to 'src/ext/Util/wixext/UtilDecompiler.cs')
-rw-r--r-- | src/ext/Util/wixext/UtilDecompiler.cs | 1543 |
1 files changed, 1543 insertions, 0 deletions
diff --git a/src/ext/Util/wixext/UtilDecompiler.cs b/src/ext/Util/wixext/UtilDecompiler.cs new file mode 100644 index 00000000..9ef3390f --- /dev/null +++ b/src/ext/Util/wixext/UtilDecompiler.cs | |||
@@ -0,0 +1,1543 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Extensions | ||
4 | { | ||
5 | #if TODO_CONSIDER_DECOMPILER | ||
6 | using System; | ||
7 | using System.IO; | ||
8 | using System.Text; | ||
9 | using System.Collections; | ||
10 | using System.Diagnostics; | ||
11 | using System.Globalization; | ||
12 | |||
13 | using Util = WixToolset.Extensions.Serialize.Util; | ||
14 | using WixToolset.Data; | ||
15 | using WixToolset.Extensibility; | ||
16 | using Wix = WixToolset.Data.Serialize; | ||
17 | |||
18 | /// <summary> | ||
19 | /// The decompiler for the WiX Toolset Utility Extension. | ||
20 | /// </summary> | ||
21 | public sealed class UtilDecompiler : DecompilerExtension | ||
22 | { | ||
23 | /// <summary> | ||
24 | /// Creates a decompiler for Utility Extension. | ||
25 | /// </summary> | ||
26 | public UtilDecompiler() | ||
27 | { | ||
28 | this.TableDefinitions = UtilExtensionData.GetExtensionTableDefinitions(); | ||
29 | } | ||
30 | |||
31 | /// <summary> | ||
32 | /// Get the extensions library to be removed. | ||
33 | /// </summary> | ||
34 | /// <param name="tableDefinitions">Table definitions for library.</param> | ||
35 | /// <returns>Library to remove from decompiled output.</returns> | ||
36 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) | ||
37 | { | ||
38 | return UtilExtensionData.GetExtensionLibrary(tableDefinitions); | ||
39 | } | ||
40 | |||
41 | /// <summary> | ||
42 | /// Called at the beginning of the decompilation of a database. | ||
43 | /// </summary> | ||
44 | /// <param name="tables">The collection of all tables.</param> | ||
45 | public override void Initialize(TableIndexedCollection tables) | ||
46 | { | ||
47 | this.CleanupSecureCustomProperties(tables); | ||
48 | this.CleanupInternetShortcutRemoveFileTables(tables); | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Decompile the SecureCustomProperties field to PropertyRefs for known extension properties. | ||
53 | /// </summary> | ||
54 | /// <remarks> | ||
55 | /// If we've referenced any of the suite or directory properties, add | ||
56 | /// a PropertyRef to refer to the Property (and associated custom action) | ||
57 | /// from the extension's library. Then remove the property from | ||
58 | /// SecureCustomExtensions property so later decompilation won't create | ||
59 | /// new Property elements. | ||
60 | /// </remarks> | ||
61 | /// <param name="tables">The collection of all tables.</param> | ||
62 | private void CleanupSecureCustomProperties(TableIndexedCollection tables) | ||
63 | { | ||
64 | Table propertyTable = tables["Property"]; | ||
65 | |||
66 | if (null != propertyTable) | ||
67 | { | ||
68 | foreach (Row row in propertyTable.Rows) | ||
69 | { | ||
70 | if ("SecureCustomProperties" == row[0].ToString()) | ||
71 | { | ||
72 | StringBuilder remainingProperties = new StringBuilder(); | ||
73 | string[] secureCustomProperties = row[1].ToString().Split(';'); | ||
74 | foreach (string property in secureCustomProperties) | ||
75 | { | ||
76 | if (property.StartsWith("WIX_SUITE_", StringComparison.Ordinal) || property.StartsWith("WIX_DIR_", StringComparison.Ordinal) | ||
77 | || property.StartsWith("WIX_ACCOUNT_", StringComparison.Ordinal)) | ||
78 | { | ||
79 | Wix.PropertyRef propertyRef = new Wix.PropertyRef(); | ||
80 | propertyRef.Id = property; | ||
81 | this.Core.RootElement.AddChild(propertyRef); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | if (0 < remainingProperties.Length) | ||
86 | { | ||
87 | remainingProperties.Append(";"); | ||
88 | } | ||
89 | remainingProperties.Append(property); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | row[1] = remainingProperties.ToString(); | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Remove RemoveFile rows that the InternetShortcut compiler extension adds for us. | ||
102 | /// </summary> | ||
103 | /// <param name="tables">The collection of all tables.</param> | ||
104 | private void CleanupInternetShortcutRemoveFileTables(TableIndexedCollection tables) | ||
105 | { | ||
106 | // index the WixInternetShortcut table | ||
107 | Table wixInternetShortcutTable = tables["WixInternetShortcut"]; | ||
108 | Hashtable wixInternetShortcuts = new Hashtable(); | ||
109 | if (null != wixInternetShortcutTable) | ||
110 | { | ||
111 | foreach (Row row in wixInternetShortcutTable.Rows) | ||
112 | { | ||
113 | wixInternetShortcuts.Add(row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), row); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | // remove the RemoveFile rows with primary keys that match the WixInternetShortcut table's | ||
118 | Table removeFileTable = tables["RemoveFile"]; | ||
119 | if (null != removeFileTable) | ||
120 | { | ||
121 | for (int i = removeFileTable.Rows.Count - 1; 0 <= i; i--) | ||
122 | { | ||
123 | if (null != wixInternetShortcuts[removeFileTable.Rows[i][0]]) | ||
124 | { | ||
125 | removeFileTable.Rows.RemoveAt(i); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | /// <summary> | ||
132 | /// Decompiles an extension table. | ||
133 | /// </summary> | ||
134 | /// <param name="table">The table to decompile.</param> | ||
135 | public override void DecompileTable(Table table) | ||
136 | { | ||
137 | switch (table.Name) | ||
138 | { | ||
139 | case "WixCloseApplication": | ||
140 | this.DecompileWixCloseApplicationTable(table); | ||
141 | break; | ||
142 | case "WixRemoveFolderEx": | ||
143 | this.DecompileWixRemoveFolderExTable(table); | ||
144 | break; | ||
145 | case "WixRestartResource": | ||
146 | this.DecompileWixRestartResourceTable(table); | ||
147 | break; | ||
148 | case "FileShare": | ||
149 | this.DecompileFileShareTable(table); | ||
150 | break; | ||
151 | case "FileSharePermissions": | ||
152 | this.DecompileFileSharePermissionsTable(table); | ||
153 | break; | ||
154 | case "WixInternetShortcut": | ||
155 | this.DecompileWixInternetShortcutTable(table); | ||
156 | break; | ||
157 | case "Group": | ||
158 | this.DecompileGroupTable(table); | ||
159 | break; | ||
160 | case "Perfmon": | ||
161 | this.DecompilePerfmonTable(table); | ||
162 | break; | ||
163 | case "PerfmonManifest": | ||
164 | this.DecompilePerfmonManifestTable(table); | ||
165 | break; | ||
166 | case "EventManifest": | ||
167 | this.DecompileEventManifestTable(table); | ||
168 | break; | ||
169 | case "SecureObjects": | ||
170 | this.DecompileSecureObjectsTable(table); | ||
171 | break; | ||
172 | case "ServiceConfig": | ||
173 | this.DecompileServiceConfigTable(table); | ||
174 | break; | ||
175 | case "User": | ||
176 | this.DecompileUserTable(table); | ||
177 | break; | ||
178 | case "UserGroup": | ||
179 | this.DecompileUserGroupTable(table); | ||
180 | break; | ||
181 | case "XmlConfig": | ||
182 | this.DecompileXmlConfigTable(table); | ||
183 | break; | ||
184 | case "XmlFile": | ||
185 | // XmlFile decompilation has been moved to FinalizeXmlFileTable function | ||
186 | break; | ||
187 | default: | ||
188 | base.DecompileTable(table); | ||
189 | break; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | /// <summary> | ||
194 | /// Finalize decompilation. | ||
195 | /// </summary> | ||
196 | /// <param name="tables">The collection of all tables.</param> | ||
197 | public override void Finish(TableIndexedCollection tables) | ||
198 | { | ||
199 | this.FinalizePerfmonTable(tables); | ||
200 | this.FinalizePerfmonManifestTable(tables); | ||
201 | this.FinalizeSecureObjectsTable(tables); | ||
202 | this.FinalizeServiceConfigTable(tables); | ||
203 | this.FinalizeXmlConfigTable(tables); | ||
204 | this.FinalizeXmlFileTable(tables); | ||
205 | this.FinalizeEventManifestTable(tables); | ||
206 | } | ||
207 | |||
208 | /// <summary> | ||
209 | /// Decompile the WixCloseApplication table. | ||
210 | /// </summary> | ||
211 | /// <param name="table">The table to decompile.</param> | ||
212 | private void DecompileWixCloseApplicationTable(Table table) | ||
213 | { | ||
214 | foreach (Row row in table.Rows) | ||
215 | { | ||
216 | Util.CloseApplication closeApplication = new Util.CloseApplication(); | ||
217 | |||
218 | closeApplication.Id = (string)row[0]; | ||
219 | |||
220 | closeApplication.Target = (string)row[1]; | ||
221 | |||
222 | if (null != row[2]) | ||
223 | { | ||
224 | closeApplication.Description = (string)row[2]; | ||
225 | } | ||
226 | |||
227 | if (null != row[3]) | ||
228 | { | ||
229 | closeApplication.Content = (string)row[3]; | ||
230 | } | ||
231 | |||
232 | // set defaults | ||
233 | closeApplication.CloseMessage = Util.YesNoType.no; | ||
234 | closeApplication.RebootPrompt = Util.YesNoType.yes; | ||
235 | closeApplication.ElevatedCloseMessage = Util.YesNoType.no; | ||
236 | |||
237 | if (null != row[4]) | ||
238 | { | ||
239 | int attribute = (int)row[4]; | ||
240 | |||
241 | closeApplication.CloseMessage = (0x1 == (attribute & 0x1)) ? Util.YesNoType.yes : Util.YesNoType.no; | ||
242 | closeApplication.RebootPrompt = (0x2 == (attribute & 0x2)) ? Util.YesNoType.yes : Util.YesNoType.no; | ||
243 | closeApplication.ElevatedCloseMessage = (0x4 == (attribute & 0x4)) ? Util.YesNoType.yes : Util.YesNoType.no; | ||
244 | } | ||
245 | |||
246 | if (null != row[5]) | ||
247 | { | ||
248 | closeApplication.Sequence = (int)row[5]; | ||
249 | } | ||
250 | |||
251 | if (null != row[6]) | ||
252 | { | ||
253 | closeApplication.Property = (string)row[6]; | ||
254 | } | ||
255 | |||
256 | this.Core.RootElement.AddChild(closeApplication); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | /// <summary> | ||
261 | /// Decompile the WixRemoveFolderEx table. | ||
262 | /// </summary> | ||
263 | /// <param name="table">The table to decompile.</param> | ||
264 | private void DecompileWixRemoveFolderExTable(Table table) | ||
265 | { | ||
266 | foreach (Row row in table.Rows) | ||
267 | { | ||
268 | // Set the Id even if auto-generated previously. | ||
269 | Util.RemoveFolderEx removeFolder = new Util.RemoveFolderEx(); | ||
270 | removeFolder.Id = (string)row[0]; | ||
271 | removeFolder.Property = (string)row[2]; | ||
272 | |||
273 | int installMode = (int)row[3]; | ||
274 | switch ((UtilCompiler.WixRemoveFolderExOn)installMode) | ||
275 | { | ||
276 | case UtilCompiler.WixRemoveFolderExOn.Install: | ||
277 | removeFolder.On = Util.RemoveFolderEx.OnType.install; | ||
278 | break; | ||
279 | |||
280 | case UtilCompiler.WixRemoveFolderExOn.Uninstall: | ||
281 | removeFolder.On = Util.RemoveFolderEx.OnType.uninstall; | ||
282 | break; | ||
283 | |||
284 | case UtilCompiler.WixRemoveFolderExOn.Both: | ||
285 | removeFolder.On = Util.RemoveFolderEx.OnType.both; | ||
286 | break; | ||
287 | |||
288 | default: | ||
289 | this.Core.OnMessage(WixWarnings.UnrepresentableColumnValue(row.SourceLineNumbers, table.Name, "InstallMode", installMode)); | ||
290 | break; | ||
291 | } | ||
292 | |||
293 | // Add to the appropriate Component or section element. | ||
294 | string componentId = (string)row[1]; | ||
295 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", componentId); | ||
296 | if (null != component) | ||
297 | { | ||
298 | component.AddChild(removeFolder); | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", componentId, "Component")); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | |||
307 | /// <summary> | ||
308 | /// Decompile the WixRestartResource table. | ||
309 | /// </summary> | ||
310 | /// <param name="table">The table to decompile.</param> | ||
311 | private void DecompileWixRestartResourceTable(Table table) | ||
312 | { | ||
313 | foreach (Row row in table.Rows) | ||
314 | { | ||
315 | // Set the Id even if auto-generated previously. | ||
316 | Util.RestartResource restartResource = new Util.RestartResource(); | ||
317 | restartResource.Id = (string)row[0]; | ||
318 | |||
319 | // Determine the resource type and set accordingly. | ||
320 | string resource = (string)row[2]; | ||
321 | int attributes = (int)row[3]; | ||
322 | UtilCompiler.WixRestartResourceAttributes type = (UtilCompiler.WixRestartResourceAttributes)(attributes & (int)UtilCompiler.WixRestartResourceAttributes.TypeMask); | ||
323 | |||
324 | switch (type) | ||
325 | { | ||
326 | case UtilCompiler.WixRestartResourceAttributes.Filename: | ||
327 | restartResource.Path = resource; | ||
328 | break; | ||
329 | |||
330 | case UtilCompiler.WixRestartResourceAttributes.ProcessName: | ||
331 | restartResource.ProcessName = resource; | ||
332 | break; | ||
333 | |||
334 | case UtilCompiler.WixRestartResourceAttributes.ServiceName: | ||
335 | restartResource.ServiceName = resource; | ||
336 | break; | ||
337 | |||
338 | default: | ||
339 | this.Core.OnMessage(WixWarnings.UnrepresentableColumnValue(row.SourceLineNumbers, table.Name, "Attributes", attributes)); | ||
340 | break; | ||
341 | } | ||
342 | |||
343 | // Add to the appropriate Component or section element. | ||
344 | string componentId = (string)row[1]; | ||
345 | if (!String.IsNullOrEmpty(componentId)) | ||
346 | { | ||
347 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", componentId); | ||
348 | if (null != component) | ||
349 | { | ||
350 | component.AddChild(restartResource); | ||
351 | } | ||
352 | else | ||
353 | { | ||
354 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", componentId, "Component")); | ||
355 | } | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | this.Core.RootElement.AddChild(restartResource); | ||
360 | } | ||
361 | } | ||
362 | } | ||
363 | |||
364 | /// <summary> | ||
365 | /// Decompile the FileShare table. | ||
366 | /// </summary> | ||
367 | /// <param name="table">The table to decompile.</param> | ||
368 | private void DecompileFileShareTable(Table table) | ||
369 | { | ||
370 | foreach (Row row in table.Rows) | ||
371 | { | ||
372 | Util.FileShare fileShare = new Util.FileShare(); | ||
373 | |||
374 | fileShare.Id = (string)row[0]; | ||
375 | |||
376 | fileShare.Name = (string)row[1]; | ||
377 | |||
378 | if (null != row[3]) | ||
379 | { | ||
380 | fileShare.Description = (string)row[3]; | ||
381 | } | ||
382 | |||
383 | // the Directory_ column is set by the parent Component | ||
384 | |||
385 | // the User_ and Permissions columns are deprecated | ||
386 | |||
387 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); | ||
388 | if (null != component) | ||
389 | { | ||
390 | component.AddChild(fileShare); | ||
391 | } | ||
392 | else | ||
393 | { | ||
394 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); | ||
395 | } | ||
396 | this.Core.IndexElement(row, fileShare); | ||
397 | } | ||
398 | } | ||
399 | |||
400 | /// <summary> | ||
401 | /// Decompile the FileSharePermissions table. | ||
402 | /// </summary> | ||
403 | /// <param name="table">The table to decompile.</param> | ||
404 | private void DecompileFileSharePermissionsTable(Table table) | ||
405 | { | ||
406 | foreach (Row row in table.Rows) | ||
407 | { | ||
408 | Util.FileSharePermission fileSharePermission = new Util.FileSharePermission(); | ||
409 | |||
410 | fileSharePermission.User = (string)row[1]; | ||
411 | |||
412 | string[] specialPermissions = UtilConstants.FolderPermissions; | ||
413 | int permissions = (int)row[2]; | ||
414 | for (int i = 0; i < 32; i++) | ||
415 | { | ||
416 | if (0 != ((permissions >> i) & 1)) | ||
417 | { | ||
418 | string name = null; | ||
419 | |||
420 | if (16 > i && specialPermissions.Length > i) | ||
421 | { | ||
422 | name = specialPermissions[i]; | ||
423 | } | ||
424 | else if (28 > i && UtilConstants.StandardPermissions.Length > (i - 16)) | ||
425 | { | ||
426 | name = UtilConstants.StandardPermissions[i - 16]; | ||
427 | } | ||
428 | else if (0 <= (i - 28) && UtilConstants.GenericPermissions.Length > (i - 28)) | ||
429 | { | ||
430 | name = UtilConstants.GenericPermissions[i - 28]; | ||
431 | } | ||
432 | |||
433 | if (null == name) | ||
434 | { | ||
435 | this.Core.OnMessage(WixWarnings.UnknownPermission(row.SourceLineNumbers, row.Table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), i)); | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | switch (name) | ||
440 | { | ||
441 | case "ChangePermission": | ||
442 | fileSharePermission.ChangePermission = Util.YesNoType.yes; | ||
443 | break; | ||
444 | case "CreateChild": | ||
445 | fileSharePermission.CreateChild = Util.YesNoType.yes; | ||
446 | break; | ||
447 | case "CreateFile": | ||
448 | fileSharePermission.CreateFile = Util.YesNoType.yes; | ||
449 | break; | ||
450 | case "Delete": | ||
451 | fileSharePermission.Delete = Util.YesNoType.yes; | ||
452 | break; | ||
453 | case "DeleteChild": | ||
454 | fileSharePermission.DeleteChild = Util.YesNoType.yes; | ||
455 | break; | ||
456 | case "GenericAll": | ||
457 | fileSharePermission.GenericAll = Util.YesNoType.yes; | ||
458 | break; | ||
459 | case "GenericExecute": | ||
460 | fileSharePermission.GenericExecute = Util.YesNoType.yes; | ||
461 | break; | ||
462 | case "GenericRead": | ||
463 | fileSharePermission.GenericRead = Util.YesNoType.yes; | ||
464 | break; | ||
465 | case "GenericWrite": | ||
466 | fileSharePermission.GenericWrite = Util.YesNoType.yes; | ||
467 | break; | ||
468 | case "Read": | ||
469 | fileSharePermission.Read = Util.YesNoType.yes; | ||
470 | break; | ||
471 | case "ReadAttributes": | ||
472 | fileSharePermission.ReadAttributes = Util.YesNoType.yes; | ||
473 | break; | ||
474 | case "ReadExtendedAttributes": | ||
475 | fileSharePermission.ReadExtendedAttributes = Util.YesNoType.yes; | ||
476 | break; | ||
477 | case "ReadPermission": | ||
478 | fileSharePermission.ReadPermission = Util.YesNoType.yes; | ||
479 | break; | ||
480 | case "Synchronize": | ||
481 | fileSharePermission.Synchronize = Util.YesNoType.yes; | ||
482 | break; | ||
483 | case "TakeOwnership": | ||
484 | fileSharePermission.TakeOwnership = Util.YesNoType.yes; | ||
485 | break; | ||
486 | case "Traverse": | ||
487 | fileSharePermission.Traverse = Util.YesNoType.yes; | ||
488 | break; | ||
489 | case "WriteAttributes": | ||
490 | fileSharePermission.WriteAttributes = Util.YesNoType.yes; | ||
491 | break; | ||
492 | case "WriteExtendedAttributes": | ||
493 | fileSharePermission.WriteExtendedAttributes = Util.YesNoType.yes; | ||
494 | break; | ||
495 | default: | ||
496 | Debug.Fail(String.Format("Unknown permission '{0}'.", name)); | ||
497 | break; | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | } | ||
502 | |||
503 | Util.FileShare fileShare = (Util.FileShare)this.Core.GetIndexedElement("FileShare", (string)row[0]); | ||
504 | if (null != fileShare) | ||
505 | { | ||
506 | fileShare.AddChild(fileSharePermission); | ||
507 | } | ||
508 | else | ||
509 | { | ||
510 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileShare_", (string)row[0], "FileShare")); | ||
511 | } | ||
512 | } | ||
513 | } | ||
514 | |||
515 | /// <summary> | ||
516 | /// Decompile the Group table. | ||
517 | /// </summary> | ||
518 | /// <param name="table">The table to decompile.</param> | ||
519 | private void DecompileGroupTable(Table table) | ||
520 | { | ||
521 | foreach (Row row in table.Rows) | ||
522 | { | ||
523 | Util.Group group = new Util.Group(); | ||
524 | |||
525 | group.Id = (string)row[0]; | ||
526 | |||
527 | if (null != row[1]) | ||
528 | { | ||
529 | this.Core.OnMessage(WixWarnings.UnrepresentableColumnValue(row.SourceLineNumbers, table.Name, "Component_", (string)row[1])); | ||
530 | } | ||
531 | |||
532 | group.Name = (string)row[2]; | ||
533 | |||
534 | if (null != row[3]) | ||
535 | { | ||
536 | group.Domain = (string)row[3]; | ||
537 | } | ||
538 | |||
539 | this.Core.RootElement.AddChild(group); | ||
540 | } | ||
541 | } | ||
542 | |||
543 | /// <summary> | ||
544 | /// Decompile the WixInternetShortcut table. | ||
545 | /// </summary> | ||
546 | /// <param name="table">The table to decompile.</param> | ||
547 | private void DecompileWixInternetShortcutTable(Table table) | ||
548 | { | ||
549 | foreach (Row row in table.Rows) | ||
550 | { | ||
551 | Util.InternetShortcut internetShortcut = new Util.InternetShortcut(); | ||
552 | internetShortcut.Id = (string)row[0]; | ||
553 | internetShortcut.Directory = (string)row[2]; | ||
554 | // remove .lnk/.url extension because compiler extension adds it back for us | ||
555 | internetShortcut.Name = Path.ChangeExtension((string)row[3], null); | ||
556 | internetShortcut.Target = (string)row[4]; | ||
557 | internetShortcut.IconFile = (string)row[6]; | ||
558 | internetShortcut.IconIndex = (int)row[7]; | ||
559 | |||
560 | UtilCompiler.InternetShortcutType shortcutType = (UtilCompiler.InternetShortcutType)row[5]; | ||
561 | switch (shortcutType) | ||
562 | { | ||
563 | case UtilCompiler.InternetShortcutType.Link: | ||
564 | internetShortcut.Type = Util.InternetShortcut.TypeType.link; | ||
565 | break; | ||
566 | case UtilCompiler.InternetShortcutType.Url: | ||
567 | internetShortcut.Type = Util.InternetShortcut.TypeType.url; | ||
568 | break; | ||
569 | } | ||
570 | |||
571 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); | ||
572 | if (null != component) | ||
573 | { | ||
574 | component.AddChild(internetShortcut); | ||
575 | } | ||
576 | else | ||
577 | { | ||
578 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); | ||
579 | } | ||
580 | |||
581 | this.Core.IndexElement(row, internetShortcut); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | /// <summary> | ||
586 | /// Decompile the Perfmon table. | ||
587 | /// </summary> | ||
588 | /// <param name="table">The table to decompile.</param> | ||
589 | private void DecompilePerfmonTable(Table table) | ||
590 | { | ||
591 | foreach (Row row in table.Rows) | ||
592 | { | ||
593 | Util.PerfCounter perfCounter = new Util.PerfCounter(); | ||
594 | |||
595 | perfCounter.Name = (string)row[2]; | ||
596 | |||
597 | this.Core.IndexElement(row, perfCounter); | ||
598 | } | ||
599 | } | ||
600 | |||
601 | /// <summary> | ||
602 | /// Decompile the PerfmonManifest table. | ||
603 | /// </summary> | ||
604 | /// <param name="table">The table to decompile.</param> | ||
605 | private void DecompilePerfmonManifestTable(Table table) | ||
606 | { | ||
607 | foreach (Row row in table.Rows) | ||
608 | { | ||
609 | Util.PerfCounterManifest perfCounterManifest = new Util.PerfCounterManifest(); | ||
610 | |||
611 | perfCounterManifest.ResourceFileDirectory = (string)row[2]; | ||
612 | |||
613 | this.Core.IndexElement(row, perfCounterManifest); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | /// <summary> | ||
618 | /// Decompile the EventManifest table. | ||
619 | /// </summary> | ||
620 | /// <param name="table">The table to decompile.</param> | ||
621 | private void DecompileEventManifestTable(Table table) | ||
622 | { | ||
623 | foreach (Row row in table.Rows) | ||
624 | { | ||
625 | Util.EventManifest eventManifest = new Util.EventManifest(); | ||
626 | this.Core.IndexElement(row, eventManifest); | ||
627 | } | ||
628 | } | ||
629 | |||
630 | /// <summary> | ||
631 | /// Decompile the SecureObjects table. | ||
632 | /// </summary> | ||
633 | /// <param name="table">The table to decompile.</param> | ||
634 | private void DecompileSecureObjectsTable(Table table) | ||
635 | { | ||
636 | foreach (Row row in table.Rows) | ||
637 | { | ||
638 | Util.PermissionEx permissionEx = new Util.PermissionEx(); | ||
639 | |||
640 | string[] specialPermissions; | ||
641 | switch ((string)row[1]) | ||
642 | { | ||
643 | case "CreateFolder": | ||
644 | specialPermissions = UtilConstants.FolderPermissions; | ||
645 | break; | ||
646 | case "File": | ||
647 | specialPermissions = UtilConstants.FilePermissions; | ||
648 | break; | ||
649 | case "Registry": | ||
650 | specialPermissions = UtilConstants.RegistryPermissions; | ||
651 | break; | ||
652 | case "ServiceInstall": | ||
653 | specialPermissions = UtilConstants.ServicePermissions; | ||
654 | break; | ||
655 | default: | ||
656 | this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, row.Table.Name, row.Fields[1].Column.Name, row[1])); | ||
657 | return; | ||
658 | } | ||
659 | |||
660 | int permissionBits = (int)row[4]; | ||
661 | for (int i = 0; i < 32; i++) | ||
662 | { | ||
663 | if (0 != ((permissionBits >> i) & 1)) | ||
664 | { | ||
665 | string name = null; | ||
666 | |||
667 | if (16 > i && specialPermissions.Length > i) | ||
668 | { | ||
669 | name = specialPermissions[i]; | ||
670 | } | ||
671 | else if (28 > i && UtilConstants.StandardPermissions.Length > (i - 16)) | ||
672 | { | ||
673 | name = UtilConstants.StandardPermissions[i - 16]; | ||
674 | } | ||
675 | else if (0 <= (i - 28) && UtilConstants.GenericPermissions.Length > (i - 28)) | ||
676 | { | ||
677 | name = UtilConstants.GenericPermissions[i - 28]; | ||
678 | } | ||
679 | |||
680 | if (null == name) | ||
681 | { | ||
682 | this.Core.OnMessage(WixWarnings.UnknownPermission(row.SourceLineNumbers, row.Table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), i)); | ||
683 | } | ||
684 | else | ||
685 | { | ||
686 | switch (name) | ||
687 | { | ||
688 | case "Append": | ||
689 | permissionEx.Append = Util.YesNoType.yes; | ||
690 | break; | ||
691 | case "ChangePermission": | ||
692 | permissionEx.ChangePermission = Util.YesNoType.yes; | ||
693 | break; | ||
694 | case "CreateChild": | ||
695 | permissionEx.CreateChild = Util.YesNoType.yes; | ||
696 | break; | ||
697 | case "CreateFile": | ||
698 | permissionEx.CreateFile = Util.YesNoType.yes; | ||
699 | break; | ||
700 | case "CreateLink": | ||
701 | permissionEx.CreateLink = Util.YesNoType.yes; | ||
702 | break; | ||
703 | case "CreateSubkeys": | ||
704 | permissionEx.CreateSubkeys = Util.YesNoType.yes; | ||
705 | break; | ||
706 | case "Delete": | ||
707 | permissionEx.Delete = Util.YesNoType.yes; | ||
708 | break; | ||
709 | case "DeleteChild": | ||
710 | permissionEx.DeleteChild = Util.YesNoType.yes; | ||
711 | break; | ||
712 | case "EnumerateSubkeys": | ||
713 | permissionEx.EnumerateSubkeys = Util.YesNoType.yes; | ||
714 | break; | ||
715 | case "Execute": | ||
716 | permissionEx.Execute = Util.YesNoType.yes; | ||
717 | break; | ||
718 | case "GenericAll": | ||
719 | permissionEx.GenericAll = Util.YesNoType.yes; | ||
720 | break; | ||
721 | case "GenericExecute": | ||
722 | permissionEx.GenericExecute = Util.YesNoType.yes; | ||
723 | break; | ||
724 | case "GenericRead": | ||
725 | permissionEx.GenericRead = Util.YesNoType.yes; | ||
726 | break; | ||
727 | case "GenericWrite": | ||
728 | permissionEx.GenericWrite = Util.YesNoType.yes; | ||
729 | break; | ||
730 | case "Notify": | ||
731 | permissionEx.Notify = Util.YesNoType.yes; | ||
732 | break; | ||
733 | case "Read": | ||
734 | permissionEx.Read = Util.YesNoType.yes; | ||
735 | break; | ||
736 | case "ReadAttributes": | ||
737 | permissionEx.ReadAttributes = Util.YesNoType.yes; | ||
738 | break; | ||
739 | case "ReadExtendedAttributes": | ||
740 | permissionEx.ReadExtendedAttributes = Util.YesNoType.yes; | ||
741 | break; | ||
742 | case "ReadPermission": | ||
743 | permissionEx.ReadPermission = Util.YesNoType.yes; | ||
744 | break; | ||
745 | case "ServiceChangeConfig": | ||
746 | permissionEx.ServiceChangeConfig = Util.YesNoType.yes; | ||
747 | break; | ||
748 | case "ServiceEnumerateDependents": | ||
749 | permissionEx.ServiceEnumerateDependents = Util.YesNoType.yes; | ||
750 | break; | ||
751 | case "ServiceInterrogate": | ||
752 | permissionEx.ServiceInterrogate = Util.YesNoType.yes; | ||
753 | break; | ||
754 | case "ServicePauseContinue": | ||
755 | permissionEx.ServicePauseContinue = Util.YesNoType.yes; | ||
756 | break; | ||
757 | case "ServiceQueryConfig": | ||
758 | permissionEx.ServiceQueryConfig = Util.YesNoType.yes; | ||
759 | break; | ||
760 | case "ServiceQueryStatus": | ||
761 | permissionEx.ServiceQueryStatus = Util.YesNoType.yes; | ||
762 | break; | ||
763 | case "ServiceStart": | ||
764 | permissionEx.ServiceStart = Util.YesNoType.yes; | ||
765 | break; | ||
766 | case "ServiceStop": | ||
767 | permissionEx.ServiceStop = Util.YesNoType.yes; | ||
768 | break; | ||
769 | case "ServiceUserDefinedControl": | ||
770 | permissionEx.ServiceUserDefinedControl = Util.YesNoType.yes; | ||
771 | break; | ||
772 | case "Synchronize": | ||
773 | permissionEx.Synchronize = Util.YesNoType.yes; | ||
774 | break; | ||
775 | case "TakeOwnership": | ||
776 | permissionEx.TakeOwnership = Util.YesNoType.yes; | ||
777 | break; | ||
778 | case "Traverse": | ||
779 | permissionEx.Traverse = Util.YesNoType.yes; | ||
780 | break; | ||
781 | case "Write": | ||
782 | permissionEx.Write = Util.YesNoType.yes; | ||
783 | break; | ||
784 | case "WriteAttributes": | ||
785 | permissionEx.WriteAttributes = Util.YesNoType.yes; | ||
786 | break; | ||
787 | case "WriteExtendedAttributes": | ||
788 | permissionEx.WriteExtendedAttributes = Util.YesNoType.yes; | ||
789 | break; | ||
790 | default: | ||
791 | throw new InvalidOperationException(String.Format("Unknown permission attribute '{0}'.", name)); | ||
792 | } | ||
793 | } | ||
794 | } | ||
795 | } | ||
796 | |||
797 | if (null != row[2]) | ||
798 | { | ||
799 | permissionEx.Domain = (string)row[2]; | ||
800 | } | ||
801 | |||
802 | permissionEx.User = (string)row[3]; | ||
803 | |||
804 | this.Core.IndexElement(row, permissionEx); | ||
805 | } | ||
806 | } | ||
807 | |||
808 | /// <summary> | ||
809 | /// Decompile the ServiceConfig table. | ||
810 | /// </summary> | ||
811 | /// <param name="table">The table to decompile.</param> | ||
812 | private void DecompileServiceConfigTable(Table table) | ||
813 | { | ||
814 | foreach (Row row in table.Rows) | ||
815 | { | ||
816 | Util.ServiceConfig serviceConfig = new Util.ServiceConfig(); | ||
817 | |||
818 | serviceConfig.ServiceName = (string)row[0]; | ||
819 | |||
820 | switch ((string)row[3]) | ||
821 | { | ||
822 | case "none": | ||
823 | serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.none; | ||
824 | break; | ||
825 | case "reboot": | ||
826 | serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.reboot; | ||
827 | break; | ||
828 | case "restart": | ||
829 | serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.restart; | ||
830 | break; | ||
831 | case "runCommand": | ||
832 | serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.runCommand; | ||
833 | break; | ||
834 | default: | ||
835 | this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[3].Column.Name, row[3])); | ||
836 | break; | ||
837 | } | ||
838 | |||
839 | switch ((string)row[4]) | ||
840 | { | ||
841 | case "none": | ||
842 | serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.none; | ||
843 | break; | ||
844 | case "reboot": | ||
845 | serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.reboot; | ||
846 | break; | ||
847 | case "restart": | ||
848 | serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.restart; | ||
849 | break; | ||
850 | case "runCommand": | ||
851 | serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.runCommand; | ||
852 | break; | ||
853 | default: | ||
854 | this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[4].Column.Name, row[4])); | ||
855 | break; | ||
856 | } | ||
857 | |||
858 | switch ((string)row[5]) | ||
859 | { | ||
860 | case "none": | ||
861 | serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.none; | ||
862 | break; | ||
863 | case "reboot": | ||
864 | serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.reboot; | ||
865 | break; | ||
866 | case "restart": | ||
867 | serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.restart; | ||
868 | break; | ||
869 | case "runCommand": | ||
870 | serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.runCommand; | ||
871 | break; | ||
872 | default: | ||
873 | this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[5].Column.Name, row[5])); | ||
874 | break; | ||
875 | } | ||
876 | |||
877 | if (null != row[6]) | ||
878 | { | ||
879 | serviceConfig.ResetPeriodInDays = (int)row[6]; | ||
880 | } | ||
881 | |||
882 | if (null != row[7]) | ||
883 | { | ||
884 | serviceConfig.RestartServiceDelayInSeconds = (int)row[7]; | ||
885 | } | ||
886 | |||
887 | if (null != row[8]) | ||
888 | { | ||
889 | serviceConfig.ProgramCommandLine = (string)row[8]; | ||
890 | } | ||
891 | |||
892 | if (null != row[9]) | ||
893 | { | ||
894 | serviceConfig.RebootMessage = (string)row[9]; | ||
895 | } | ||
896 | |||
897 | this.Core.IndexElement(row, serviceConfig); | ||
898 | } | ||
899 | } | ||
900 | |||
901 | /// <summary> | ||
902 | /// Decompile the User table. | ||
903 | /// </summary> | ||
904 | /// <param name="table">The table to decompile.</param> | ||
905 | private void DecompileUserTable(Table table) | ||
906 | { | ||
907 | foreach (Row row in table.Rows) | ||
908 | { | ||
909 | Util.User user = new Util.User(); | ||
910 | |||
911 | user.Id = (string)row[0]; | ||
912 | |||
913 | user.Name = (string)row[2]; | ||
914 | |||
915 | if (null != row[3]) | ||
916 | { | ||
917 | user.Domain = (string)row[3]; | ||
918 | } | ||
919 | |||
920 | if (null != row[4]) | ||
921 | { | ||
922 | user.Password = (string)row[4]; | ||
923 | } | ||
924 | |||
925 | if (null != row[5]) | ||
926 | { | ||
927 | int attributes = (int)row[5]; | ||
928 | |||
929 | if (UtilCompiler.UserDontExpirePasswrd == (attributes & UtilCompiler.UserDontExpirePasswrd)) | ||
930 | { | ||
931 | user.PasswordNeverExpires = Util.YesNoType.yes; | ||
932 | } | ||
933 | |||
934 | if (UtilCompiler.UserPasswdCantChange == (attributes & UtilCompiler.UserPasswdCantChange)) | ||
935 | { | ||
936 | user.CanNotChangePassword = Util.YesNoType.yes; | ||
937 | } | ||
938 | |||
939 | if (UtilCompiler.UserPasswdChangeReqdOnLogin == (attributes & UtilCompiler.UserPasswdChangeReqdOnLogin)) | ||
940 | { | ||
941 | user.PasswordExpired = Util.YesNoType.yes; | ||
942 | } | ||
943 | |||
944 | if (UtilCompiler.UserDisableAccount == (attributes & UtilCompiler.UserDisableAccount)) | ||
945 | { | ||
946 | user.Disabled = Util.YesNoType.yes; | ||
947 | } | ||
948 | |||
949 | if (UtilCompiler.UserFailIfExists == (attributes & UtilCompiler.UserFailIfExists)) | ||
950 | { | ||
951 | user.FailIfExists = Util.YesNoType.yes; | ||
952 | } | ||
953 | |||
954 | if (UtilCompiler.UserUpdateIfExists == (attributes & UtilCompiler.UserUpdateIfExists)) | ||
955 | { | ||
956 | user.UpdateIfExists = Util.YesNoType.yes; | ||
957 | } | ||
958 | |||
959 | if (UtilCompiler.UserLogonAsService == (attributes & UtilCompiler.UserLogonAsService)) | ||
960 | { | ||
961 | user.LogonAsService = Util.YesNoType.yes; | ||
962 | } | ||
963 | |||
964 | if (UtilCompiler.UserDontRemoveOnUninstall == (attributes & UtilCompiler.UserDontRemoveOnUninstall)) | ||
965 | { | ||
966 | user.RemoveOnUninstall = Util.YesNoType.no; | ||
967 | } | ||
968 | |||
969 | if (UtilCompiler.UserDontCreateUser == (attributes & UtilCompiler.UserDontCreateUser)) | ||
970 | { | ||
971 | user.CreateUser = Util.YesNoType.no; | ||
972 | } | ||
973 | |||
974 | if (UtilCompiler.UserNonVital == (attributes & UtilCompiler.UserNonVital)) | ||
975 | { | ||
976 | user.Vital = Util.YesNoType.no; | ||
977 | } | ||
978 | } | ||
979 | |||
980 | if (null != row[1]) | ||
981 | { | ||
982 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); | ||
983 | |||
984 | if (null != component) | ||
985 | { | ||
986 | component.AddChild(user); | ||
987 | } | ||
988 | else | ||
989 | { | ||
990 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); | ||
991 | } | ||
992 | } | ||
993 | else | ||
994 | { | ||
995 | this.Core.RootElement.AddChild(user); | ||
996 | } | ||
997 | this.Core.IndexElement(row, user); | ||
998 | } | ||
999 | } | ||
1000 | |||
1001 | /// <summary> | ||
1002 | /// Decompile the UserGroup table. | ||
1003 | /// </summary> | ||
1004 | /// <param name="table">The table to decompile.</param> | ||
1005 | private void DecompileUserGroupTable(Table table) | ||
1006 | { | ||
1007 | foreach (Row row in table.Rows) | ||
1008 | { | ||
1009 | Util.User user = (Util.User)this.Core.GetIndexedElement("User", (string)row[0]); | ||
1010 | |||
1011 | if (null != user) | ||
1012 | { | ||
1013 | Util.GroupRef groupRef = new Util.GroupRef(); | ||
1014 | |||
1015 | groupRef.Id = (string)row[1]; | ||
1016 | |||
1017 | user.AddChild(groupRef); | ||
1018 | } | ||
1019 | else | ||
1020 | { | ||
1021 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Group_", (string)row[0], "Group")); | ||
1022 | } | ||
1023 | } | ||
1024 | } | ||
1025 | |||
1026 | /// <summary> | ||
1027 | /// Decompile the XmlConfig table. | ||
1028 | /// </summary> | ||
1029 | /// <param name="table">The table to decompile.</param> | ||
1030 | private void DecompileXmlConfigTable(Table table) | ||
1031 | { | ||
1032 | foreach (Row row in table.Rows) | ||
1033 | { | ||
1034 | Util.XmlConfig xmlConfig = new Util.XmlConfig(); | ||
1035 | |||
1036 | xmlConfig.Id = (string)row[0]; | ||
1037 | |||
1038 | xmlConfig.File = (string)row[1]; | ||
1039 | |||
1040 | xmlConfig.ElementPath = (string)row[2]; | ||
1041 | |||
1042 | if (null != row[3]) | ||
1043 | { | ||
1044 | xmlConfig.VerifyPath = (string)row[3]; | ||
1045 | } | ||
1046 | |||
1047 | if (null != row[4]) | ||
1048 | { | ||
1049 | xmlConfig.Name = (string)row[4]; | ||
1050 | } | ||
1051 | |||
1052 | if (null != row[5]) | ||
1053 | { | ||
1054 | xmlConfig.Value = (string)row[5]; | ||
1055 | } | ||
1056 | |||
1057 | int flags = (int)row[6]; | ||
1058 | |||
1059 | if (0x1 == (flags & 0x1)) | ||
1060 | { | ||
1061 | xmlConfig.Node = Util.XmlConfig.NodeType.element; | ||
1062 | } | ||
1063 | else if (0x2 == (flags & 0x2)) | ||
1064 | { | ||
1065 | xmlConfig.Node = Util.XmlConfig.NodeType.value; | ||
1066 | } | ||
1067 | else if (0x4 == (flags & 0x4)) | ||
1068 | { | ||
1069 | xmlConfig.Node = Util.XmlConfig.NodeType.document; | ||
1070 | } | ||
1071 | |||
1072 | if (0x10 == (flags & 0x10)) | ||
1073 | { | ||
1074 | xmlConfig.Action = Util.XmlConfig.ActionType.create; | ||
1075 | } | ||
1076 | else if (0x20 == (flags & 0x20)) | ||
1077 | { | ||
1078 | xmlConfig.Action = Util.XmlConfig.ActionType.delete; | ||
1079 | } | ||
1080 | |||
1081 | if (0x100 == (flags & 0x100)) | ||
1082 | { | ||
1083 | xmlConfig.On = Util.XmlConfig.OnType.install; | ||
1084 | } | ||
1085 | else if (0x200 == (flags & 0x200)) | ||
1086 | { | ||
1087 | xmlConfig.On = Util.XmlConfig.OnType.uninstall; | ||
1088 | } | ||
1089 | |||
1090 | if (0x00001000 == (flags & 0x00001000)) | ||
1091 | { | ||
1092 | xmlConfig.PreserveModifiedDate = Util.YesNoType.yes; | ||
1093 | } | ||
1094 | |||
1095 | if (null != row[8]) | ||
1096 | { | ||
1097 | xmlConfig.Sequence = (int)row[8]; | ||
1098 | } | ||
1099 | |||
1100 | this.Core.IndexElement(row, xmlConfig); | ||
1101 | } | ||
1102 | } | ||
1103 | |||
1104 | /// <summary> | ||
1105 | /// Finalize the Perfmon table. | ||
1106 | /// </summary> | ||
1107 | /// <param name="tables">The collection of all tables.</param> | ||
1108 | /// <remarks> | ||
1109 | /// Since the PerfCounter element nests under a File element, but | ||
1110 | /// the Perfmon table does not have a foreign key relationship with | ||
1111 | /// the File table (instead it has a formatted string that usually | ||
1112 | /// refers to a file row - but doesn't have to), the nesting must | ||
1113 | /// be inferred during finalization. | ||
1114 | /// </remarks> | ||
1115 | private void FinalizePerfmonTable(TableIndexedCollection tables) | ||
1116 | { | ||
1117 | Table perfmonTable = tables["Perfmon"]; | ||
1118 | |||
1119 | if (null != perfmonTable) | ||
1120 | { | ||
1121 | foreach (Row row in perfmonTable.Rows) | ||
1122 | { | ||
1123 | string formattedFile = (string)row[1]; | ||
1124 | Util.PerfCounter perfCounter = (Util.PerfCounter)this.Core.GetIndexedElement(row); | ||
1125 | |||
1126 | // try to "de-format" the File column's value to determine the proper parent File element | ||
1127 | if ((formattedFile.StartsWith("[#", StringComparison.Ordinal) || formattedFile.StartsWith("[!", StringComparison.Ordinal)) | ||
1128 | && formattedFile.EndsWith("]", StringComparison.Ordinal)) | ||
1129 | { | ||
1130 | string fileId = formattedFile.Substring(2, formattedFile.Length - 3); | ||
1131 | |||
1132 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", fileId); | ||
1133 | if (null != file) | ||
1134 | { | ||
1135 | file.AddChild(perfCounter); | ||
1136 | } | ||
1137 | else | ||
1138 | { | ||
1139 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, perfmonTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File", formattedFile, "File")); | ||
1140 | } | ||
1141 | } | ||
1142 | else | ||
1143 | { | ||
1144 | this.Core.OnMessage(UtilErrors.IllegalFileValueInPerfmonOrManifest(formattedFile, "Perfmon")); | ||
1145 | } | ||
1146 | } | ||
1147 | } | ||
1148 | } | ||
1149 | |||
1150 | /// <summary> | ||
1151 | /// Finalize the PerfmonManifest table. | ||
1152 | /// </summary> | ||
1153 | /// <param name="tables">The collection of all tables.</param> | ||
1154 | private void FinalizePerfmonManifestTable(TableIndexedCollection tables) | ||
1155 | { | ||
1156 | Table perfmonManifestTable = tables["PerfmonManifest"]; | ||
1157 | |||
1158 | if (null != perfmonManifestTable) | ||
1159 | { | ||
1160 | foreach (Row row in perfmonManifestTable.Rows) | ||
1161 | { | ||
1162 | string formattedFile = (string)row[1]; | ||
1163 | Util.PerfCounterManifest perfCounterManifest = (Util.PerfCounterManifest)this.Core.GetIndexedElement(row); | ||
1164 | |||
1165 | // try to "de-format" the File column's value to determine the proper parent File element | ||
1166 | if ((formattedFile.StartsWith("[#", StringComparison.Ordinal) || formattedFile.StartsWith("[!", StringComparison.Ordinal)) | ||
1167 | && formattedFile.EndsWith("]", StringComparison.Ordinal)) | ||
1168 | { | ||
1169 | string fileId = formattedFile.Substring(2, formattedFile.Length - 3); | ||
1170 | |||
1171 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", fileId); | ||
1172 | if (null != file) | ||
1173 | { | ||
1174 | file.AddChild(perfCounterManifest); | ||
1175 | } | ||
1176 | else | ||
1177 | { | ||
1178 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, perfCounterManifest.ResourceFileDirectory, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File", formattedFile, "File")); | ||
1179 | } | ||
1180 | } | ||
1181 | else | ||
1182 | { | ||
1183 | this.Core.OnMessage(UtilErrors.IllegalFileValueInPerfmonOrManifest(formattedFile, "PerfmonManifest")); | ||
1184 | } | ||
1185 | } | ||
1186 | } | ||
1187 | } | ||
1188 | |||
1189 | /// <summary> | ||
1190 | /// Finalize the SecureObjects table. | ||
1191 | /// </summary> | ||
1192 | /// <param name="tables">The collection of all tables.</param> | ||
1193 | /// <remarks> | ||
1194 | /// Nests the PermissionEx elements below their parent elements. There are no declared foreign | ||
1195 | /// keys for the parents of the SecureObjects table. | ||
1196 | /// </remarks> | ||
1197 | private void FinalizeSecureObjectsTable(TableIndexedCollection tables) | ||
1198 | { | ||
1199 | Table createFolderTable = tables["CreateFolder"]; | ||
1200 | Table secureObjectsTable = tables["SecureObjects"]; | ||
1201 | |||
1202 | Hashtable createFolders = new Hashtable(); | ||
1203 | |||
1204 | // index the CreateFolder table because the foreign key to this table from the | ||
1205 | // LockPermissions table is only part of the primary key of this table | ||
1206 | if (null != createFolderTable) | ||
1207 | { | ||
1208 | foreach (Row row in createFolderTable.Rows) | ||
1209 | { | ||
1210 | Wix.CreateFolder createFolder = (Wix.CreateFolder)this.Core.GetIndexedElement(row); | ||
1211 | string directoryId = (string)row[0]; | ||
1212 | |||
1213 | if (!createFolders.Contains(directoryId)) | ||
1214 | { | ||
1215 | createFolders.Add(directoryId, new ArrayList()); | ||
1216 | } | ||
1217 | ((ArrayList)createFolders[directoryId]).Add(createFolder); | ||
1218 | } | ||
1219 | } | ||
1220 | |||
1221 | if (null != secureObjectsTable) | ||
1222 | { | ||
1223 | foreach (Row row in secureObjectsTable.Rows) | ||
1224 | { | ||
1225 | string id = (string)row[0]; | ||
1226 | string table = (string)row[1]; | ||
1227 | |||
1228 | Util.PermissionEx permissionEx = (Util.PermissionEx)this.Core.GetIndexedElement(row); | ||
1229 | |||
1230 | if ("CreateFolder" == table) | ||
1231 | { | ||
1232 | ArrayList createFolderElements = (ArrayList)createFolders[id]; | ||
1233 | |||
1234 | if (null != createFolderElements) | ||
1235 | { | ||
1236 | foreach (Wix.CreateFolder createFolder in createFolderElements) | ||
1237 | { | ||
1238 | createFolder.AddChild(permissionEx); | ||
1239 | } | ||
1240 | } | ||
1241 | else | ||
1242 | { | ||
1243 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, "SecureObjects", row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "LockObject", id, table)); | ||
1244 | } | ||
1245 | } | ||
1246 | else | ||
1247 | { | ||
1248 | Wix.IParentElement parentElement = (Wix.IParentElement)this.Core.GetIndexedElement(table, id); | ||
1249 | |||
1250 | if (null != parentElement) | ||
1251 | { | ||
1252 | parentElement.AddChild(permissionEx); | ||
1253 | } | ||
1254 | else | ||
1255 | { | ||
1256 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, "SecureObjects", row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "LockObject", id, table)); | ||
1257 | } | ||
1258 | } | ||
1259 | } | ||
1260 | } | ||
1261 | } | ||
1262 | |||
1263 | /// <summary> | ||
1264 | /// Finalize the ServiceConfig table. | ||
1265 | /// </summary> | ||
1266 | /// <param name="tables">The collection of all tables.</param> | ||
1267 | /// <remarks> | ||
1268 | /// Since there is no foreign key from the ServiceName column to the | ||
1269 | /// ServiceInstall table, this relationship must be handled late. | ||
1270 | /// </remarks> | ||
1271 | private void FinalizeServiceConfigTable(TableIndexedCollection tables) | ||
1272 | { | ||
1273 | Table serviceConfigTable = tables["ServiceConfig"]; | ||
1274 | Table serviceInstallTable = tables["ServiceInstall"]; | ||
1275 | |||
1276 | Hashtable serviceInstalls = new Hashtable(); | ||
1277 | |||
1278 | // index the ServiceInstall table because the foreign key used by the ServiceConfig | ||
1279 | // table is actually the ServiceInstall.Name, not the ServiceInstall.ServiceInstall | ||
1280 | // this is unfortunate because the service Name is not guaranteed to be unique, so | ||
1281 | // decompiler must assume there could be multiple matches and add the ServiceConfig to each | ||
1282 | // TODO: the Component column information should be taken into acount to accurately identify | ||
1283 | // the correct column to use | ||
1284 | if (null != serviceInstallTable) | ||
1285 | { | ||
1286 | foreach (Row row in serviceInstallTable.Rows) | ||
1287 | { | ||
1288 | string name = (string)row[1]; | ||
1289 | Wix.ServiceInstall serviceInstall = (Wix.ServiceInstall)this.Core.GetIndexedElement(row); | ||
1290 | |||
1291 | if (!serviceInstalls.Contains(name)) | ||
1292 | { | ||
1293 | serviceInstalls.Add(name, new ArrayList()); | ||
1294 | } | ||
1295 | |||
1296 | ((ArrayList)serviceInstalls[name]).Add(serviceInstall); | ||
1297 | } | ||
1298 | } | ||
1299 | |||
1300 | if (null != serviceConfigTable) | ||
1301 | { | ||
1302 | foreach (Row row in serviceConfigTable.Rows) | ||
1303 | { | ||
1304 | Util.ServiceConfig serviceConfig = (Util.ServiceConfig)this.Core.GetIndexedElement(row); | ||
1305 | |||
1306 | if (0 == (int)row[2]) | ||
1307 | { | ||
1308 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); | ||
1309 | |||
1310 | if (null != component) | ||
1311 | { | ||
1312 | component.AddChild(serviceConfig); | ||
1313 | } | ||
1314 | else | ||
1315 | { | ||
1316 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); | ||
1317 | } | ||
1318 | } | ||
1319 | else | ||
1320 | { | ||
1321 | ArrayList serviceInstallElements = (ArrayList)serviceInstalls[row[0]]; | ||
1322 | |||
1323 | if (null != serviceInstallElements) | ||
1324 | { | ||
1325 | foreach (Wix.ServiceInstall serviceInstall in serviceInstallElements) | ||
1326 | { | ||
1327 | serviceInstall.AddChild(serviceConfig); | ||
1328 | } | ||
1329 | } | ||
1330 | else | ||
1331 | { | ||
1332 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ServiceName", (string)row[0], "ServiceInstall")); | ||
1333 | } | ||
1334 | } | ||
1335 | } | ||
1336 | } | ||
1337 | } | ||
1338 | |||
1339 | /// <summary> | ||
1340 | /// Finalize the XmlConfig table. | ||
1341 | /// </summary> | ||
1342 | /// <param name="tables">Collection of all tables.</param> | ||
1343 | private void FinalizeXmlConfigTable(TableIndexedCollection tables) | ||
1344 | { | ||
1345 | Table xmlConfigTable = tables["XmlConfig"]; | ||
1346 | |||
1347 | if (null != xmlConfigTable) | ||
1348 | { | ||
1349 | foreach (Row row in xmlConfigTable.Rows) | ||
1350 | { | ||
1351 | Util.XmlConfig xmlConfig = (Util.XmlConfig)this.Core.GetIndexedElement(row); | ||
1352 | |||
1353 | if (null == row[6] || 0 == (int)row[6]) | ||
1354 | { | ||
1355 | Util.XmlConfig parentXmlConfig = (Util.XmlConfig)this.Core.GetIndexedElement("XmlConfig", (string)row[2]); | ||
1356 | |||
1357 | if (null != parentXmlConfig) | ||
1358 | { | ||
1359 | parentXmlConfig.AddChild(xmlConfig); | ||
1360 | } | ||
1361 | else | ||
1362 | { | ||
1363 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, xmlConfigTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ElementPath", (string)row[2], "XmlConfig")); | ||
1364 | } | ||
1365 | } | ||
1366 | else | ||
1367 | { | ||
1368 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[7]); | ||
1369 | |||
1370 | if (null != component) | ||
1371 | { | ||
1372 | component.AddChild(xmlConfig); | ||
1373 | } | ||
1374 | else | ||
1375 | { | ||
1376 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, xmlConfigTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[7], "Component")); | ||
1377 | } | ||
1378 | } | ||
1379 | } | ||
1380 | } | ||
1381 | } | ||
1382 | |||
1383 | |||
1384 | /// <summary> | ||
1385 | /// Finalize the XmlFile table. | ||
1386 | /// </summary> | ||
1387 | /// <param name="tables">The collection of all tables.</param> | ||
1388 | /// <remarks> | ||
1389 | /// Some of the XmlFile table rows are compiler generated from util:EventManifest node | ||
1390 | /// These rows should not be appended to component. | ||
1391 | /// </remarks> | ||
1392 | private void FinalizeXmlFileTable(TableIndexedCollection tables) | ||
1393 | { | ||
1394 | Table xmlFileTable = tables["XmlFile"]; | ||
1395 | Table eventManifestTable = tables["EventManifest"]; | ||
1396 | |||
1397 | if (null != xmlFileTable) | ||
1398 | { | ||
1399 | foreach (Row row in xmlFileTable.Rows) | ||
1400 | { | ||
1401 | bool bManifestGenerated = false; | ||
1402 | string xmlFileConfigId = (string)row[0]; | ||
1403 | if (null != eventManifestTable) | ||
1404 | { | ||
1405 | foreach (Row emrow in eventManifestTable.Rows) | ||
1406 | { | ||
1407 | string formattedFile = (string)emrow[1]; | ||
1408 | if ((formattedFile.StartsWith("[#", StringComparison.Ordinal) || formattedFile.StartsWith("[!", StringComparison.Ordinal)) | ||
1409 | && formattedFile.EndsWith("]", StringComparison.Ordinal)) | ||
1410 | { | ||
1411 | string fileId = formattedFile.Substring(2, formattedFile.Length - 3); | ||
1412 | if (String.Equals(String.Concat("Config_", fileId, "ResourceFile"), xmlFileConfigId)) | ||
1413 | { | ||
1414 | Util.EventManifest eventManifest = (Util.EventManifest)this.Core.GetIndexedElement(emrow); | ||
1415 | if (null != eventManifest) | ||
1416 | { | ||
1417 | eventManifest.ResourceFile = (string)row[4]; | ||
1418 | } | ||
1419 | bManifestGenerated = true; | ||
1420 | } | ||
1421 | |||
1422 | else if (String.Equals(String.Concat("Config_", fileId, "MessageFile"), xmlFileConfigId)) | ||
1423 | { | ||
1424 | Util.EventManifest eventManifest = (Util.EventManifest)this.Core.GetIndexedElement(emrow); | ||
1425 | if (null != eventManifest) | ||
1426 | { | ||
1427 | eventManifest.MessageFile = (string)row[4]; | ||
1428 | } | ||
1429 | bManifestGenerated = true; | ||
1430 | } | ||
1431 | } | ||
1432 | } | ||
1433 | } | ||
1434 | |||
1435 | if (true == bManifestGenerated) | ||
1436 | continue; | ||
1437 | |||
1438 | Util.XmlFile xmlFile = new Util.XmlFile(); | ||
1439 | |||
1440 | xmlFile.Id = (string)row[0]; | ||
1441 | xmlFile.File = (string)row[1]; | ||
1442 | xmlFile.ElementPath = (string)row[2]; | ||
1443 | |||
1444 | if (null != row[3]) | ||
1445 | { | ||
1446 | xmlFile.Name = (string)row[3]; | ||
1447 | } | ||
1448 | |||
1449 | if (null != row[4]) | ||
1450 | { | ||
1451 | xmlFile.Value = (string)row[4]; | ||
1452 | } | ||
1453 | |||
1454 | int flags = (int)row[5]; | ||
1455 | if (0x1 == (flags & 0x1) && 0x2 == (flags & 0x2)) | ||
1456 | { | ||
1457 | this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, xmlFileTable.Name, row.Fields[5].Column.Name, row[5])); | ||
1458 | } | ||
1459 | else if (0x1 == (flags & 0x1)) | ||
1460 | { | ||
1461 | xmlFile.Action = Util.XmlFile.ActionType.createElement; | ||
1462 | } | ||
1463 | else if (0x2 == (flags & 0x2)) | ||
1464 | { | ||
1465 | xmlFile.Action = Util.XmlFile.ActionType.deleteValue; | ||
1466 | } | ||
1467 | else | ||
1468 | { | ||
1469 | xmlFile.Action = Util.XmlFile.ActionType.setValue; | ||
1470 | } | ||
1471 | |||
1472 | if (0x100 == (flags & 0x100)) | ||
1473 | { | ||
1474 | xmlFile.SelectionLanguage = Util.XmlFile.SelectionLanguageType.XPath; | ||
1475 | } | ||
1476 | |||
1477 | if (0x00001000 == (flags & 0x00001000)) | ||
1478 | { | ||
1479 | xmlFile.PreserveModifiedDate = Util.YesNoType.yes; | ||
1480 | } | ||
1481 | |||
1482 | if (0x00010000 == (flags & 0x00010000)) | ||
1483 | { | ||
1484 | xmlFile.Permanent = Util.YesNoType.yes; | ||
1485 | } | ||
1486 | |||
1487 | if (null != row[7]) | ||
1488 | { | ||
1489 | xmlFile.Sequence = (int)row[7]; | ||
1490 | } | ||
1491 | |||
1492 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[6]); | ||
1493 | |||
1494 | if (null != component) | ||
1495 | { | ||
1496 | component.AddChild(xmlFile); | ||
1497 | } | ||
1498 | else | ||
1499 | { | ||
1500 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, xmlFileTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[6], "Component")); | ||
1501 | } | ||
1502 | } | ||
1503 | } | ||
1504 | } | ||
1505 | |||
1506 | /// <summary> | ||
1507 | /// Finalize the eventManifest table. | ||
1508 | /// This function must be called after FinalizeXmlFileTable | ||
1509 | /// </summary> | ||
1510 | /// <param name="tables">The collection of all tables.</param> | ||
1511 | private void FinalizeEventManifestTable(TableIndexedCollection tables) | ||
1512 | { | ||
1513 | Table eventManifestTable = tables["EventManifest"]; | ||
1514 | |||
1515 | if (null != eventManifestTable) | ||
1516 | { | ||
1517 | foreach (Row row in eventManifestTable.Rows) | ||
1518 | { | ||
1519 | string formattedFile = (string)row[1]; | ||
1520 | Util.EventManifest eventManifest = (Util.EventManifest)this.Core.GetIndexedElement(row); | ||
1521 | |||
1522 | // try to "de-format" the File column's value to determine the proper parent File element | ||
1523 | if ((formattedFile.StartsWith("[#", StringComparison.Ordinal) || formattedFile.StartsWith("[!", StringComparison.Ordinal)) | ||
1524 | && formattedFile.EndsWith("]", StringComparison.Ordinal)) | ||
1525 | { | ||
1526 | string fileId = formattedFile.Substring(2, formattedFile.Length - 3); | ||
1527 | |||
1528 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", fileId); | ||
1529 | if (null != file) | ||
1530 | { | ||
1531 | file.AddChild(eventManifest); | ||
1532 | } | ||
1533 | } | ||
1534 | else | ||
1535 | { | ||
1536 | this.Core.OnMessage(UtilErrors.IllegalFileValueInPerfmonOrManifest(formattedFile, "EventManifest")); | ||
1537 | } | ||
1538 | } | ||
1539 | } | ||
1540 | } | ||
1541 | } | ||
1542 | #endif | ||
1543 | } | ||