private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { // Do start conquer and inject Core.LogWritter.Write("Launching " + SelectedServer.ExecutableName + "..."); string PathToConquerExe = Path.Combine(Application.StartupPath, SelectedServer.ExecutableName); string WorkingDir = Path.GetDirectoryName(PathToConquerExe); bool NoUseDX8_DX9 = true; bool UseDecryptedServerDat = false; bool AlreadyUsingLoader = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length >= 2; if (AlreadyUsingLoader) { Core.LogWritter.Write("Detected already using ConnquerLoader."); } // If using 6000 Version or more the HookDLL Used is COHook.dll if (SelectedServer.ServerVersion >= Constants.MinVersionUseServerDat && SelectedServer.ServerVersion <= Constants.MaxVersionUseServerDat) { HookDLL = "COHook.dll"; Core.LogWritter.Write("Using Custom Server.dat..."); UseDecryptedServerDat = true; } if (File.Exists(PathToConquerExe)) { string CheckPathEnvDX8 = Path.Combine(Application.StartupPath, "Env_DX8", SelectedServer.ExecutableName); string CheckPathEnvDX9 = Path.Combine(Application.StartupPath, "Env_DX9", SelectedServer.ExecutableName); Core.LogWritter.Write("Checking if existing path: " + CheckPathEnvDX8 + "..."); if (File.Exists(CheckPathEnvDX8)) { Core.LogWritter.Write("Found Env_DX8 Folder. Setting the folder for run executable..."); PathToConquerExe = CheckPathEnvDX8; WorkingDir = Path.GetDirectoryName(PathToConquerExe); if (CurrentConquerProcess == null) { string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX8", HookINI); if (File.Exists(OutputCopyDll)) { File.Delete(OutputCopyDll); } if (!AlreadyUsingLoader) { File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll); } if (SelectedServer.ServerVersion >= 6371 && SelectedServer.ServerVersion <= Constants.MaxVersionUseServerDat) { RebuildServerDat(); if (!AlreadyUsingLoader) { File.WriteAllBytes(Path.Combine(WorkingDir, "TQAnp.dll"), Properties.Resources.TQAnp); File.WriteAllBytes(Path.Combine(Application.StartupPath, HookDLL), Properties.Resources.COHook6371); } Core.LogWritter.Write("Generating required files for use Custom Server.dat... (Using DX8)"); } } NoUseDX8_DX9 = false; } if (SelectedServer.UseDirectX9 && DX9Allowed) { if (File.Exists(CheckPathEnvDX9)) { Core.LogWritter.Write("Found Env_DX9 Folder. Setting the folder for run executable..."); PathToConquerExe = CheckPathEnvDX9; WorkingDir = Path.GetDirectoryName(PathToConquerExe); if (CurrentConquerProcess == null) { string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX9", HookINI); if (File.Exists(OutputCopyDll)) { File.Delete(OutputCopyDll); } File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll); if (SelectedServer.ServerVersion >= 6600) { RebuildServerDat(); if (!AlreadyUsingLoader) { File.WriteAllBytes(Path.Combine(WorkingDir, "TQAnp.dll"), Properties.Resources.TQAnp); File.WriteAllBytes(Path.Combine(Application.StartupPath, HookDLL), Properties.Resources.COHook6371); } Core.LogWritter.Write("Generating required files for use Custom Server.dat... (Using DX9)"); } } NoUseDX8_DX9 = false; } } if (NoUseDX8_DX9 && UseDecryptedServerDat && SelectedServer.ServerVersion >= Constants.MinVersionUseServerDat) { if (!AlreadyUsingLoader) { File.WriteAllBytes(Path.Combine(WorkingDir, "COFlashFixer.dll"), Properties.Resources.COFlashFixer_DLL); // Fix for flash } if (SelectedServer.ServerVersion >= 6176 && SelectedServer.ServerVersion <= 6370) { if (!AlreadyUsingLoader) { File.WriteAllBytes(Path.Combine(WorkingDir, HookDLL), Properties.Resources.COHook6176); // 6176 TO 6370 Hook } } else { if (!AlreadyUsingLoader) { File.WriteAllBytes(Path.Combine(WorkingDir, HookDLL), Properties.Resources.COHook6022); // V5717 TO V6175 Hook } } Core.LogWritter.Write("Generating required files for use Custom Server.dat..."); RebuildServerDat(); } Process conquerProc = Process.Start(new ProcessStartInfo() { FileName = PathToConquerExe, WorkingDirectory = WorkingDir, Arguments = "blacknull" }); if (conquerProc != null) { Core.LogWritter.Write("Process launched!"); worker.ReportProgress(10); CurrentConquerProcess = conquerProc; CurrentConquerProcess.EnableRaisingEvents = true; CurrentConquerProcess.Exited += new EventHandler(ConquerProc_Exited); int ConquerOpened = Process.GetProcessesByName(CurrentConquerProcess.ProcessName).Count(); if (Constants.EnableCLServerConnections) { Core.LogWritter.Write($"CLServer Enabled. Processes of Conquer opened: {ConquerOpened} (Only connect if have less or equal to 1)"); } if (Constants.EnableCLServerConnections && ConquerOpened <= 1) // Only if not have other Conquer.exe opened { Core.LogWritter.Write("Connecting to CLServer"); // Try connect to CLServer try { SocketSystem.CurrentSocketClient = new CLClient(SelectedServer.LoginHost, 8000); Core.LogWritter.Write(string.Format("CLClient connected at CLServer with port {0}.", 8000)); } catch (Exception ex) // Prevent break process of loader { Console.WriteLine("Cannot connect to CLServer: {0}", ex); } } LoaderEvents.ConquerLaunchedStartEvent(new List <Parameter> { new Parameter() { Id = "ConquerProcessId", Value = CurrentConquerProcess.Id.ToString() }, new Parameter() { Id = "GameServerIP", Value = SelectedServer.GameHost } }); worker.ReportProgress(20); if (UseDecryptedServerDat) { if (SelectedServer.ServerVersion <= 6186) { if (!Injector.StartInjection(Application.StartupPath + @"\COFlashFixer.dll", (uint)conquerProc.Id, worker)) { Core.LogWritter.Write("Injection COFlashFixer failed!"); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject COFlashFixer.dll", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Core.LogWritter.Write("Injected COFlashFixer successfully!"); } } if (SelectedServer.ServerVersion >= Constants.MinVersionUseServerDat) { if (!Injector.StartInjection(Application.StartupPath + @"\" + "ConquerCipherHook.dll", (uint)conquerProc.Id, worker)) { Core.LogWritter.Write("Injection ConquerCipherHook failed!"); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject ConquerCipherHook.dll", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Core.LogWritter.Write("Injected ConquerCipherHook successfully!"); } } if (!Injector.StartInjection(Application.StartupPath + @"\" + HookDLL, (uint)conquerProc.Id, worker)) { Core.LogWritter.Write($"Injection {HookDLL} failed!"); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject {HookDLL}", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Core.LogWritter.Write($"Injected {HookDLL} successfully!"); } } else { if (!Injector.StartInjection(Application.StartupPath + @"\" + HookDLL, (uint)conquerProc.Id, worker)) { Core.LogWritter.Write("Injection Hook failed!"); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject " + HookDLL, this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Core.LogWritter.Write("Injected Hook successfully!"); } } worker.ReportProgress(100); } else { Core.LogWritter.Write("Cannot launch " + SelectedServer.ExecutableName + ""); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot start {SelectedServer.ExecutableName}", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { Core.LogWritter.Write("Path for Executable not found: " + PathToConquerExe); } }
private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { // Do start conquer and inject Core.LogWritter.Write("Launching " + SelectedServer.ExecutableName + "..."); string PathToConquerExe = Path.Combine(Application.StartupPath, SelectedServer.ExecutableName); string WorkingDir = Path.GetDirectoryName(PathToConquerExe); if (File.Exists(PathToConquerExe)) { string CheckPathEnvDX8 = Path.Combine(Application.StartupPath, "Env_DX8", SelectedServer.ExecutableName); string CheckPathEnvDX9 = Path.Combine(Application.StartupPath, "Env_DX9", SelectedServer.ExecutableName); Core.LogWritter.Write("Checking if existing path: " + CheckPathEnvDX8 + "..."); if (File.Exists(CheckPathEnvDX8)) { Core.LogWritter.Write("Found Env_DX8 Folder. Setting the folder for run executable..."); PathToConquerExe = CheckPathEnvDX8; WorkingDir = Path.GetDirectoryName(PathToConquerExe); string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX8", HookINI); if (File.Exists(OutputCopyDll)) { File.Delete(OutputCopyDll); } File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll); } if (SelectedServer.UseDirectX9) { if (File.Exists(CheckPathEnvDX9)) { Core.LogWritter.Write("Found Env_DX9 Folder. Setting the folder for run executable..."); PathToConquerExe = CheckPathEnvDX9; WorkingDir = Path.GetDirectoryName(PathToConquerExe); string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX9", HookINI); if (File.Exists(OutputCopyDll)) { File.Delete(OutputCopyDll); } File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll); } } Process conquerProc = Process.Start(new ProcessStartInfo() { FileName = PathToConquerExe, WorkingDirectory = WorkingDir, Arguments = "blacknull" }); if (conquerProc != null) { Core.LogWritter.Write("Process launched!"); worker.ReportProgress(10); CurrentConquerProcess = conquerProc; int ConquerOpened = Process.GetProcessesByName(CurrentConquerProcess.ProcessName).Count(); Core.LogWritter.Write($"CLServer Enabled: {LoaderConfig.CLServer} . Processes of Conquer opened: {ConquerOpened} (Only connect if have less or equal to 1)"); if (LoaderConfig.CLServer && ConquerOpened <= 1) // Only if not have other Conquer.exe opened { Core.LogWritter.Write("Connecting to CLServer"); // Try connect to CLServer try { SocketSystem.CurrentSocketClient = new CLClient(SelectedServer.LoginHost, 8000); Core.LogWritter.Write(string.Format("CLClient connected at CLServer with port {0}.", 8000)); } catch (Exception ex) // Prevent break process of loader { Console.WriteLine("Cannot connect to CLServer: {0}", ex); } } LoaderEvents.ConquerLaunchedStartEvent(new List <Parameter> { new Parameter() { Id = "ConquerProcessId", Value = CurrentConquerProcess.Id.ToString() }, new Parameter() { Id = "GameServerIP", Value = SelectedServer.GameHost } }); Core.LogWritter.Write("Injecting DLL..."); worker.ReportProgress(20); if (SelectedServer.ServerVersion >= 6187) { conquerProc.WaitForInputIdle(35000); } if (!Injector.StartInjection(Application.StartupPath + @"\" + HookDLL, (uint)conquerProc.Id, worker)) { Core.LogWritter.Write("Injection failed!"); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject " + HookDLL, this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Core.LogWritter.Write("Injected successfully!"); } } else { Core.LogWritter.Write("Cannot launch " + SelectedServer.ExecutableName + ""); MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot start {SelectedServer.ExecutableName}", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { Core.LogWritter.Write("Path for Executable not found: " + PathToConquerExe); } }