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(); }
public static void EnableDebugging(bool is64, string modpath) { Patcher.DeleteIfExists(string.Format("{0}.normal", monoPath)); File.Move(monoPath, string.Format("{0}.normal", monoPath)); if (is64) { File.Copy( Path.GetFullPath(Path.Combine(@"Debug\64", "mono.dll")), monoPath, true); } else { File.Copy( Path.GetFullPath(Path.Combine(@"Debug\32", "mono.dll")), monoPath, true); } Log.Write("Copying debug file.....mono.dll"); File.Copy(Path.GetFullPath(Path.Combine("Debug", "pdb2mdb.exe")), Path.Combine(modpath, "pdb2mdb.exe"), true); Log.Write("Copying debug file.....pdb2mdb.exe"); File.Copy(Path.GetFullPath(Path.Combine("Debug", "debug.bat")), Path.Combine(modpath, "debug.bat"), true); Log.Write("Copying debug file.....debug.bat"); try { ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine("Debug", "en_debugger.bat")); startInfo.Verb = "runas"; Process en_debug = Process.Start(startInfo); en_debug.WaitForExit(); } catch (Exception ex) { MessageBox.Show(string.Format("Error: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.Write("Error", true, true); Log.Write(ex.Message); Log.Write(ex.ToString()); } if (Environment.GetEnvironmentVariable( "DNSPY_UNITY_DBG", EnvironmentVariableTarget.Machine) != null) { MessageBox.Show("Debugging Enabled successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to set debug variable!", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); 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"); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\MSCLoader.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\uAudio.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Xml.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\Newtonsoft.Json.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Data.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\System.Runtime.Serialization.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\NAudio.dll")); Patcher.DeleteIfExists(Path.Combine(mscPath, @"mysummercar_Data\Managed\NVorbis.dll")); Log.Write("", false, true); Log.Write("MSCLoader removed successfully!"); Log.Write(""); MessageBox.Show("MSCLoader removed successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); statusBarLabel.Text = "MSCLoader removed successfully!"; } 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); } checkPatchStatus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); statusBarLabel.Text = "Error: " + ex.Message; } } }
public static void remove64() { if (Form1.mscPath != "(unknown)") { try { if (File.Exists(Path.Combine(Form1.mscPath, "mysummercar.exe.32"))) { Patcher.DeleteIfExists(Path.Combine(Form1.mscPath, "mysummercar.exe")); Patcher.DeleteIfExists(Path.Combine(Form1.mscPath, "steam_api64.dll")); File.Move(Path.Combine(Form1.mscPath, "mysummercar.exe.32"), Path.Combine(Form1.mscPath, "mysummercar.exe")); } else { throw new Exception("Backup file not found. Please verify file integrity on steam before continue!"); } if (File.Exists(Path.Combine(Form1.mscPath, @"mysummercar_Data\Mono\mono.dll.32"))) { Patcher.DeleteIfExists(Path.Combine(Form1.mscPath, @"mysummercar_Data\Mono\mono.dll")); Patcher.DeleteIfExists(Path.Combine(Form1.mscPath, @"mysummercar_Data\Mono\mono.dll.normal")); File.Move(Path.Combine(Form1.mscPath, @"mysummercar_Data\Mono\mono.dll.32"), Path.Combine(Form1.mscPath, @"mysummercar_Data\Mono\mono.dll")); } else { throw new Exception("Backup file not found. Please verify file integrity on steam before continue!"); } if (File.Exists(Path.Combine(Form1.mscPath, @"mysummercar_Data\Plugins\CSteamworks.dll.32"))) { Patcher.DeleteIfExists(Path.Combine(Form1.mscPath, @"mysummercar_Data\Plugins\CSteamworks.dll")); File.Move(Path.Combine(Form1.mscPath, @"mysummercar_Data\Plugins\CSteamworks.dll.32"), Path.Combine(Form1.mscPath, @"mysummercar_Data\Plugins\CSteamworks.dll")); } else { throw new Exception("Backup file not found. Please verify file integrity on steam before continue!"); } MessageBox.Show("32-bit version restored successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { MessageBox.Show(string.Format("Failed to restore 32-bit version.{1}{1}Error details:{1}{0}", e.Message, Environment.NewLine), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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(); } }
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(); }
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(); } }