aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Burn/Bundles/BurnCommon.cs')
-rw-r--r--src/WixToolset.Core.Burn/Bundles/BurnCommon.cs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs
index bca1be72..ab3b7896 100644
--- a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs
+++ b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs
@@ -111,7 +111,7 @@ namespace WixToolset.Core.Burn.Bundles
111 /// <param name="fileExe">File to modify in-place.</param> 111 /// <param name="fileExe">File to modify in-place.</param>
112 public BurnCommon(IMessaging messaging, string fileExe) 112 public BurnCommon(IMessaging messaging, string fileExe)
113 { 113 {
114 this.messaging = messaging; 114 this.Messaging = messaging;
115 this.fileExe = fileExe; 115 this.fileExe = fileExe;
116 } 116 }
117 117
@@ -130,7 +130,7 @@ namespace WixToolset.Core.Burn.Bundles
130 public UInt32 AttachedContainerAddress { get; protected set; } 130 public UInt32 AttachedContainerAddress { get; protected set; }
131 public UInt32 AttachedContainerSize { get; protected set; } 131 public UInt32 AttachedContainerSize { get; protected set; }
132 132
133 protected IMessaging messaging { get; } 133 protected IMessaging Messaging { get; }
134 134
135 public void Dispose() 135 public void Dispose()
136 { 136 {
@@ -147,12 +147,11 @@ namespace WixToolset.Core.Burn.Bundles
147 /// <param name="size">Optional count of bytes to copy. 0 indicates whole input stream from current should be copied.</param> 147 /// <param name="size">Optional count of bytes to copy. 0 indicates whole input stream from current should be copied.</param>
148 protected static int CopyStream(Stream input, Stream output, int size) 148 protected static int CopyStream(Stream input, Stream output, int size)
149 { 149 {
150 byte[] bytes = new byte[4096]; 150 var bytes = new byte[4096];
151 int total = 0; 151 var total = 0;
152 int read = 0;
153 do 152 do
154 { 153 {
155 read = Math.Min(bytes.Length, size - total); 154 var read = Math.Min(bytes.Length, size - total);
156 read = input.Read(bytes, 0, read); 155 read = input.Read(bytes, 0, read);
157 if (0 == read) 156 if (0 == read)
158 { 157 {
@@ -185,21 +184,21 @@ namespace WixToolset.Core.Burn.Bundles
185 uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_MAGIC); 184 uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_MAGIC);
186 if (BURN_SECTION_MAGIC != uint32) 185 if (BURN_SECTION_MAGIC != uint32)
187 { 186 {
188 this.messaging.Write(ErrorMessages.InvalidBundle(this.fileExe)); 187 this.Messaging.Write(ErrorMessages.InvalidBundle(this.fileExe));
189 return false; 188 return false;
190 } 189 }
191 190
192 this.Version = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_VERSION); 191 this.Version = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_VERSION);
193 if (BURN_SECTION_VERSION != this.Version) 192 if (BURN_SECTION_VERSION != this.Version)
194 { 193 {
195 this.messaging.Write(ErrorMessages.BundleTooNew(this.fileExe, this.Version)); 194 this.Messaging.Write(ErrorMessages.BundleTooNew(this.fileExe, this.Version));
196 return false; 195 return false;
197 } 196 }
198 197
199 uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_FORMAT); // We only know how to deal with CABs right now 198 uint32 = BurnCommon.ReadUInt32(bytes, BURN_SECTION_OFFSET_FORMAT); // We only know how to deal with CABs right now
200 if (1 != uint32) 199 if (1 != uint32)
201 { 200 {
202 this.messaging.Write(ErrorMessages.InvalidBundle(this.fileExe)); 201 this.Messaging.Write(ErrorMessages.InvalidBundle(this.fileExe));
203 return false; 202 return false;
204 } 203 }
205 204
@@ -266,7 +265,7 @@ namespace WixToolset.Core.Burn.Bundles
266 265
267 if (UInt32.MaxValue == wixburnSectionOffset) 266 if (UInt32.MaxValue == wixburnSectionOffset)
268 { 267 {
269 this.messaging.Write(ErrorMessages.StubMissingWixburnSection(this.fileExe)); 268 this.Messaging.Write(ErrorMessages.StubMissingWixburnSection(this.fileExe));
270 return false; 269 return false;
271 } 270 }
272 271
@@ -274,7 +273,7 @@ namespace WixToolset.Core.Burn.Bundles
274 // the smallest alignment (512 bytes), but just to be paranoid... 273 // the smallest alignment (512 bytes), but just to be paranoid...
275 if (BURN_SECTION_SIZE > BurnCommon.ReadUInt32(bytes, IMAGE_SECTION_HEADER_OFFSET_SIZEOFRAWDATA)) 274 if (BURN_SECTION_SIZE > BurnCommon.ReadUInt32(bytes, IMAGE_SECTION_HEADER_OFFSET_SIZEOFRAWDATA))
276 { 275 {
277 this.messaging.Write(ErrorMessages.StubWixburnSectionTooSmall(this.fileExe)); 276 this.Messaging.Write(ErrorMessages.StubWixburnSectionTooSmall(this.fileExe));
278 return false; 277 return false;
279 } 278 }
280 279
@@ -303,7 +302,7 @@ namespace WixToolset.Core.Burn.Bundles
303 // Verify the NT signature... 302 // Verify the NT signature...
304 if (IMAGE_NT_SIGNATURE != BurnCommon.ReadUInt32(bytes, IMAGE_NT_HEADER_OFFSET_SIGNATURE)) 303 if (IMAGE_NT_SIGNATURE != BurnCommon.ReadUInt32(bytes, IMAGE_NT_HEADER_OFFSET_SIGNATURE))
305 { 304 {
306 this.messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe)); 305 this.Messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe));
307 return false; 306 return false;
308 } 307 }
309 308
@@ -338,7 +337,7 @@ namespace WixToolset.Core.Burn.Bundles
338 // Verify the DOS 'MZ' signature. 337 // Verify the DOS 'MZ' signature.
339 if (IMAGE_DOS_SIGNATURE != BurnCommon.ReadUInt16(bytes, IMAGE_DOS_HEADER_OFFSET_MAGIC)) 338 if (IMAGE_DOS_SIGNATURE != BurnCommon.ReadUInt16(bytes, IMAGE_DOS_HEADER_OFFSET_MAGIC))
340 { 339 {
341 this.messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe)); 340 this.Messaging.Write(ErrorMessages.InvalidStubExe(this.fileExe));
342 return false; 341 return false;
343 } 342 }
344 343