HDT plugin: record starts, exits and unhandled exceptions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-08 15:54:33 +01:00
parent 4fb1467e70
commit 4239465263

View file

@ -100,6 +100,19 @@ namespace HdtWineOverlay
Log.Info("Applied Wine overlay workarounds");
// HDT has died mid-game with nothing in its log, and under Wine its
// stderr goes nowhere. Note starts, clean exits and unhandled .NET
// exceptions in a file written synchronously: a start without an
// exit line means the process was killed or crashed natively (see
// C:\users\steamuser\wine-crashes.txt for winedbg's side).
if(!_crashCaptureRegistered)
{
_crashCaptureRegistered = true;
AppDomain.CurrentDomain.UnhandledException += (s, e) => CrashCapture($"unhandled exception (terminating={e.IsTerminating}): {e.ExceptionObject}");
AppDomain.CurrentDomain.ProcessExit += (s, e) => CrashCapture("clean exit");
CrashCapture("started");
}
if(System.IO.File.Exists(System.IO.Path.Combine(Config.AppDataPath, "wine-overlay-test")))
ShowTestPopup();
}
@ -169,6 +182,21 @@ namespace HdtWineOverlay
}
}
private static bool _crashCaptureRegistered;
private static void CrashCapture(string what)
{
try
{
System.IO.File.AppendAllText(System.IO.Path.Combine(Config.AppDataPath, "crash-capture.txt"),
$"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} pid {System.Diagnostics.Process.GetCurrentProcess().Id}: {what}\r\n");
}
catch
{
// Nothing sensible to do while the process is going down.
}
}
private void OnToolTipOpened(object sender, RoutedEventArgs e)
{
if(_active && PresentationSource.FromVisual((Visual)sender) is HwndSource source)