From 39e196ddbb7c2697760fab66bc2da877832bdf14 Mon Sep 17 00:00:00 2001 From: attickdoor Date: Fri, 13 Mar 2020 23:31:11 -0400 Subject: [PATCH 1/3] Add GetStaticAddressFromSig --- .../ClientState/ClientStateAddressResolver.cs | 4 ++-- Dalamud/Game/SigScanner.cs | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs index 07c554f38..357fa77a2 100644 --- a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs +++ b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs @@ -13,9 +13,9 @@ namespace Dalamud.Game.ClientState public IntPtr JobGaugeData { get; set; } protected override void Setup64Bit(SigScanner sig) { - ActorTable = sig.Module.BaseAddress + 0x1C62198; // updated 5.21 + ActorTable = sig.GetStaticAddressFromSig("F3 0F 11 05 ?? ?? ?? ?? EB 27", 0) + 0xC; LocalContentId = sig.Module.BaseAddress + 0x1C2E000; - JobGaugeData = sig.Module.BaseAddress + 0x1C5E420; + JobGaugeData = sig.GetStaticAddressFromSig("E8 ?? ?? ?? ?? 80 BB ?? ?? ?? ?? ?? 77 93", 0x220) + 0x10; } } } diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index f27222a35..d1b8f122c 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -166,7 +166,7 @@ namespace Dalamud.Game { /// 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 address the CALL sig resolved to. /// The real offset of the signature. private IntPtr ReadCallSig(IntPtr SigLocation) { @@ -174,6 +174,28 @@ namespace Dalamud.Game { return IntPtr.Add(SigLocation, 5 + jumpOffset); } + /// + /// Scan for a .data address using a .text function. + /// This is intended to be used with IDA sigs. + /// Place your cursor on the line calling a static address, and create and IDA sig. + /// + /// The signature of the function using the data. + /// The offset from function start of the instruction using the data. + /// An IntPtr to the static memory location. + public IntPtr GetStaticAddressFromSig(string signature, int offset) + { + IntPtr instrAddr = ScanText(signature); + instrAddr = IntPtr.Add(instrAddr, offset + 1); + long bAddr = (long)Module.BaseAddress; + var num = (long)Marshal.ReadInt32(instrAddr) + (long)instrAddr + 4 - bAddr; + while(! (num >= DataSectionOffset && num <= DataSectionOffset + DataSectionSize)) + { + instrAddr= IntPtr.Add(instrAddr, 1); + num = Marshal.ReadInt32(instrAddr) + (long)instrAddr + 4 - bAddr; + } + return IntPtr.Add(instrAddr, Marshal.ReadInt32(instrAddr) + 4); + } + /// /// Scan for a byte signature in the .data section. /// From 9186a1cf54a302c04d4fcad0b6aef060f6393d7a Mon Sep 17 00:00:00 2001 From: attickdoor Date: Fri, 13 Mar 2020 23:44:09 -0400 Subject: [PATCH 2/3] do-while is actually more elegant for once --- Dalamud/Game/SigScanner.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index d1b8f122c..a9508ad47 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -185,14 +185,15 @@ namespace Dalamud.Game { public IntPtr GetStaticAddressFromSig(string signature, int offset) { IntPtr instrAddr = ScanText(signature); - instrAddr = IntPtr.Add(instrAddr, offset + 1); + instrAddr = IntPtr.Add(instrAddr, offset); long bAddr = (long)Module.BaseAddress; - var num = (long)Marshal.ReadInt32(instrAddr) + (long)instrAddr + 4 - bAddr; - while(! (num >= DataSectionOffset && num <= DataSectionOffset + DataSectionSize)) + long num; + do { - instrAddr= IntPtr.Add(instrAddr, 1); + instrAddr = IntPtr.Add(instrAddr, 1); num = Marshal.ReadInt32(instrAddr) + (long)instrAddr + 4 - bAddr; } + while (!(num >= DataSectionOffset && num <= DataSectionOffset + DataSectionSize)); return IntPtr.Add(instrAddr, Marshal.ReadInt32(instrAddr) + 4); } From ae0690a3d0ac2586698f2983ad0376cdf77e35c0 Mon Sep 17 00:00:00 2001 From: attickdoor Date: Sun, 15 Mar 2020 03:55:42 -0400 Subject: [PATCH 3/3] use good sig and offset for ActorTable --- Dalamud/Game/ClientState/ClientStateAddressResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs index 357fa77a2..df547ff99 100644 --- a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs +++ b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs @@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState public IntPtr JobGaugeData { get; set; } protected override void Setup64Bit(SigScanner sig) { - ActorTable = sig.GetStaticAddressFromSig("F3 0F 11 05 ?? ?? ?? ?? EB 27", 0) + 0xC; + ActorTable = sig.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 85 ED", 0) + 0x148; LocalContentId = sig.Module.BaseAddress + 0x1C2E000; JobGaugeData = sig.GetStaticAddressFromSig("E8 ?? ?? ?? ?? 80 BB ?? ?? ?? ?? ?? 77 93", 0x220) + 0x10; }