예제 #1
0
        static void ExtractMessageScripts()
        {
            using (Writer = new IndentedTextWriter(FileUtils.CreateText($".\\MessageScriptDump.txt")))
            {
                if (UseDecompiler)
                {
                    Decompiler = new MessageScriptDecompiler(Writer);
                }

                foreach (var file in Directory.EnumerateFiles(DirectoryPath, "*.*", SearchOption.AllDirectories))
                {
#if !DEBUG
                    try
#endif
                    {
                        ExtractMessageScript(file, File.OpenRead(file), null);
                    }
#if !DEBUG
                    catch (Exception e)
                    {
                        Console.WriteLine($"File \"{file}\" threw exception: {e.Message}");
                    }
#endif
                }

                Writer.Flush();
            }

            Console.WriteLine("Done.");
            //Console.ReadKey();
        }
예제 #2
0
        private void WriteMessageScriptDisassembly()
        {
            mWriter.WriteLine(".msg");

            using (var messageScriptDecompiler = new MessageScriptDecompiler(mWriter))
            {
                messageScriptDecompiler.Decompile(MessageScript.FromBinary(mScript.MessageScriptSection));
            }
        }
        public bool TryDecompile(FlowScript flowScript, string filepath)
        {
            mFilePath = Path.GetFullPath(filepath);
            LogInfo($"FlowScript output path set to {mFilePath}");

            if (MessageScriptFilePath == null)
            {
                MessageScriptFilePath = Path.ChangeExtension(mFilePath, "msg");
            }

            LogInfo($"MessageScript output path set to {MessageScriptFilePath}");

            if (flowScript.MessageScript != null)
            {
                // Disambiguate message script dialog names so that the decompilation won't fail
                DisambiguateMessageScriptDialogNames(flowScript.MessageScript);

                if (DecompileMessageScript)
                {
                    // Decompile embedded message script
                    LogInfo("Writing decompiled MessageScript to file");
                    using (var messageScriptDecompiler = new MessageScriptDecompiler(new FileTextWriter(MessageScriptFilePath)))
                    {
                        messageScriptDecompiler.Library = Library;
                        messageScriptDecompiler.Decompile(flowScript.MessageScript);
                    }
                }
            }

            // Decompile to decompilation unit
            if (!TryDecompile(flowScript, out var compilationUnit))
            {
                return(false);
            }

            // Write out the decompilation unit
            LogInfo("Writing decompiled FlowScript to file");
            var writer = new CompilationUnitWriter();

            writer.Write(compilationUnit, filepath);

            return(true);
        }
예제 #4
0
        /// <summary>
        /// decompiles the messagescript returns true if it is successful
        /// </summary>
        private static bool TryDoMessageScriptDecompilation()
        {
            // load binary file
            Logger.ConsoleInfo("Loading binary MessageScript file...");
            MessageScript script   = null;
            var           encoding = MessageScriptEncoding;
            var           format   = GetMessageScriptFormatVersion();

            if (!TryPerformAction("Failed to load message script from file.", () => script = MessageScript.FromFile(InputFilePath, format, encoding)))
            {
                return(false);
            }

            Logger.ConsoleInfo("Decompiling MessageScript...");

            if (!TryPerformAction("Failed to decompile message script to file.", () =>
            {
                using (var decompiler = new MessageScriptDecompiler(new FileTextWriter(OutputFilePath)))
                {
                    if (LibraryName != null)
                    {
                        var library = LibraryLookup.GetLibrary(LibraryName);

                        if (library == null)
                        {
                            Logger.ConsoleError("Invalid library name specified");
                        }

                        decompiler.Library = library;
                    }

                    decompiler.Decompile(script);
                }
            }))
            {
                return(false);
            }

            //open msg file

            return(true);
        }