blob: 0dea8b1d9cb08c83fedc6feb7d622c68737e161c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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(this.Context.Messaging, 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;
}
}
}
|