Пример #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();
        }
Пример #2
0
        public void PatchThis()
        {
            Log.Write("Start patching files!", true, true);
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCLoader.dll"));
            if (!File.Exists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Xml.dll")))
            {
                File.Copy(Path.GetFullPath(Path.Combine("System.Xml.dll", "")), Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Xml.dll"));
                Log.Write("Copying new file.....System.Xml.dll");
            }
            if (!File.Exists(Path.Combine(mscPath, @"mysummercar_Data\Managed\uAudio.dll")))
            {
                File.Copy(Path.GetFullPath(Path.Combine("uAudio.dll", "")), Path.Combine(mscPath, @"mysummercar_Data\Managed\uAudio.dll"));
                Log.Write("Copying new file.....uAudio.dll");
            }
            if (File.Exists(Path.GetFullPath(Path.Combine("MSCLoader.dll", ""))))
            {
                File.Copy(Path.GetFullPath(Path.Combine("MSCLoader.dll", "")), Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCLoader.dll"));
                Log.Write("Copying new file.....MSCLoader.dll");
            }
            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();
        }
Пример #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();
            }
        }
Пример #4
0
        public void StartPatching()
        {
            Log.Write("Start installing MSCLoader!", true, true);

            try
            {
                Patcher.ProcessReferences(mscPath, false);
                if (is64bin)
                {
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"winhttp.dll"));
                    if (File.Exists(Path.GetFullPath(Path.Combine("w64.dll", ""))))
                    {
                        File.Copy(Path.GetFullPath(Path.Combine("w64.dll", "")), Path.Combine(mscPath, @"winhttp.dll"));
                        Log.Write("Copying new file.....winhttp.dll");
                    }
                    else
                    {
                        throw new FileNotFoundException("File \"w64.dll\" not found, please redownload modlaoder and/or unpack all files", "w64.dll");
                    }
                }
                else
                {
                    Patcher.DeleteIfExists(Path.Combine(mscPath, @"winhttp.dll"));
                    if (File.Exists(Path.GetFullPath(Path.Combine("w32.dll", ""))))
                    {
                        File.Copy(Path.GetFullPath(Path.Combine("w32.dll", "")), Path.Combine(mscPath, @"winhttp.dll"));
                        Log.Write("Copying new file.....winhttp.dll");
                    }
                    else
                    {
                        throw new FileNotFoundException("File \"w32.dll\" not found, please redownload modlaoder and/or unpack all files", "w32.dll");
                    }
                }
                Patcher.CopyCoreAssets(modPath);
                Log.Write("Creating Config file!", true, true);
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"doorstop_config.ini"));
                Log.Write("Generating config file.....doorstop_config.ini");
                using (TextWriter tw = File.CreateText(Path.Combine(mscPath, @"doorstop_config.ini")))
                {
                    tw.WriteLine(@"[UnityDoorstop]");
                    tw.WriteLine(@"enabled=true");
                    tw.WriteLine(@"targetAssembly=mysummercar_Data\Managed\MSCLoader.dll");
                    tw.WriteLine(@"redirectOutputLog=true");
                    tw.WriteLine(@"ignoreDisableSwitch=true");
                    tw.WriteLine(@"[MSCLoader]");
                    switch (InitMethod)
                    {
                    case "Init_MD":
                        tw.WriteLine(@"mods=MD");
                        break;

                    case "Init_GF":
                        tw.WriteLine(@"mods=GF");
                        break;

                    case "Init_AD":
                        tw.WriteLine(@"mods=AD");
                        break;

                    default:
                        tw.WriteLine(@"mods=GF");
                        break;
                    }
                    tw.WriteLine(@"skipIntro=false");
                    tw.Flush();
                }

                Log.Write("Install successfull!");
                Log.Write("");
                MessageBox.Show("Install successfull!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                statusBarLabel.Text = "Install successfull!";
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error while installing: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Write("Error", true, true);
                Log.Write(ex.Message);
                Log.Write(ex.ToString());
            }
            CheckPatchStatus();
        }
Пример #5
0
        public void PatchStarter()
        {
            if (modPath == Path.GetFullPath("."))
            {
                throw new Exception("Modloader Files unpacked into mod folder. Cannot install.");
            }
            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 (newPatchFound)
            {
                if (File.Exists(string.Format("{0}.backup", AssemblyFullPath)))
                {
                    Patcher.DeleteIfExists(AssemblyFullPath);
                    File.Move(string.Format("{0}.backup", AssemblyFullPath), AssemblyFullPath);
                    Log.Write("Recovering.....Assembly-CSharp.dll.backup");
                }
                else
                {
                    Log.Write("Error! Backup file not found");
                    MessageBox.Show(string.Format("Backup file not found in:{1}{0}{1}Can't continue{1}{1}Please check integrity files in steam, to recover original file.", String.Format("{0}.backup", AssemblyFullPath), Environment.NewLine), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                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.ProcessReferences(mscPath, false);
                Patcher.CopyCoreAssets(modPath);
                Patcher.DeleteIfExists(Path.Combine(mscPath, @"doorstop_config.ini"));
                Log.Write("Generating config file.....doorstop_config.ini");
                using (TextWriter tw = File.CreateText(Path.Combine(mscPath, @"doorstop_config.ini")))
                {
                    tw.WriteLine(@"[UnityDoorstop]");
                    tw.WriteLine(@"enabled=true");
                    tw.WriteLine(@"targetAssembly=mysummercar_Data\Managed\MSCLoader.dll");
                    tw.WriteLine(@"redirectOutputLog=true");
                    tw.WriteLine(@"ignoreDisableSwitch=true");
                    tw.WriteLine(@"[MSCLoader]");

                    switch (InitMethod)
                    {
                    case "Init_MD":
                        tw.WriteLine(@"mods=MD");
                        break;

                    case "Init_GF":
                        tw.WriteLine(@"mods=GF");
                        break;

                    case "Init_AD":
                        tw.WriteLine(@"mods=AD");
                        break;

                    default:
                        tw.WriteLine(@"mods=GF");
                        break;
                    }
                    tw.WriteLine(@"skipIntro=false");
                    tw.Flush();
                }
                Log.Write("MSCLoader update successful!");
                Log.Write("");
                MessageBox.Show("Update successfull!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                statusBarLabel.Text = "Update successfull!";
                CheckPatchStatus();
            }
            else
            {
                StartPatching();
            }
        }