コード例 #1
0
        private static void PreparePatches()
        {
            ColoredOutput.WriteInformation("Preparing patches...");

            _distanceAssemblyDefinition = ModuleLoader.LoadDistanceModule(_distanceAssemblyFilename);

            if (!string.IsNullOrEmpty(_bootstrapAssemblyFilename))
            {
                _bootstrapAssemblyDefinition = ModuleLoader.LoadBootstrapModule(_bootstrapAssemblyFilename);
            }
            _patcher = new Patcher(_bootstrapAssemblyDefinition, _distanceAssemblyDefinition);

            _patcher.AddPatch(new SpectrumInitCodePatch());
            _patcher.AddPatch(new SpectrumUpdateCodePatch());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: REHERC/Spectrum
        internal static void Main(string[] args)
        {
            WriteStartupHeader();

            if (!IsValidSyntax(args))
            {
                ColoredOutput.WriteInformation($"Usage: {GetExecutingFileName()} <-t (--target) Assembly-CSharp.dll> [options]");
                ColoredOutput.WriteInformation("  Options:");
                ColoredOutput.WriteInformation("    -t [--target]+: Specify the target Distance DLL you want to patch.");
                ColoredOutput.WriteInformation("    -s [--source]+: Specify the source DLL you want to cross-reference.");
                ColoredOutput.WriteInformation("    -p [--patch]+:  Run only patch with the specified name.");
                ErrorHandler.TerminateWithError("Invalid syntax provided.");
            }

            ParseArguments(args);

            if (string.IsNullOrEmpty(_distanceAssemblyFilename))
            {
                ErrorHandler.TerminateWithError("Target DLL name not specified.");
            }
            if ((args.Contains("-p") || args.Contains("--patch")) && string.IsNullOrEmpty(_requestedPatchName))
            {
                ErrorHandler.TerminateWithError("Patch name not specified.");
            }
            if ((args.Contains("-s") || args.Contains("--source")) && string.IsNullOrEmpty(_bootstrapAssemblyFilename))
            {
                ErrorHandler.TerminateWithError("Source DLL name not specified.");
            }

            if (!DistanceFileExists())
            {
                ErrorHandler.TerminateWithError("Specified TARGET DLL not found.");
            }

            if (!BootstrapFileExists() && (args.Contains("-s") || args.Contains("--source")))
            {
                ErrorHandler.TerminateWithError("Specified SOURCE DLL not found.");
            }

            CreateBackup();
            PreparePatches();
            RunPatches();
            ModuleWriter.SavePatchedFile(_distanceAssemblyDefinition, _distanceAssemblyFilename);

            // Run decapsulation after all other configured patches.
            _patcher.AddPatch(new DecapsulationPatch());
            _patcher.RunSpecific("Decapsulation");

            var devDllFileName = $"{Path.GetFileNameWithoutExtension(_distanceAssemblyFilename)}.dev.dll";

            ModuleWriter.SavePatchedFile(_distanceAssemblyDefinition, devDllFileName);
            ColoredOutput.WriteSuccess($"Saved decapsulated development DLL to {devDllFileName}");

            ColoredOutput.WriteSuccess("Patch process completed.");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Ciastex/Centrifuge
        private static void PreparePatches()
        {
            ColoredOutput.WriteInformation("Preparing patches...");
            _gameAssemblyDefinition = ModuleLoader.LoadGameModule(_gameAssemblyFilename);

            if (!string.IsNullOrEmpty(_bootstrapAssemblyFilename))
            {
                _bootstrapAssemblyDefinition = ModuleLoader.LoadBootstrapModule(_bootstrapAssemblyFilename);
            }
            _patcher = new Patcher(_bootstrapAssemblyDefinition, _gameAssemblyDefinition);
            _patcher.AddPatch(new CentrifugeInitPatch());
        }
コード例 #4
0
ファイル: frmPatcher.cs プロジェクト: Gpower2/AcTools
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtOldFile.Text))
                {
                    throw new Exception("Please provide with an old file first!");
                }
                if (!File.Exists(txtOldFile.Text))
                {
                    throw new Exception("Please provide with an existing old file first!");
                }
                if (String.IsNullOrWhiteSpace(txtNewFile.Text))
                {
                    throw new Exception("Please provide with a new file first!");
                }
                if (!File.Exists(txtNewFile.Text))
                {
                    throw new Exception("Please provide with an existing new file first!");
                }
                if (String.IsNullOrWhiteSpace(txtDiffFile.Text))
                {
                    throw new Exception("Please provide with a diff filename first!");
                }
                _Per.AddPatch(new Patch(txtOldFile.Text, txtNewFile.Text, txtDiffFile.Text));

                refreshPatchList();

                txtDiffFile.Text = "";
                txtNewFile.Text  = "";
                txtOldFile.Text  = "";
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex);
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Ciastex/Centrifuge
        internal static void Main(string[] args)
        {
            WriteStartupHeader();

            if (!IsValidSyntax(args))
            {
                ColoredOutput.WriteInformation($"Usage: {GetExecutingFileName()} <(-t | --target) target_assembly.dll> [options]");
                ColoredOutput.WriteInformation("  Options:");
                ColoredOutput.WriteInformation("    -t [--target]+: Specify the target assembly you want to patch.");
                ColoredOutput.WriteInformation("    -s [--source]+: Specify the source DLL you want to source the init code from.");
                ColoredOutput.WriteInformation("    -p [--patch]+:  Run only the patch with the specified name.");
                ColoredOutput.WriteInformation("    -h [--hash]: Generate a .md5 file of the patched assembly.");
                ColoredOutput.WriteInformation("    -d [--decap-only]: Only decapsulate the target DLL. Invalidates -s -p and -h.");

                ErrorHandler.TerminateWithError("Invalid syntax provided.", TerminationReason.InvalidSyntax);
            }

            ParseArguments(args);

            if (string.IsNullOrEmpty(_gameAssemblyFilename))
            {
                ErrorHandler.TerminateWithError("Target DLL name not specified.", TerminationReason.TargetDllNotProvided);
            }
            if ((args.Contains("-p") || args.Contains("--patch")) && string.IsNullOrEmpty(_requestedPatchName))
            {
                ErrorHandler.TerminateWithError("Patch name not specified.", TerminationReason.PatchNameNotProvided);
            }
            if ((args.Contains("-s") || args.Contains("--source")) && string.IsNullOrEmpty(_bootstrapAssemblyFilename))
            {
                ErrorHandler.TerminateWithError("Source DLL name not specified.", TerminationReason.SourceDllNotProvided);
            }

            if (!BootstrapFileExists() && (args.Contains("-s") || args.Contains("--source")))
            {
                ErrorHandler.TerminateWithError("Specified SOURCE DLL not found.", TerminationReason.SourceDllNonexistant);
            }

            if (!GameFileExists())
            {
                ErrorHandler.TerminateWithError("Specified TARGET DLL not found.", TerminationReason.TargetDllNonexistant);
            }

            PreparePatches();

            if (!_decapOnly)
            {
                CreateBackup();
                RunPatches();

                ModuleWriter.SavePatchedFile(_gameAssemblyDefinition, _gameAssemblyFilename, false);

                if (_generateHashFile)
                {
                    GenerateHashFile();
                }
            }
            else
            {
                ColoredOutput.WriteInformation("Attention! Decap-only run requested.");
            }

            _patcher.AddPatch(new DecapsulationPatch());
            _patcher.RunSpecific("Decapsulation");

            var devDllFileName = $"{Path.GetFileNameWithoutExtension(_gameAssemblyFilename)}.dev.dll";

            ModuleWriter.SavePatchedFile(_gameAssemblyDefinition, devDllFileName, true);
            ColoredOutput.WriteSuccess($"Saved decapsulated development DLL to {devDllFileName}");

            ColoredOutput.WriteSuccess("Patch process completed.");
        }