/// <summary> /// Closes any open connection, searches for DoW2 and injects the ForwardOperationsBase. /// </summary> public static void StartDebugging() { LoggingManager.SendMessage("DebugManager - Advanced mode started"); if (s_client != null) { try { s_client.Close(); } catch (Exception) { } s_client = null; } ClearLog(); if (s_window == null || s_window.IsDisposed) { s_window = new DebugWindow(); } ThreadPool.QueueUserWorkItem(Inject); ShowDebugWindow(); }
/// <summary> /// Closes any open connection, searches for DoW2 and injects the ForwardOperationsBase. /// </summary> public static void StartDebugging() { LoggingManager.SendMessage("DebugManager - Advanced mode started"); if (s_client != null) { try { s_client.Close(); } catch (Exception) { } s_client = null; } ClearLog(); if (s_window == null || s_window.IsDisposed) s_window = new DebugWindow(); ThreadPool.QueueUserWorkItem(Inject); ShowDebugWindow(); }
/// <summary> /// Injects the FOB into DoW2. /// </summary> /// <param name="o"></param> private static void Inject(object o) { LogMessage("Searching for DoW2 process..."); Process[] ps = Process.GetProcessesByName("DoW2"); for (int i = 0; i < 10; i++) { Thread.Sleep(1000); ps = Process.GetProcessesByName("DoW2"); if (ps.Length > 0) break; } if (ps.Length <= 0) { LogMessage("TIME OUT! Could not find DoW2 process 10 seconds after launch. Please try again."); return; } LogMessage("Process found!"); Process dow2 = ps[0]; // Retribution does not use GFWL anymore, no need to patch the memory if (!ToolSettings.IsInRetributionMode) { LogMessage("Preparing process..."); try { dow2.ReplaceSequence(s_memoryCheckSignature, s_memoryCheckPatch, "xlive.dll", 1); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Patching failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Error launching DoW2, please try again."); return; } } LogMessage("Injecting Cope's Forward Operations Base"); try { s_callbackReceiver = new DummyReceiver(); s_client = dow2.InjectForwardOperationalBase(s_callbackReceiver); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Injecting FOB failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Failed to start debugging system, please try again"); return; } string currentDir = Directory.GetCurrentDirectory() + '\\'; LogMessage("Injecting ModDebug.dll and initializing DebugManager..."); try { //dow2.InjectDll("M:\\Steam\\steamapps\\common\\dawn of war 2\\CopeLua.dll"); //dow2.InjectDll(currentDir + "LuaLibLoad.dll"); s_client.LoadAssemblyAndStartMethod(currentDir + "ModDebug.dll", "ModDebug.DebugManager", "Init", true); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Initializtaion of remote DebugManager failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Initialization of the remote DebugManager failed!"); return; } LogMessage("Setup done!"); dow2.Exited += OnGameExited; }
/// <summary> /// Injects the FOB into DoW2. /// </summary> /// <param name="o"></param> private static void Inject(object o) { LogMessage("Searching for DoW2 process..."); Process[] ps = Process.GetProcessesByName("DoW2"); for (int i = 0; i < 10; i++) { Thread.Sleep(1000); ps = Process.GetProcessesByName("DoW2"); if (ps.Length > 0) { break; } } if (ps.Length <= 0) { LogMessage("TIME OUT! Could not find DoW2 process 10 seconds after launch. Please try again."); return; } LogMessage("Process found!"); Process dow2 = ps[0]; // Retribution does not use GFWL anymore, no need to patch the memory if (!ToolSettings.IsInRetributionMode) { LogMessage("Preparing process..."); try { dow2.ReplaceSequence(s_memoryCheckSignature, s_memoryCheckPatch, "xlive.dll", 1); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Patching failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Error launching DoW2, please try again."); return; } } LogMessage("Injecting Cope's Forward Operations Base"); try { s_callbackReceiver = new DummyReceiver(); s_client = dow2.InjectForwardOperationalBase(s_callbackReceiver); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Injecting FOB failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Failed to start debugging system, please try again"); return; } string currentDir = Directory.GetCurrentDirectory() + '\\'; LogMessage("Injecting ModDebug.dll and initializing DebugManager..."); try { //dow2.InjectDll("M:\\Steam\\steamapps\\common\\dawn of war 2\\CopeLua.dll"); //dow2.InjectDll(currentDir + "LuaLibLoad.dll"); s_client.LoadAssemblyAndStartMethod(currentDir + "ModDebug.dll", "ModDebug.DebugManager", "Init", true); } catch (Exception e) { LoggingManager.SendMessage("DebugManager - Initializtaion of remote DebugManager failed!"); LoggingManager.HandleException(e); UIHelper.ShowError("Initialization of the remote DebugManager failed!"); return; } LogMessage("Setup done!"); dow2.Exited += OnGameExited; }