diff --git a/Daybreak.API/Interop/GWHook.cs b/Daybreak.API/Interop/GWHook.cs index 65c24e6a..23801cf6 100644 --- a/Daybreak.API/Interop/GWHook.cs +++ b/Daybreak.API/Interop/GWHook.cs @@ -1,5 +1,4 @@ using System.Runtime.InteropServices; -using System.Text; using MinHook; namespace Daybreak.API.Interop; @@ -27,7 +26,6 @@ public sealed class GWHook( private HookEngine? engine; private bool usedJmpPatch; // true if we patched an existing JMP instead of using MinHook private int originalRel32; // saved rel32 for restoration when usedJmpPatch - private byte[]? prologueBytes; // first N bytes of target for diagnostics /// Delegate that calls the next hook / real function. public T Continue => this.cont ?? @@ -37,23 +35,6 @@ public sealed class GWHook( public nuint TargetAddress { get; private set; } public nuint ContinueAddress { get; private set; } public nuint DetourAddress { get; private set; } - public bool UsedJmpPatch => this.usedJmpPatch; - - /// Returns diagnostic info about the hook for logging. - public string GetDiagnosticInfo() - { - var sb = new StringBuilder(); - sb.AppendLine($" Hooked: {this.Hooked}"); - sb.AppendLine($" Method: {(this.usedJmpPatch ? "JMP patch" : "MinHook")}"); - sb.AppendLine($" Target: 0x{this.TargetAddress:X8}"); - sb.AppendLine($" Continue: 0x{this.ContinueAddress:X8}"); - sb.AppendLine($" Detour: 0x{this.DetourAddress:X8}"); - if (this.prologueBytes is not null) - { - sb.AppendLine($" Prologue (before hook): {BitConverter.ToString(this.prologueBytes)}"); - } - return sb.ToString(); - } /// Installs the hook exactly once (thread-safe). public bool EnsureInitialized() @@ -86,9 +67,6 @@ public sealed class GWHook( return false; } - // Capture prologue bytes for diagnostics before any patching - this.prologueBytes = ReadBytes(target, 16); - // If not bypassing previous hooks and target starts with JMP, use our JMP patching // This handles the case where GWCA already hooked the function if (!this.bypassPreviousHooks && StartsWithJmp(target)) @@ -262,18 +240,4 @@ public sealed class GWHook( var rel = *(int*)(p + 1); return (nuint)(p + 5 + rel); } - - /// - /// Reads N bytes from the given address for diagnostic purposes. - /// - private static unsafe byte[] ReadBytes(nuint addr, int count) - { - var bytes = new byte[count]; - var p = (byte*)addr; - for (var i = 0; i < count; i++) - { - bytes[i] = p[i]; - } - return bytes; - } } \ No newline at end of file diff --git a/Daybreak.API/Services/Interop/SkillbarContextService.cs b/Daybreak.API/Services/Interop/SkillbarContextService.cs index 173cb619..dbbe932e 100644 --- a/Daybreak.API/Services/Interop/SkillbarContextService.cs +++ b/Daybreak.API/Services/Interop/SkillbarContextService.cs @@ -92,7 +92,6 @@ public sealed class SkillbarContextService : IHostedService, IInteropHealthServi this.logger.LogInformation( "DecodeTemplateHeader hook installed at 0x{target:X8}", this.decodeTemplateHeaderHook.TargetAddress); - this.logger.LogDebug("DecodeTemplateHeader hook diagnostics:\n{diagnostics}", this.decodeTemplateHeaderHook.GetDiagnosticInfo()); while (!this.loadSkillTemplateHook.EnsureInitialized()) { @@ -102,7 +101,6 @@ public sealed class SkillbarContextService : IHostedService, IInteropHealthServi this.logger.LogInformation( "LoadSkillTemplate hook installed at 0x{target:X8}", this.loadSkillTemplateHook.TargetAddress); - this.logger.LogDebug("LoadSkillTemplate hook diagnostics:\n{diagnostics}", this.loadSkillTemplateHook.GetDiagnosticInfo()); }, cancellationToken); return Task.CompletedTask; } @@ -164,38 +162,12 @@ public sealed class SkillbarContextService : IHostedService, IInteropHealthServi private unsafe void LoadSkillTemplateDetour(int targetAgentId, SkillTemplate* templateData) { - var scopedLogger = this.logger.CreateScopedLogger(); - scopedLogger.LogDebug( - "LoadSkillTemplateDetour called for agent {agentId}, templateData at 0x{addr:X8}", - targetAgentId, - (nuint)templateData); - - // Log template data for debugging - if (templateData != null) - { - scopedLogger.LogDebug( - "SkillTemplate: Primary={primary}, Secondary={secondary}", - templateData->Primary, - templateData->Secondary); - } - else - { - scopedLogger.LogWarning("templateData is null!"); - } - if (this.loadSkillTemplateCallbacks.Any(r => r.Callback(*templateData))) { - scopedLogger.LogDebug("LoadSkillTemplate callback handled loading for agent {agentId}", targetAgentId); return; } - scopedLogger.LogDebug( - "Calling Continue at 0x{continueAddr:X8}", - this.loadSkillTemplateHook.ContinueAddress); - this.loadSkillTemplateHook.Continue(targetAgentId, templateData); - - scopedLogger.LogDebug("Continue returned successfully"); } ///