diff options
Diffstat (limited to 'src/WixToolset.Core.Burn')
-rw-r--r-- | src/WixToolset.Core.Burn/Bundles/BurnCommon.cs | 21 | ||||
-rw-r--r-- | src/WixToolset.Core.Burn/Bundles/BurnReader.cs | 9 | ||||
-rw-r--r-- | src/WixToolset.Core.Burn/Bundles/BurnWriter.cs | 11 | ||||
-rw-r--r-- | src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs | 2 |
4 files changed, 24 insertions, 19 deletions
diff --git a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs index 0baa6094..df328eb6 100644 --- a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs +++ b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs | |||
@@ -6,6 +6,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
6 | using System.Diagnostics; | 6 | using System.Diagnostics; |
7 | using System.IO; | 7 | using System.IO; |
8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.Extensibility.Services; | ||
9 | 10 | ||
10 | /// <summary> | 11 | /// <summary> |
11 | /// Common functionality for Burn PE Writer & Reader for the WiX toolset. | 12 | /// Common functionality for Burn PE Writer & Reader for the WiX toolset. |
@@ -77,7 +78,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
77 | 78 | ||
78 | protected const UInt32 BURN_SECTION_MAGIC = 0x00f14300; | 79 | protected const UInt32 BURN_SECTION_MAGIC = 0x00f14300; |
79 | protected const UInt32 BURN_SECTION_VERSION = 0x00000002; | 80 | protected const UInt32 BURN_SECTION_VERSION = 0x00000002; |
80 | |||
81 | protected string fileExe; | 81 | protected string fileExe; |
82 | protected UInt32 peOffset = UInt32.MaxValue; | 82 | protected UInt32 peOffset = UInt32.MaxValue; |
83 | protected UInt16 sections = UInt16.MaxValue; | 83 | protected UInt16 sections = UInt16.MaxValue; |
@@ -103,8 +103,9 @@ namespace WixToolset.Core.Burn.Bundles | |||
103 | /// </summary> | 103 | /// </summary> |
104 | /// <param name="fileExe">File to modify in-place.</param> | 104 | /// <param name="fileExe">File to modify in-place.</param> |
105 | /// <param name="bundleGuid">GUID for the bundle.</param> | 105 | /// <param name="bundleGuid">GUID for the bundle.</param> |
106 | public BurnCommon(string fileExe) | 106 | public BurnCommon(IMessaging messaging, string fileExe) |
107 | { | 107 | { |
108 | this.messaging = messaging; | ||
108 | this.fileExe = fileExe; | 109 | this.fileExe = fileExe; |
109 | } | 110 | } |
110 | 111 | ||
@@ -123,6 +124,8 @@ namespace WixToolset.Core.Burn.Bundles | |||
123 | public UInt32 AttachedContainerAddress { get; protected set; } | 124 | public UInt32 AttachedContainerAddress { get; protected set; } |
124 | public UInt32 AttachedContainerSize { get; protected set; } | 125 | public UInt32 AttachedContainerSize { get; protected set; } |
125 | 126 | ||
127 | protected IMessaging messaging { get; } | ||
128 | |||
126 | public void Dispose() | 129 | public void Dispose() |
127 | { | 130 | { |
128 | Dispose(true); | 131 | Dispose(true); |
@@ -176,21 +179,21 @@ namespace WixToolset.Core.Burn.Bundles | |||
176 | uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_MAGIC); | 179 | uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_MAGIC); |
177 | if (BURN_SECTION_MAGIC != uint32) | 180 | if (BURN_SECTION_MAGIC != uint32) |
178 | { | 181 | { |
179 | Messaging.Instance.OnMessage(WixErrors.InvalidBundle(this.fileExe)); | 182 | this.messaging.Write(ErrorMessages.InvalidBundle(this.fileExe)); |
180 | return false; | 183 | return false; |
181 | } | 184 | } |
182 | 185 | ||
183 | this.Version = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_VERSION); | 186 | this.Version = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_VERSION); |
184 | if (BURN_SECTION_VERSION != this.Version) | 187 | if (BURN_SECTION_VERSION != this.Version) |
185 | { | 188 | { |
186 | Messaging.Instance.OnMessage(WixErrors.BundleTooNew(this.fileExe, this.Version)); | 189 | this.messaging.Write(ErrorMessages.BundleTooNew(this.fileExe, this.Version)); |
187 | return false; | 190 | return false; |
188 | } | 191 | } |
189 | 192 | ||
190 | uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_FORMAT); // We only know how to deal with CABs right now | 193 | uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_FORMAT); // We only know how to deal with CABs right now |
191 | if (1 != uint32) | 194 | if (1 != uint32) |
192 | { | 195 | { |
193 | Messaging.Instance.OnMessage(WixErrors.InvalidBundle(this.fileExe)); | 196 | this.messaging.Write(ErrorMessages.InvalidBundle(this.fileExe)); |
194 | return false; | 197 | return false; |
195 | } | 198 | } |
196 | 199 | ||
@@ -257,7 +260,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
257 | 260 | ||
258 | if (UInt32.MaxValue == wixburnSectionOffset) | 261 | if (UInt32.MaxValue == wixburnSectionOffset) |
259 | { | 262 | { |
260 | Messaging.Instance.OnMessage(WixErrors.StubMissingWixburnSection(this.fileExe)); | 263 | this.messaging.Write(ErrorMessages.StubMissingWixburnSection(this.fileExe)); |
261 | return false; | 264 | return false; |
262 | } | 265 | } |
263 | 266 | ||
@@ -265,7 +268,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
265 | // the smallest alignment (512 bytes), but just to be paranoid... | 268 | // the smallest alignment (512 bytes), but just to be paranoid... |
266 | if (BURN_SECTION_SIZE > BurnCommon.ReadUInt32(bytes, IMAGE_SECTION_HEADER_OFFSET_SIZEOFRAWDATA)) | 269 | if (BURN_SECTION_SIZE > BurnCommon.ReadUInt32(bytes, IMAGE_SECTION_HEADER_OFFSET_SIZEOFRAWDATA)) |
267 | { | 270 | { |
268 | Messaging.Instance.OnMessage(WixErrors.StubWixburnSectionTooSmall(this.fileExe)); | 271 | this.messaging.Write(ErrorMessages.StubWixburnSectionTooSmall(this.fileExe)); |
269 | return false; | 272 | return false; |
270 | } | 273 | } |
271 | 274 | ||
@@ -294,7 +297,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
294 | // Verify the NT signature... | 297 | // Verify the NT signature... |
295 | if (IMAGE_NT_SIGNATURE != BurnCommon.ReadUInt32(bytes, IMAGE_NT_HEADER_OFFSET_SIGNATURE)) | 298 | if (IMAGE_NT_SIGNATURE != BurnCommon.ReadUInt32(bytes, IMAGE_NT_HEADER_OFFSET_SIGNATURE)) |
296 | { | 299 | { |
297 | Messaging.Instance.OnMessage(WixErrors.InvalidStubExe(this.fileExe)); | 300 | this.messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe)); |
298 | return false; | 301 | return false; |
299 | } | 302 | } |
300 | 303 | ||
@@ -329,7 +332,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
329 | // Verify the DOS 'MZ' signature. | 332 | // Verify the DOS 'MZ' signature. |
330 | if (IMAGE_DOS_SIGNATURE != BurnCommon.ReadUInt16(bytes, IMAGE_DOS_HEADER_OFFSET_MAGIC)) | 333 | if (IMAGE_DOS_SIGNATURE != BurnCommon.ReadUInt16(bytes, IMAGE_DOS_HEADER_OFFSET_MAGIC)) |
331 | { | 334 | { |
332 | Messaging.Instance.OnMessage(WixErrors.InvalidStubExe(this.fileExe)); | 335 | this.messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe)); |
333 | return false; | 336 | return false; |
334 | } | 337 | } |
335 | 338 | ||
diff --git a/src/WixToolset.Core.Burn/Bundles/BurnReader.cs b/src/WixToolset.Core.Burn/Bundles/BurnReader.cs index 3b3076c4..b4e23623 100644 --- a/src/WixToolset.Core.Burn/Bundles/BurnReader.cs +++ b/src/WixToolset.Core.Burn/Bundles/BurnReader.cs | |||
@@ -8,6 +8,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
8 | using System.IO; | 8 | using System.IO; |
9 | using System.Xml; | 9 | using System.Xml; |
10 | using WixToolset.Core.Native; | 10 | using WixToolset.Core.Native; |
11 | using WixToolset.Extensibility.Services; | ||
11 | 12 | ||
12 | /// <summary> | 13 | /// <summary> |
13 | /// Burn PE reader for the WiX toolset. | 14 | /// Burn PE reader for the WiX toolset. |
@@ -32,8 +33,8 @@ namespace WixToolset.Core.Burn.Bundles | |||
32 | /// Creates a BurnReader for reading a PE file. | 33 | /// Creates a BurnReader for reading a PE file. |
33 | /// </summary> | 34 | /// </summary> |
34 | /// <param name="fileExe">File to read.</param> | 35 | /// <param name="fileExe">File to read.</param> |
35 | private BurnReader(string fileExe) | 36 | private BurnReader(IMessaging messaging, string fileExe) |
36 | : base(fileExe) | 37 | : base(messaging, fileExe) |
37 | { | 38 | { |
38 | this.attachedContainerPayloadNames = new List<DictionaryEntry>(); | 39 | this.attachedContainerPayloadNames = new List<DictionaryEntry>(); |
39 | } | 40 | } |
@@ -59,9 +60,9 @@ namespace WixToolset.Core.Burn.Bundles | |||
59 | /// </summary> | 60 | /// </summary> |
60 | /// <param name="fileExe">Path to file.</param> | 61 | /// <param name="fileExe">Path to file.</param> |
61 | /// <returns>Burn reader.</returns> | 62 | /// <returns>Burn reader.</returns> |
62 | public static BurnReader Open(string fileExe) | 63 | public static BurnReader Open(IMessaging messaging, string fileExe) |
63 | { | 64 | { |
64 | BurnReader reader = new BurnReader(fileExe); | 65 | BurnReader reader = new BurnReader(messaging, fileExe); |
65 | 66 | ||
66 | reader.binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)); | 67 | reader.binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)); |
67 | if (!reader.Initialize(reader.binaryReader)) | 68 | if (!reader.Initialize(reader.binaryReader)) |
diff --git a/src/WixToolset.Core.Burn/Bundles/BurnWriter.cs b/src/WixToolset.Core.Burn/Bundles/BurnWriter.cs index e7365212..08eeaa15 100644 --- a/src/WixToolset.Core.Burn/Bundles/BurnWriter.cs +++ b/src/WixToolset.Core.Burn/Bundles/BurnWriter.cs | |||
@@ -6,6 +6,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
6 | using System.Diagnostics; | 6 | using System.Diagnostics; |
7 | using System.IO; | 7 | using System.IO; |
8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.Extensibility.Services; | ||
9 | 10 | ||
10 | /// <summary> | 11 | /// <summary> |
11 | /// Burn PE writer for the WiX toolset. | 12 | /// Burn PE writer for the WiX toolset. |
@@ -30,8 +31,8 @@ namespace WixToolset.Core.Burn.Bundles | |||
30 | /// </summary> | 31 | /// </summary> |
31 | /// <param name="fileExe">File to modify in-place.</param> | 32 | /// <param name="fileExe">File to modify in-place.</param> |
32 | /// <param name="bundleGuid">GUID for the bundle.</param> | 33 | /// <param name="bundleGuid">GUID for the bundle.</param> |
33 | private BurnWriter(string fileExe) | 34 | private BurnWriter(IMessaging messaging, string fileExe) |
34 | : base(fileExe) | 35 | : base(messaging, fileExe) |
35 | { | 36 | { |
36 | } | 37 | } |
37 | 38 | ||
@@ -40,9 +41,9 @@ namespace WixToolset.Core.Burn.Bundles | |||
40 | /// </summary> | 41 | /// </summary> |
41 | /// <param name="fileExe">Path to file.</param> | 42 | /// <param name="fileExe">Path to file.</param> |
42 | /// <returns>Burn writer.</returns> | 43 | /// <returns>Burn writer.</returns> |
43 | public static BurnWriter Open(string fileExe) | 44 | public static BurnWriter Open(IMessaging messaging, string fileExe) |
44 | { | 45 | { |
45 | BurnWriter writer = new BurnWriter(fileExe); | 46 | BurnWriter writer = new BurnWriter(messaging, fileExe); |
46 | 47 | ||
47 | using (BinaryReader binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))) | 48 | using (BinaryReader binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))) |
48 | { | 49 | { |
@@ -76,7 +77,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
76 | this.WriteToBurnSectionOffset(BURN_SECTION_OFFSET_MAGIC, BURN_SECTION_MAGIC); | 77 | this.WriteToBurnSectionOffset(BURN_SECTION_OFFSET_MAGIC, BURN_SECTION_MAGIC); |
77 | this.WriteToBurnSectionOffset(BURN_SECTION_OFFSET_VERSION, BURN_SECTION_VERSION); | 78 | this.WriteToBurnSectionOffset(BURN_SECTION_OFFSET_VERSION, BURN_SECTION_VERSION); |
78 | 79 | ||
79 | Messaging.Instance.OnMessage(WixVerboses.BundleGuid(bundleId.ToString("B"))); | 80 | this.messaging.Write(VerboseMessages.BundleGuid(bundleId.ToString("B"))); |
80 | this.binaryWriter.BaseStream.Seek(this.wixburnDataOffset + BURN_SECTION_OFFSET_BUNDLEGUID, SeekOrigin.Begin); | 81 | this.binaryWriter.BaseStream.Seek(this.wixburnDataOffset + BURN_SECTION_OFFSET_BUNDLEGUID, SeekOrigin.Begin); |
81 | this.binaryWriter.Write(bundleId.ToByteArray()); | 82 | this.binaryWriter.Write(bundleId.ToByteArray()); |
82 | 83 | ||
diff --git a/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs index 5eb76479..0dea8b1d 100644 --- a/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs +++ b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs | |||
@@ -29,7 +29,7 @@ namespace WixToolset.Core.Burn.Inscribe | |||
29 | { | 29 | { |
30 | reader.Stream.Seek(reader.AttachedContainerAddress, SeekOrigin.Begin); | 30 | reader.Stream.Seek(reader.AttachedContainerAddress, SeekOrigin.Begin); |
31 | 31 | ||
32 | using (BurnWriter writer = BurnWriter.Open(tempFile)) | 32 | using (BurnWriter writer = BurnWriter.Open(this.Context.Messaging, tempFile)) |
33 | { | 33 | { |
34 | writer.RememberThenResetSignature(); | 34 | writer.RememberThenResetSignature(); |
35 | writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached); | 35 | writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached); |