private void OnEndSession() { Dispatcher.UIThread.InvokeAsync(() => { DebugSessionEnded?.Invoke(this, new EventArgs()); _shell.CurrentPerspective = Perspective.Editor; _lastDocument?.ClearDebugHighlight(); _lastDocument = null; }); lock (_sessionLock) { if (_session != null) { _session.Exit(); _session.TargetStopped -= _session_TargetStopped; _session.TargetHitBreakpoint -= _session_TargetStopped; _session.TargetSignaled -= _session_TargetStopped; _session.TargetInterrupted -= _session_TargetStopped; _session.TargetExited -= _session_TargetExited; _session.TargetStarted -= _session_TargetStarted; _session.TargetReady -= _session_TargetReady; _session.Dispose(); _session = null; } } // This will save breakpoints that were moved to be closer to actual sequence points. Breakpoints.Save(); }
private void OnEndSession() { lock (_sessionLock) { if (_session != null) { _session.TargetUnhandledException -= _session_TargetStopped; _session.TargetStopped -= _session_TargetStopped; _session.TargetHitBreakpoint -= _session_TargetStopped; _session.TargetSignaled -= _session_TargetStopped; _session.TargetInterrupted -= _session_TargetStopped; _session.TargetExited -= _session_TargetExited; _session.TargetStarted -= _session_TargetStarted; _session.TargetReady -= _session_TargetReady; _session?.Dispose(); _session = null; } } Dispatcher.UIThread.InvokeAsync(() => { DebugSessionEnded?.Invoke(this, EventArgs.Empty); _studio.CurrentPerspective = Perspective.Normal; _lastDocument?.ClearDebugHighlight(); _lastDocument = null; // This will save breakpoints that were moved to be closer to actual sequence points. Breakpoints.Save(); }); }
public override void TearDown() { base.TearDown(); if (ds != null) { ds.Exit(); ds.Dispose(); } }
static void Cleanup() { currentBacktrace = null; if (!IsDebugging) { return; } if (busyStatusIcon != null) { busyStatusIcon.Dispose(); busyStatusIcon = null; } session.TargetEvent -= OnTargetEvent; session.TargetStarted -= OnStarted; session.OutputWriter = null; session.LogWriter = null; session.ExceptionHandler = null; session.BusyStateChanged -= OnBusyStateChanged; session.TypeResolverHandler = null; session.BreakpointTraceHandler = null; session.GetExpressionEvaluator = null; console.CancelRequested -= OnCancelRequested; // Dispose the session at the end, since it may take a while. DebuggerSession oldSession = session; session = null; if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } if (console != null) { console.Dispose(); console = null; } DispatchService.GuiDispatch(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); if (oldSession != null) { oldSession.BusyStateChanged -= OnBusyStateChanged; oldSession.Dispose(); } }
static void Cleanup() { if (oldLayout != null) { string layout = oldLayout; oldLayout = null; // Dispatch asynchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { if (IdeApp.Workbench.CurrentLayout == "Debug") { IdeApp.Workbench.CurrentLayout = layout; } }); } currentBacktrace = null; if (!IsDebugging) { return; } if (busyStatusIcon != null) { busyStatusIcon.Dispose(); busyStatusIcon = null; } session.TargetEvent -= OnTargetEvent; session.TargetStarted -= OnStarted; session.OutputWriter = null; session.LogWriter = null; session.BusyStateChanged -= OnBusyStateChanged; session.TypeResolverHandler = null; session.BreakpointTraceHandler = null; session.GetExpressionEvaluator = null; console.CancelRequested -= OnCancelRequested; // Dispose the session at the end, since it may take a while. DebuggerSession oldSession = session; session = null; DispatchService.GuiDispatch(delegate { if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } }); if (console != null) { console.Dispose(); console = null; } DispatchService.GuiDispatch(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); if (oldSession != null) { oldSession.BusyStateChanged -= OnBusyStateChanged; oldSession.Dispose(); } }
public void TearDown() { ds.Exit(); ds.Dispose(); }
public override void TearDown() { base.TearDown(); ds.Exit(); ds.Dispose(); }
static void Main(string[] args) { Console.Write("Enter full game path of game 'Geometry Dash': "); gdPath = Console.ReadLine(); if (!System.IO.File.Exists($"{gdPath}\\GeometryDash.exe")) { Utils.WriteLog("File 'GeometryDash.exe' does not exist!", ConsoleColor.DarkRed); Utils.PrintExit(-1); } if (System.IO.File.Exists($"{Environment.CurrentDirectory}\\GDLoader.dll")) { if (System.IO.File.Exists($"{gdPath}\\GDLoader.dll")) { System.IO.File.Delete($"{gdPath}\\GDLoader.dll"); } System.IO.File.Copy($"{Environment.CurrentDirectory}\\GDLoader.dll", $"{gdPath}\\GDLoader.dll"); } if (System.IO.Directory.Exists($"{Environment.CurrentDirectory}\\Mods")) { if (!System.IO.Directory.Exists($"{gdPath}\\Mods")) { System.IO.Directory.CreateDirectory($"{gdPath}\\Mods"); if (System.IO.File.Exists($"{Environment.CurrentDirectory}\\Mods\\ExampleAddon.dll")) { System.IO.File.Copy($"{Environment.CurrentDirectory}\\Mods\\ExampleAddon.dll", $"{gdPath}\\Mods\\ExampleAddon.dll"); } } } System.IO.File.Copy($"{gdPath}\\GeometryDash.exe", $"{gdPath}\\GeometryDash.bak", true); var peFile = new PeFile($"{gdPath}\\GeometryDash.exe"); var GDLoaderFile = new PeFile($"{gdPath}\\GDLoader.dll"); preInitOffset = GDLoaderFile.ExportedFunctions.ToList().Find(x => x.Name == "?pre_init@@YAXXZ").Address; Utils.WriteLog($"pre_init func Offset: 0x{preInitOffset:x}", ConsoleColor.Yellow); if (peFile.ImageNtHeaders != null) { peFile.ImageNtHeaders.OptionalHeader.DllCharacteristics = DllCharacteristicsType.NxCompat | DllCharacteristicsType.TerminalServerAware; } else { Utils.WriteLog("IMAGE_NT_HEADERS is null!", ConsoleColor.DarkRed); Utils.PrintExit(-1); } peFile.AddSection(".loader", 32, ScnCharacteristicsType.MemExecute | ScnCharacteristicsType.MemRead | ScnCharacteristicsType.MemWrite); loaderHdr = peFile.ImageSectionHeaders.ToList().Find(x => x.Name == ".loader"); textHdr = peFile.ImageSectionHeaders.ToList().Find(x => x.Name == ".text"); peFile.AddImport("GDLoader.dll", "?pre_init@@YAXXZ"); System.IO.File.WriteAllBytes($"{gdPath}\\GeometryDash_stage1patch.exe", peFile.RawFile.ToArray()); DebuggerSession debugSession = new DebuggerSession(); debugSession.ProcessStarted += DebugSessionOnProcessStarted; debugSession.LibraryLoaded += DebugSessionOnLibraryLoaded; debugSession.ExceptionOccurred += DebugSessionOnExceptionOccurred; debugSession.ProcessTerminated += DebugSessionOnProcessTerminated; Utils.WriteLog($"Starting debugger on file: '{gdPath}\\GeometryDash_stage1patch.exe'", ConsoleColor.DarkGray); var dbgSession = debugSession.StartProcess(new DebuggerProcessStartInfo { CommandLine = $"{gdPath}\\GeometryDash_stage1patch.exe" }); while (debugSession.IsActive) { if (foundLibrary) { dbgSession.Terminate(); dbgSession.Dispose(); break; } } debugSession.Dispose(); if (foundLibrary) { onPostDebugSuccess(); } else { Utils.WriteLog("Library not found. Exiting...", ConsoleColor.Red); Utils.PrintExit(-1); } }