private void ToggleHacks() { if (pd == null) { return; } pd.RemoveBreakPoints(); timer.Stop(); timer.Start(); if (noTreesCheckBox.Checked) { pd.AddBreakPoint(new TreeRaidusBp()); } if (noTreesCheckBox.Checked && inBothModesCheckBox.Checked) { pd.AddBreakPoint(new AlwaysSniperBP()); } }
private void AddBreakPoint(D2BreakPoint bp) { if (pd.Breakpoints.Count >= Kernel32.MaxHardwareBreakpoints) { return; } try { pd.AddBreakPoint(bp, pd.GetModuleAddress(bp.ModuleName)); } catch { Logger.Generic.Log(this, LogType.Warning, "Failed to apply hacks. Try again"); } }
public void Start() { try { pd = new ProcessDebugger(process.Id); var breakpoints = new List <HardwareBreakPoint>(); var data = BuildDatas.ContainsKey(build) ? BuildDatas[build] : null; if (data != null) { breakpoints.Add(new CascBreakpoint1(data.CascOffs1)); breakpoints.Add(new CascBreakpoint2(data.CascOffs2)); } else { throw new Exception("No offset data for build " + build); } pd.Run(); var time = DateTime.Now; PrettyLogger.WriteLine(ConsoleColor.Yellow, "Attaching to {0}...", process.GetVersionInfo()); PrettyLogger.WriteLine(ConsoleColor.Yellow, "Waiting 5 sec to come up..."); while (!pd.WaitForComeUp(50) && time.MSecToNow() < 5000) { } if (!pd.IsDebugging) { throw new Exception("Failed to start logger"); } PrettyLogger.WriteLine(ConsoleColor.Yellow, "Installing breakpoints..."); foreach (var bp in breakpoints) { pd.AddBreakPoint(bp); } PrettyLogger.WriteLine(ConsoleColor.Magenta, "Successfully attached to {0} PID: {1}.", process.GetVersionInfo(), process.Id); } catch (Exception e) { throw e; } }