mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
add more exception handler options to dev menu
This commit is contained in:
parent
be965f8dd1
commit
df65d59f8b
2 changed files with 54 additions and 12 deletions
|
|
@ -117,6 +117,14 @@ internal sealed class Dalamud : IServiceType
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.DefaultExceptionFilter = NativeFunctions.SetUnhandledExceptionFilter(nint.Zero);
|
||||||
|
NativeFunctions.SetUnhandledExceptionFilter(this.DefaultExceptionFilter);
|
||||||
|
Log.Debug($"SE default exception filter at {this.DefaultExceptionFilter.ToInt64():X}");
|
||||||
|
|
||||||
|
var debugSig = "40 55 53 56 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 48 83 3D ?? ?? ?? ?? ??";
|
||||||
|
this.DebugExceptionFilter = Service<TargetSigScanner>.Get().ScanText(debugSig);
|
||||||
|
Log.Debug($"SE debug exception filter at {this.DebugExceptionFilter.ToInt64():X}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -129,6 +137,16 @@ internal sealed class Dalamud : IServiceType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal DirectoryInfo AssetDirectory => new(this.StartInfo.AssetDirectory!);
|
internal DirectoryInfo AssetDirectory => new(this.StartInfo.AssetDirectory!);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the in-game default exception filter.
|
||||||
|
/// </summary>
|
||||||
|
private nint DefaultExceptionFilter { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the in-game debug exception filter.
|
||||||
|
/// </summary>
|
||||||
|
private nint DebugExceptionFilter { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signal to the crash handler process that we should restart the game.
|
/// Signal to the crash handler process that we should restart the game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -191,16 +209,30 @@ internal sealed class Dalamud : IServiceType
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replace the built-in exception handler with a debug one.
|
/// Replace the current exception handler with the default one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void ReplaceExceptionHandler()
|
internal void UseDefaultExceptionHandler() =>
|
||||||
{
|
this.SetExceptionHandler(this.DefaultExceptionFilter);
|
||||||
var releaseSig = "40 55 53 56 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 85 ?? ?? ?? ?? 48 83 3D ?? ?? ?? ?? ??";
|
|
||||||
var releaseFilter = Service<TargetSigScanner>.Get().ScanText(releaseSig);
|
|
||||||
Log.Debug($"SE debug filter at {releaseFilter.ToInt64():X}");
|
|
||||||
|
|
||||||
var oldFilter = NativeFunctions.SetUnhandledExceptionFilter(releaseFilter);
|
/// <summary>
|
||||||
Log.Debug("Reset ExceptionFilter, old: {0}", oldFilter);
|
/// Replace the current exception handler with a debug one.
|
||||||
|
/// </summary>
|
||||||
|
internal void UseDebugExceptionHandler() =>
|
||||||
|
this.SetExceptionHandler(this.DebugExceptionFilter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disable the current exception handler.
|
||||||
|
/// </summary>
|
||||||
|
internal void UseNoExceptionHandler() =>
|
||||||
|
this.SetExceptionHandler(nint.Zero);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper function to set the exception handler.
|
||||||
|
/// </summary>
|
||||||
|
private void SetExceptionHandler(nint newFilter)
|
||||||
|
{
|
||||||
|
var oldFilter = NativeFunctions.SetUnhandledExceptionFilter(newFilter);
|
||||||
|
Log.Debug("Set ExceptionFilter to {0}, old: {1}", newFilter, oldFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupClientStructsResolver(DirectoryInfo cacheDir)
|
private void SetupClientStructsResolver(DirectoryInfo cacheDir)
|
||||||
|
|
|
||||||
|
|
@ -863,9 +863,19 @@ internal class DalamudInterface : IDisposable, IServiceType
|
||||||
|
|
||||||
if (ImGui.BeginMenu("Game"))
|
if (ImGui.BeginMenu("Game"))
|
||||||
{
|
{
|
||||||
if (ImGui.MenuItem("Replace ExceptionHandler"))
|
if (ImGui.MenuItem("Use in-game default ExceptionHandler"))
|
||||||
{
|
{
|
||||||
this.dalamud.ReplaceExceptionHandler();
|
this.dalamud.UseDefaultExceptionHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.MenuItem("Use in-game debug ExceptionHandler"))
|
||||||
|
{
|
||||||
|
this.dalamud.UseDebugExceptionHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.MenuItem("Disable in-game ExceptionHandler"))
|
||||||
|
{
|
||||||
|
this.dalamud.UseNoExceptionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndMenu();
|
ImGui.EndMenu();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue