示例#1
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Do you want to remove MSCLoader from game?", "Remove?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             button3.Enabled = false;
             Log.Write("Removing MSCLoader from game", true, true);
             Patcher.DeleteIfExists(string.Format("{0}.backup", AssemblyFullPath));
             Patcher.DeleteIfExists(Path.Combine(mscPath, "winhttp.dll"));
             Patcher.DeleteIfExists(Path.Combine(mscPath, "doorstop_config.ini"));
             Patcher.ProcessReferences(mscPath, true);
             Log.Write("");
             Log.Write("MSCLoader removed successfully!");
             Log.Write("");
             MessageBox.Show("MSCLoader removed successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             statusBarLabel.Text = "MSCLoader removed successfully!";
             CheckPatchStatus();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             statusBarLabel.Text = "Error: " + ex.Message;
             Log.Write("Error", true, true);
             Log.Write(ex.Message);
             Log.Write(ex.ToString());
         }
     }
 }
示例#2
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();
        }
示例#3
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();
            }
        }