From 95e2bc14f29736fe4c7c18c165adac9293e4b1a2 Mon Sep 17 00:00:00 2001 From: attickdoor Date: Wed, 4 Mar 2020 21:29:02 -0500 Subject: [PATCH] Support IDA sigs that are based off of the first CALL instruction for a function. --- Dalamud/Game/SigScanner.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index 1d4fc7df8..f27222a35 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -155,10 +155,25 @@ namespace Dalamud.Game { if (IsCopy) scanRet = new IntPtr(scanRet.ToInt64() - this.moduleCopyOffset); + + if (Marshal.ReadByte(scanRet) == 0xE8) + return ReadCallSig(scanRet); return scanRet; } + /// + /// Helper for ScanText to get the correct address for + /// IDA sigs that mark the first CALL location. + /// + /// The address the CALL sig resolved to. + /// The real offset of the signature. + private IntPtr ReadCallSig(IntPtr SigLocation) + { + int jumpOffset = Marshal.ReadInt32(IntPtr.Add(SigLocation, 1)); + return IntPtr.Add(SigLocation, 5 + jumpOffset); + } + /// /// Scan for a byte signature in the .data section. ///