Ejemplo n.º 1
0
        public void StartPatching()
        {
            Log.Write("Start patching game files!", true, true);

            try
            {
                Patcher.CopyReferences(mscPath);
                File.Copy(AssemblyFullPath, string.Format("{0}.backup", AssemblyFullPath));
                Log.Write("Creating.....Assembly-CSharp.dll.backup");
                Log.Write(string.Format("Patching.....{0}", Path.GetFileName(AssemblyFullPath)));
                PatchThis(Path.Combine(mscPath, @"mysummercar_Data\Managed\"), "Assembly-CSharp.dll", "PlayMakerArrayListProxy", "Awake", "MSCLoader.dll", "MSCLoader.ModLoader", InitMethod);
                Log.Write("Finished patching!");

                Patcher.CopyCoreAssets(modPath);

                Log.Write("Patching successfull!");
                Log.Write("");
                MessageBox.Show("Patching successfull!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                statusBarLabel.Text = "Patching successfull!";
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error while patching: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Write(string.Format("Error while patching: {0}", ex.Message));
            }
            CheckPatchStatus();
        }
Ejemplo n.º 2
0
        public void PatchThis()
        {
            Log.Write("Start patching files!", true, true);

            Patcher.CopyReferences(mscPath);

            var cSharpAssembly = LoadAssembly(AssemblyFullPath);
            var mscLoader      = LoadAssembly("MSCLoader.dll");
            var coreLibrary    =
                cSharpAssembly.MainModule.AssemblyResolver.Resolve(
                    (AssemblyNameReference)cSharpAssembly.MainModule.TypeSystem.Corlib);

            mLoadedAssemblies.Add("Assembly-CSharp", cSharpAssembly);
            mLoadedAssemblies.Add("MSCPatcher", mscLoader);
            mLoadedAssemblies.Add("CoreLibrary", coreLibrary);

            //Launch the patching

            mModifications = LoadModifications(ModificationsXmlPath);

            PatchModifications();

            // We backup the original dll
            File.Move(AssemblyFullPath, String.Format("{0}.backup", AssemblyFullPath));
            Log.Write("Creating.....Assembly-CSharp.dll.backup");

            Log.Write(string.Format("Patching.....{0}", Path.GetFileName(AssemblyFullPath)));

            GetAssembly("Assembly-CSharp").Write(AssemblyFullPath);

            Log.Write("Finished Patching");

            Patcher.CopyCoreAssets(modPath);

            Log.Write("Patching successfull!");
            Log.Write("");
            MessageBox.Show("Patching successfull!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            statusBarLabel.Text = "Patching successfull!";
            checkPatchStatus();
        }
Ejemplo n.º 3
0
        public void PatchStarter()
        {
            if (oldFilesFound)
            {
                Log.Write("Cleaning old files!", true, true);
                //Remove old 0.1 unused files and patch game
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Assembly-CSharp.original.dll"));
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Mono.Cecil.dll"));
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Mono.Cecil.Rocks.dll"));
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCLoader.dll"));
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCPatcher.exe"));
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Xml.dll"));

                StartPatching();
            }
            else if (isgameUpdated)
            {
                //Remove old backup and patch new game file.
                Log.Write("Removing old backup!", true, true);
                Patcher.DeleteIfExists(string.Format("{0}.backup", AssemblyFullPath));

                StartPatching();
            }
            else if (oldPatchFound)
            {
                if (File.Exists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Assembly-CSharp.original.dll")))
                {
                    if (File.Exists(AssemblyFullPath))
                    {
                        Log.Write("Recovering backup file!", true, true);

                        Patcher.DeleteIfExists(AssemblyFullPath);

                        File.Move(Path.Combine(mscPath, @"mysummercar_Data\Managed\Assembly-CSharp.original.dll"), AssemblyFullPath);
                        Log.Write("Recovering.....Assembly-CSharp.original.dll");
                    }
                    else
                    {
                        Log.Write("Recovering backup file!", true, true);

                        File.Move(Path.Combine(mscPath, @"mysummercar_Data\Managed\Assembly-CSharp.original.dll"), AssemblyFullPath);
                        Log.Write("Recovering.....Assembly-CSharp.original.dll");
                    }
                    //Removing old files
                    Log.Write("Cleaning old files!", true, true);
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Mono.Cecil.dll"));
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Mono.Cecil.Rocks.dll"));
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCLoader.dll"));
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCPatcher.exe"));
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Xml.dll"));

                    StartPatching();
                }
                else
                {
                    MessageBox.Show(string.Format("0.1 backup file not found in:{1}{0}{1}Can't continue with upgrade{1}{1}Please check integrity files in steam, to recover original file.", Path.Combine(mscPath, @"mysummercar_Data\Managed\Assembly-CSharp.original.dll"), Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    statusBarLabel.Text = "Error!";
                }
            }
            else if (mscloaderUpdate)
            {
                Log.Write("MSCLoader.dll update!", true, true);

                Patcher.CopyReferences(mscPath);
                Patcher.CopyCoreAssets(modPath);

                Log.Write("MSCLoader.dll update successful!");
                Log.Write("");
                MessageBox.Show("Update successfull!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                statusBarLabel.Text = "Update successfull!";
                CheckPatchStatus();
            }
            else
            {
                StartPatching();
            }
        }