From 647e2b3c0f09b0add0a47faba30905fd54282a4e Mon Sep 17 00:00:00 2001 From: Loskh <1020612624@qq.com> Date: Sun, 11 Jan 2026 21:02:14 +0800 Subject: [PATCH] fix: prevent AsmHook from corrupting ReadJmpCallSig --- Dalamud/Game/SigScanner.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index 81fb8a3a3..5f75500b3 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -287,16 +287,15 @@ public class SigScanner : IDisposable, ISigScanner } var scanRet = Scan(this.TextSectionBase, this.TextSectionSize, signature); - - if (this.IsCopy) - scanRet = new IntPtr(scanRet.ToInt64() - this.moduleCopyOffset); - + var insnByte = Marshal.ReadByte(scanRet); + var baseAddress = this.IsCopy ? this.moduleCopyOffset + this.Module.BaseAddress : this.Module.BaseAddress; + if (insnByte == 0xE8 || insnByte == 0xE9) { scanRet = ReadJmpCallSig(scanRet); - var rel = scanRet - this.Module.BaseAddress; + var rel = scanRet - baseAddress; if (rel < 0 || rel >= this.TextSectionSize) { throw new KeyNotFoundException( @@ -304,6 +303,11 @@ public class SigScanner : IDisposable, ISigScanner } } + if (this.IsCopy) + { + scanRet = scanRet - this.moduleCopyOffset; + } + // If this is below the module, there's bound to be a problem with the sig/resolution... Let's not save it // TODO: THIS IS A HACK! FIX THE ROOT CAUSE! if (this.textCache != null && scanRet.ToInt64() >= this.Module.BaseAddress.ToInt64())