From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- .../Inscribe/InscribeBundleCommand.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs (limited to 'src/WixToolset.Core.Burn/Inscribe/InscribeBundleCommand.cs') 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 @@ +// 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. + +namespace WixToolset.Core.Burn.Inscribe +{ + using System.IO; + using WixToolset.Core.Burn.Bundles; + using WixToolset.Extensibility; + + internal class InscribeBundleCommand + { + public InscribeBundleCommand(IInscribeContext context) + { + this.Context = context; + } + + private IInscribeContext Context { get; } + + public bool Execute() + { + bool inscribed = false; + string tempFile = Path.Combine(this.Context.IntermediateFolder, "bundle_engine_signed.exe"); + + using (BurnReader reader = BurnReader.Open(this.Context.InputFilePath)) + { + File.Copy(this.Context.SignedEngineFile, tempFile, true); + + // If there was an attached container on the original (unsigned) bundle, put it back. + if (reader.AttachedContainerSize > 0) + { + reader.Stream.Seek(reader.AttachedContainerAddress, SeekOrigin.Begin); + + using (BurnWriter writer = BurnWriter.Open(tempFile)) + { + writer.RememberThenResetSignature(); + writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached); + inscribed = true; + } + } + } + + Directory.CreateDirectory(Path.GetDirectoryName(this.Context.OutputFile)); + if (File.Exists(this.Context.OutputFile)) + { + File.Delete(this.Context.OutputFile); + } + + File.Move(tempFile, this.Context.OutputFile); + WixToolset.Core.Native.NativeMethods.ResetAcls(new string[] { this.Context.OutputFile }, 1); + + return inscribed; + } + } +} -- cgit v1.2.3-55-g6feb