コード例 #1
0
ファイル: melt.cs プロジェクト: roni8686/wix3
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">Arguments to decompiler.</param>
        /// <returns>0 if sucessful, otherwise 1.</returns>
        public static int Main(string[] args)
        {
            AppCommon.PrepareConsoleForLocalization();
            Melt melt = new Melt();

            return(melt.Run(args));
        }
コード例 #2
0
        /// <summary>
        /// Extract binary data from tables with a Name and Data column in them.
        /// </summary>
        /// <param name="inputPdb">A reference to a <see cref="Pdb"/> as output.  Paths (Data properties) will be modified in this object.</param>
        /// <param name="package">The installer database to rip from.</param>
        /// <param name="exportPath">The full path where files will be exported to.</param>
        /// <param name="tableName">The name of the table to export.</param>
        private static void MeltBinaryTable(Pdb inputPdb, InstallPackage package, string exportPath, string tableName)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentNullException("tableName");
            }
            if (string.IsNullOrEmpty(exportPath))
            {
                throw new ArgumentNullException("exportPath");
            }
            if (null == package)
            {
                throw new ArgumentNullException("package");
            }
            if (null == inputPdb)
            {
                throw new ArgumentNullException("inputPdb");
            }

            Table pdbTable = inputPdb.Output.Tables[tableName];

            if (null == pdbTable)
            {
                Console.WriteLine("Table {0} does not exist.", tableName);
                return;
            }

            try
            {
                Directory.CreateDirectory(exportPath);
                Melt.ExtractFilesInBinaryTable(package, null, tableName, exportPath);
                IDictionary <string, string> paths = package.GetFilePaths(exportPath);

                if (null != paths)
                {
                    foreach (Row row in pdbTable.Rows)
                    {
                        string filename = (string)row.Fields[0].Data;
                        row.Fields[1].Data = paths[filename];
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occured extracting the {0} binary table from the install package.", tableName);
                Console.WriteLine(ex.Message);
            }
        }
コード例 #3
0
ファイル: melt.cs プロジェクト: DavidFlamme/wix3
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 /// <param name="args">Arguments to decompiler.</param>
 /// <returns>0 if sucessful, otherwise 1.</returns>
 public static int Main(string[] args)
 {
     AppCommon.PrepareConsoleForLocalization();
     Melt melt = new Melt();
     return melt.Run(args);
 }
コード例 #4
0
        /// <summary>
        /// Extracts files from an MSI database and rewrites the paths embedded in the source .wixpdb to the output .wixpdb.
        /// </summary>
        private void MeltProduct()
        {
            // print friendly message saying what file is being decompiled
            Console.WriteLine("{0} / {1}", Path.GetFileName(this.inputFile), Path.GetFileName(this.inputPdbFile));

            Pdb inputPdb = Pdb.Load(this.inputPdbFile, true, true);

            // extract files from the .msi (unless suppressed) and get the path map of File ids to target paths
            string outputDirectory  = this.exportBasePath ?? Environment.GetEnvironmentVariable("WIX_TEMP");
            string exportBinaryPath = null;
            string exportIconPath   = null;

            if (this.exportToSubDirectoriesFormat)
            {
                exportBinaryPath = Path.Combine(outputDirectory, "Binary");
                exportIconPath   = Path.Combine(outputDirectory, "Icon");
                outputDirectory  = Path.Combine(outputDirectory, "File");
            }

            Table wixFileTable = inputPdb.Output.Tables["WixFile"];

            IDictionary <string, string> paths = null;

            using (InstallPackage package = new InstallPackage(this.inputFile, DatabaseOpenMode.ReadOnly, null, outputDirectory))
            {
                // ignore failures as this is a new validation in v3.x
                ValidateMsiMatchesPdb(package, inputPdb);

                if (!this.suppressExtraction)
                {
                    package.ExtractFiles();

                    if (this.exportToSubDirectoriesFormat)
                    {
                        Melt.MeltBinaryTable(inputPdb, package, exportBinaryPath, "Binary");
                        Melt.MeltBinaryTable(inputPdb, package, exportIconPath, "Icon");
                    }
                }

                paths = package.Files.SourcePaths;
            }

            if (null != wixFileTable)
            {
                foreach (Row row in wixFileTable.Rows)
                {
                    WixFileRow fileRow = row as WixFileRow;
                    if (null != fileRow)
                    {
                        string newPath;
                        if (paths.TryGetValue(fileRow.File, out newPath))
                        {
                            fileRow.Source = Path.Combine(outputDirectory, newPath);
                        }
                    }
                }
            }

            string tempPath = Path.Combine(Environment.GetEnvironmentVariable("WIX_TEMP") ?? Path.GetTempPath(), Path.GetRandomFileName());

            try
            {
                inputPdb.Save(this.outputFile, null, null, tempPath);
            }
            finally
            {
                if (this.tidy)
                {
                    if (!AppCommon.DeleteDirectory(tempPath, this.messageHandler))
                    {
                        Console.WriteLine(MeltStrings.WAR_FailedToDeleteTempDir, tempPath);
                    }
                }
                else
                {
                    Console.WriteLine(MeltStrings.INF_TempDirLocatedAt, tempPath);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">Arguments to decompiler.</param>
        /// <returns>0 if sucessful, otherwise 1.</returns>
        public static int Main(string[] args)
        {
            Melt melt = new Melt();

            return(melt.Run(args));
        }