コード例 #1
0
        /// <summary>
        /// Updates engine with attached container information and adds attached container again.
        /// </summary>
        /// <param name="bundleFile">Bundle with attached container.</param>
        /// <param name="signedEngineFile">Signed bundle engine.</param>
        /// <param name="outputFile">Signed engine with attached container.</param>
        /// <returns>True if bundle was updated.</returns>
        public bool InscribeBundle(string bundleFile, string signedEngineFile, string outputFile)
        {
            bool   inscribed = false;
            string tempFile  = Path.Combine(this.TempFilesLocation, "bundle_engine_signed.exe");

            using (BurnReader reader = BurnReader.Open(bundleFile, this))
            {
                File.Copy(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, this))
                    {
                        writer.RememberThenResetSignature();
                        writer.AppendContainer(reader.Stream, reader.AttachedContainerSize, BurnCommon.Container.Attached);
                        inscribed = true;
                    }
                }
            }

            Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
            if (File.Exists(outputFile))
            {
                File.Delete(outputFile);
            }
            File.Move(tempFile, outputFile);

            return(inscribed);
        }
コード例 #2
0
ファイル: BurnWriter.cs プロジェクト: Jeremiahf/wix3
        /// <summary>
        /// Opens a Burn writer.
        /// </summary>
        /// <param name="fileExe">Path to file.</param>
        /// <param name="messageHandler">Message handler.</param>
        /// <returns>Burn writer.</returns>
        public static BurnWriter Open(string fileExe, IMessageHandler messageHandler)
        {
            BurnWriter writer = new BurnWriter(fileExe, messageHandler);

            using (BinaryReader binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)))
            {
                if (!writer.Initialize(binaryReader))
                {
                    writer.invalidBundle = true;
                }
            }

            if (!writer.invalidBundle)
            {
                writer.binaryWriter = new BinaryWriter(File.Open(fileExe, FileMode.Open, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete));
            }

            return writer;
        }
コード例 #3
0
        /// <summary>
        /// Opens a Burn writer.
        /// </summary>
        /// <param name="fileExe">Path to file.</param>
        /// <param name="messageHandler">Message handler.</param>
        /// <returns>Burn writer.</returns>
        public static BurnWriter Open(string fileExe, IMessageHandler messageHandler)
        {
            BurnWriter writer = new BurnWriter(fileExe, messageHandler);

            using (BinaryReader binaryReader = new BinaryReader(File.Open(fileExe, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)))
            {
                if (!writer.Initialize(binaryReader))
                {
                    writer.invalidBundle = true;
                }
            }

            if (!writer.invalidBundle)
            {
                writer.binaryWriter = new BinaryWriter(File.Open(fileExe, FileMode.Open, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete));
            }

            return(writer);
        }