コード例 #1
0
        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.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);
        }
コード例 #2
0
        public bool Execute()
        {
            var inscribed = false;
            var tempFile  = Path.Combine(this.Context.IntermediateFolder, "bundle_engine_signed.exe");

            using (var reader = BurnReader.Open(this.Context.InputFilePath))
            {
                FileSystem.CopyFile(this.Context.SignedEngineFile, tempFile, allowHardlink: false);

                // 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 (var writer = BurnWriter.Open(this.Messaging, tempFile))
                    {
                        writer.RememberThenResetSignature();
                        writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached);
                        inscribed = true;
                    }
                }
            }

            Directory.CreateDirectory(Path.GetDirectoryName(this.Context.OutputFile));

            FileSystem.MoveFile(tempFile, this.Context.OutputFile);

            return(inscribed);
        }
コード例 #3
0
 /// <summary>
 /// Extracts the attached container.
 /// </summary>
 /// <param name="messaging"></param>
 /// <param name="bundleFilePath">Path to the bundle.</param>
 /// <param name="destinationFolderPath">Path to extract to.</param>
 /// <param name="tempFolderPath">Temp path for extraction.</param>
 /// <returns>True if there was an attached container.</returns>
 public static bool ExtractAttachedContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath)
 {
     Directory.CreateDirectory(tempFolderPath);
     using (var burnReader = BurnReader.Open(messaging, bundleFilePath))
     {
         return(burnReader.ExtractAttachedContainer(destinationFolderPath, tempFolderPath));
     }
 }
コード例 #4
0
        public Intermediate Unbind(IUnbindContext context)
        {
            string uxExtractPath = Path.Combine(context.ExportBasePath, "UX");
            string acExtractPath = Path.Combine(context.ExportBasePath, "AttachedContainer");

            using (BurnReader reader = BurnReader.Open(context.InputFilePath))
            {
                reader.ExtractUXContainer(uxExtractPath, context.IntermediateFolder);
                reader.ExtractAttachedContainer(acExtractPath, context.IntermediateFolder);
            }

            return(null);
        }
コード例 #5
0
        public Intermediate Unbind(IUnbindContext context)
        {
            var uxExtractPath = Path.Combine(context.ExportBasePath, "UX");
            var acExtractPath = Path.Combine(context.ExportBasePath, "AttachedContainer");
            var messaging     = context.ServiceProvider.GetService <IMessaging>();

            using (var reader = BurnReader.Open(messaging, context.InputFilePath))
            {
                reader.ExtractUXContainer(uxExtractPath, context.IntermediateFolder);
                reader.ExtractAttachedContainer(acExtractPath, context.IntermediateFolder);
            }

            return(null);
        }
コード例 #6
0
        public bool Execute()
        {
            string tempFile = Path.Combine(this.Context.IntermediateFolder, "bundle_engine_unsigned.exe");

            using (BurnReader reader = BurnReader.Open(this.Context.InputFilePath))
                using (FileStream writer = File.Open(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete))
                {
                    reader.Stream.Seek(0, SeekOrigin.Begin);

                    byte[] buffer = new byte[4 * 1024];
                    int    total  = 0;
                    int    read   = 0;
                    do
                    {
                        read = Math.Min(buffer.Length, (int)reader.EngineSize - total);

                        read = reader.Stream.Read(buffer, 0, read);
                        writer.Write(buffer, 0, read);

                        total += read;
                    } while (total < reader.EngineSize && 0 < read);

                    if (total != reader.EngineSize)
                    {
                        throw new InvalidOperationException("Failed to copy engine out of bundle.");
                    }

                    // TODO: update writer with detached container signatures.
                }

            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(true);
        }
コード例 #7
0
        public bool Execute()
        {
            var tempFile = Path.Combine(this.IntermediateFolder, "bundle_engine_unsigned.exe");

            using (var reader = BurnReader.Open(this.InputFilePath))
                using (var writer = File.Open(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete))
                {
                    reader.Stream.Seek(0, SeekOrigin.Begin);

                    var buffer = new byte[4 * 1024];
                    var total  = 0;
                    var read   = 0;
                    do
                    {
                        read = Math.Min(buffer.Length, (int)reader.EngineSize - total);

                        read = reader.Stream.Read(buffer, 0, read);
                        writer.Write(buffer, 0, read);

                        total += read;
                    } while (total < reader.EngineSize && 0 < read);

                    if (total != reader.EngineSize)
                    {
                        throw new InvalidOperationException("Failed to copy engine out of bundle.");
                    }

                    // TODO: update writer with detached container signatures.
                }

            Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile));

            FileSystem.MoveFile(tempFile, this.OutputFile);

            return(true);
        }
コード例 #8
0
ファイル: BundleExtractor.cs プロジェクト: sgtatham/Core
        public static ExtractBAContainerResult ExtractBAContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath)
        {
            var result = new ExtractBAContainerResult();

            Directory.CreateDirectory(tempFolderPath);
            using (var burnReader = BurnReader.Open(messaging, bundleFilePath))
            {
                result.Success = burnReader.ExtractUXContainer(destinationFolderPath, tempFolderPath);
            }

            if (result.Success)
            {
                result.ManifestDocument         = LoadBurnManifest(destinationFolderPath);
                result.ManifestNamespaceManager = GetBurnNamespaceManager(result.ManifestDocument, "burn");

                result.BADataDocument         = LoadBAData(destinationFolderPath);
                result.BADataNamespaceManager = GetBADataNamespaceManager(result.BADataDocument, "ba");

                result.BundleExtensionDataDocument         = LoadBundleExtensionData(destinationFolderPath);
                result.BundleExtensionDataNamespaceManager = GetBundleExtensionDataNamespaceManager(result.BundleExtensionDataDocument, "be");
            }

            return(result);
        }