diff --git a/apps/hdt-wine-overlay/WineOverlayPlugin.cs b/apps/hdt-wine-overlay/WineOverlayPlugin.cs index f7b3cb9..f3009e1 100644 --- a/apps/hdt-wine-overlay/WineOverlayPlugin.cs +++ b/apps/hdt-wine-overlay/WineOverlayPlugin.cs @@ -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)