コード例 #1
0
        /// <summary>
        /// Open, Decode, Save a script file.
        /// </summary>
        /// <param name="inputPath"></param>
        /// <param name="outputPath"></param>
        /// <returns></returns>
        private static ScriptFile ProcessScriptfile(string inputPath, string outputPath)
        {
            ScriptFile scriptFile = LoadScriptFile(inputPath).Predecode().BuildAggregation().Decode();

            return(SaveScriptFile(scriptFile, outputPath));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ThreadLock = new object();
            Config     = new Ini.IniFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini"));
            if (!File.Exists(Config.path))
            {
                Config.IniWriteValue("Base", "IntStyle", "int");
                Config.IniWriteBool("Base", "Show_Array_Size", true);
                Config.IniWriteBool("Base", "Reverse_Hashes", true);
                Config.IniWriteBool("Base", "Declare_Variables", true);
                Config.IniWriteBool("Base", "Shift_Variables", true);
                Config.IniWriteBool("View", "Show_Nat_Namespace", true);
                Config.IniWriteBool("Base", "Show_Func_Pointer", false);
                Config.IniWriteBool("Base", "Use_MultiThreading", false);
                Config.IniWriteBool("Base", "Include_Function_Position", false);
                Config.IniWriteBool("Base", "Uppercase_Natives", false);
                Config.IniWriteBool("Base", "Hex_Index", false);
                Config.IniWriteBool("View", "Line_Numbers", true);
            }
            Find_Show_Array_Size();
            Find_Reverse_Hashes();
            Find_Declare_Variables();
            Find_Shift_Variables();
            Find_Show_Func_Pointer();
            Find_Use_MultiThreading();
            Find_IncFuncPos();
            Find_Nat_Namespace();
            Find_Hex_Index();
            Find_Upper_Natives();
            //Build NativeFiles from Directory if file exists, if not use the files in the resources
            string path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                                       "natives.dat");

            if (File.Exists(path))
            {
                nativefile = new NativeFile(File.OpenRead(path));
            }
            else
            {
                nativefile = new NativeFile(new MemoryStream(Properties.Resources.natives));
            }


            path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                                "x64natives.dat");
            if (File.Exists(path))
            {
                x64nativefile = new x64NativeFile(File.OpenRead(path));
            }
            else
            {
                x64nativefile = new x64NativeFile(new MemoryStream(Properties.Resources.x64natives));
            }

            ScriptFile.npi      = new NativeParamInfo();
            ScriptFile.hashbank = new Hashes();

            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            else
            {
                DateTime Start = DateTime.Now;
                string   ext   = Path.GetExtension(args[0]);
                if (ext == ".full")                 //handle openIV exporting pc scripts as *.ysc.full
                {
                    ext = Path.GetExtension(Path.GetFileNameWithoutExtension(args[0]));
                }
                ScriptFile fileopen;
                Console.WriteLine("Decompiling " + args[0] + "...");
                try
                {
                    fileopen = new ScriptFile(File.OpenRead(args[0]), ext != ".ysc");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error decompiling script " + ex.Message);
                    return;
                }
                Console.WriteLine("Decompiled in " + (DateTime.Now - Start).ToString());
                fileopen.Save(File.OpenWrite(args[0] + ".c"), true);
                Console.WriteLine("Extracing native table...");
                StreamWriter fw = new StreamWriter(File.OpenWrite(args[0] + " native table.txt"));
                foreach (ulong nat in fileopen.X64NativeTable._nativehash)
                {
                    string temps = nat.ToString("X");
                    while (temps.Length < 16)
                    {
                        temps = "0" + temps;
                    }
                    fw.WriteLine(temps);
                }
                fw.Flush();
                fw.Close();
                Console.WriteLine("All done & saved!");
            }
        }