Skip to content

Commit

Permalink
fix: Don't let a debugger crash Bink (#1892)
Browse files Browse the repository at this point in the history
Resolves a problem where attaching a debugger can cause Bink to throw an exception, crashing the game.
  • Loading branch information
KazWolfe authored Jul 4, 2024
1 parent 336d853 commit 4a3e6df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Dalamud.Boot/veh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ LONG WINAPI vectored_exception_handler(EXCEPTION_POINTERS* ex)
{
// pass
}
else if (ex->ExceptionRecord->ExceptionCode == 0x406D1388)
{
// VS thread namer - just let these run; they aren't a problem.
// https://learn.microsoft.com/en-us/visualstudio/debugger/tips-for-debugging-threads
return EXCEPTION_CONTINUE_EXECUTION;
}
else
{
if (!is_whitelist_exception(ex->ExceptionRecord->ExceptionCode))
Expand Down
8 changes: 4 additions & 4 deletions Dalamud/Game/Internal/AntiDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Dalamud.Game.Internal;
[ServiceManager.EarlyLoadedService]
internal sealed class AntiDebug : IInternalDisposableService
{
private readonly byte[] nop = new byte[] { 0x31, 0xC0, 0x90, 0x90, 0x90, 0x90 };
private byte[] original;
private readonly byte[] nop = [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90];
private byte[]? original;
private IntPtr debugCheckAddress;

[ServiceManager.ServiceConstructor]
Expand Down Expand Up @@ -44,8 +44,8 @@ private AntiDebug(TargetSigScanner sigScanner)
}

/// <summary>Finalizes an instance of the <see cref="AntiDebug"/> class.</summary>
~AntiDebug() => this.Disable();

~AntiDebug() => ((IInternalDisposableService)this).DisposeService();
/// <summary>
/// Gets a value indicating whether the anti-debugging is enabled.
/// </summary>
Expand Down

0 comments on commit 4a3e6df

Please sign in to comment.