aboutsummaryrefslogtreecommitdiff
path: root/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs')
-rw-r--r--src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs b/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs
index e3fd9f51..575252b0 100644
--- a/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs
+++ b/src/wix/WixToolset.Core.Burn/Bundles/BurnReader.cs
@@ -78,7 +78,7 @@ namespace WixToolset.Core.Burn.Bundles
78 public bool ExtractUXContainer(string outputDirectory, string tempDirectory) 78 public bool ExtractUXContainer(string outputDirectory, string tempDirectory)
79 { 79 {
80 // No UX container to extract 80 // No UX container to extract
81 if (this.UXAddress == 0 || this.UXSize == 0) 81 if (this.AttachedContainers.Count == 0)
82 { 82 {
83 return false; 83 return false;
84 } 84 }
@@ -92,11 +92,12 @@ namespace WixToolset.Core.Burn.Bundles
92 string tempCabPath = Path.Combine(tempDirectory, "ux.cab"); 92 string tempCabPath = Path.Combine(tempDirectory, "ux.cab");
93 string manifestOriginalPath = Path.Combine(outputDirectory, "0"); 93 string manifestOriginalPath = Path.Combine(outputDirectory, "0");
94 string manifestPath = Path.Combine(outputDirectory, "manifest.xml"); 94 string manifestPath = Path.Combine(outputDirectory, "manifest.xml");
95 var uxContainerSlot = this.AttachedContainers[0];
95 96
96 this.binaryReader.BaseStream.Seek(this.UXAddress, SeekOrigin.Begin); 97 this.binaryReader.BaseStream.Seek(this.UXAddress, SeekOrigin.Begin);
97 using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write)) 98 using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write))
98 { 99 {
99 BurnCommon.CopyStream(this.binaryReader.BaseStream, tempCab, (int)this.UXSize); 100 BurnCommon.CopyStream(this.binaryReader.BaseStream, tempCab, (int)uxContainerSlot.Size);
100 } 101 }
101 102
102 var cabinet = new Cabinet(tempCabPath); 103 var cabinet = new Cabinet(tempCabPath);
@@ -152,14 +153,15 @@ namespace WixToolset.Core.Burn.Bundles
152 } 153 }
153 154
154 /// <summary> 155 /// <summary>
155 /// Gets the attached container from the exe and extracts its contents to the output directory. 156 /// Gets each non-UX attached container from the exe and extracts its contents to the output directory.
156 /// </summary> 157 /// </summary>
157 /// <param name="outputDirectory">Directory to write extracted files to.</param> 158 /// <param name="outputDirectory">Directory to write extracted files to.</param>
159 /// <param name="tempDirectory">Scratch directory.</param>
158 /// <returns>True if successful, false otherwise</returns> 160 /// <returns>True if successful, false otherwise</returns>
159 public bool ExtractAttachedContainers(string outputDirectory) 161 public bool ExtractAttachedContainers(string outputDirectory, string tempDirectory)
160 { 162 {
161 // No attached container to extract 163 // No attached containers to extract
162 if (this.AttachedContainers.Count == 0) 164 if (this.AttachedContainers.Count < 2)
163 { 165 {
164 return false; 166 return false;
165 } 167 }
@@ -170,11 +172,13 @@ namespace WixToolset.Core.Burn.Bundles
170 } 172 }
171 173
172 Directory.CreateDirectory(outputDirectory); 174 Directory.CreateDirectory(outputDirectory);
173 foreach (ContainerSlot cntnr in this.AttachedContainers) 175 uint nextAddress = this.EngineSize;
176 for (int i = 1; i < this.AttachedContainers.Count; i++)
174 { 177 {
175 string tempCabPath = Path.GetTempFileName(); 178 ContainerSlot cntnr = this.AttachedContainers[i];
179 string tempCabPath = Path.Combine(tempDirectory, $"a{i}.cab");
176 180
177 this.binaryReader.BaseStream.Seek(cntnr.Address, SeekOrigin.Begin); 181 this.binaryReader.BaseStream.Seek(nextAddress, SeekOrigin.Begin);
178 using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write)) 182 using (Stream tempCab = File.Open(tempCabPath, FileMode.Create, FileAccess.Write))
179 { 183 {
180 BurnCommon.CopyStream(this.binaryReader.BaseStream, tempCab, (int)cntnr.Size); 184 BurnCommon.CopyStream(this.binaryReader.BaseStream, tempCab, (int)cntnr.Size);
@@ -182,6 +186,8 @@ namespace WixToolset.Core.Burn.Bundles
182 186
183 var cabinet = new Cabinet(tempCabPath); 187 var cabinet = new Cabinet(tempCabPath);
184 cabinet.Extract(outputDirectory); 188 cabinet.Extract(outputDirectory);
189
190 nextAddress += cntnr.Size;
185 } 191 }
186 192
187 foreach (DictionaryEntry entry in this.attachedContainerPayloadNames) 193 foreach (DictionaryEntry entry in this.attachedContainerPayloadNames)