diff options
Diffstat (limited to 'src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs')
-rw-r--r-- | src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs new file mode 100644 index 00000000..5eb76479 --- /dev/null +++ b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs | |||
@@ -0,0 +1,53 @@ | |||
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.Core.Burn.Inscribe | ||
4 | { | ||
5 | using System.IO; | ||
6 | using WixToolset.Core.Burn.Bundles; | ||
7 | using WixToolset.Extensibility; | ||
8 | |||
9 | internal class InscribeBundleCommand | ||
10 | { | ||
11 | public InscribeBundleCommand(IInscribeContext context) | ||
12 | { | ||
13 | this.Context = context; | ||
14 | } | ||
15 | |||
16 | private IInscribeContext Context { get; } | ||
17 | |||
18 | public bool Execute() | ||
19 | { | ||
20 | bool inscribed = false; | ||
21 | string tempFile = Path.Combine(this.Context.IntermediateFolder, "bundle_engine_signed.exe"); | ||
22 | |||
23 | using (BurnReader reader = BurnReader.Open(this.Context.InputFilePath)) | ||
24 | { | ||
25 | File.Copy(this.Context.SignedEngineFile, tempFile, true); | ||
26 | |||
27 | // If there was an attached container on the original (unsigned) bundle, put it back. | ||
28 | if (reader.AttachedContainerSize > 0) | ||
29 | { | ||
30 | reader.Stream.Seek(reader.AttachedContainerAddress, SeekOrigin.Begin); | ||
31 | |||
32 | using (BurnWriter writer = BurnWriter.Open(tempFile)) | ||
33 | { | ||
34 | writer.RememberThenResetSignature(); | ||
35 | writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached); | ||
36 | inscribed = true; | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | Directory.CreateDirectory(Path.GetDirectoryName(this.Context.OutputFile)); | ||
42 | if (File.Exists(this.Context.OutputFile)) | ||
43 | { | ||
44 | File.Delete(this.Context.OutputFile); | ||
45 | } | ||
46 | |||
47 | File.Move(tempFile, this.Context.OutputFile); | ||
48 | WixToolset.Core.Native.NativeMethods.ResetAcls(new string[] { this.Context.OutputFile }, 1); | ||
49 | |||
50 | return inscribed; | ||
51 | } | ||
52 | } | ||
53 | } | ||