From 8cc34ea1b6b9fec24a0e189646561fcb38c04ca7 Mon Sep 17 00:00:00 2001 From: goaaats Date: Sun, 19 Jun 2022 23:06:13 +0200 Subject: [PATCH] fix: adjust for base address when saving .text offsets --- Dalamud/Game/SigScanner.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index 3fea68536..700831d51 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -25,7 +25,7 @@ namespace Dalamud.Game private IntPtr moduleCopyPtr; private long moduleCopyOffset; - private Dictionary? textCache; + private Dictionary? textCache; /// /// Initializes a new instance of the class using the main module of the current process. @@ -308,11 +308,10 @@ namespace Dalamud.Game { if (this.textCache != null && this.textCache.TryGetValue(signature, out var address)) { - return address; + return new IntPtr(address + this.Module.BaseAddress.ToInt64()); } var mBase = this.IsCopy ? this.moduleCopyPtr : this.TextSectionBase; - var scanRet = Scan(mBase, this.TextSectionSize, signature); if (this.IsCopy) @@ -323,7 +322,7 @@ namespace Dalamud.Game if (insnByte == 0xE8 || insnByte == 0xE9) return ReadJmpCallSig(scanRet); - this.textCache?.Add(signature, scanRet); + this.textCache?.Add(signature, scanRet.ToInt64() - this.Module.BaseAddress.ToInt64()); return scanRet; } @@ -518,7 +517,7 @@ namespace Dalamud.Game return; } - this.textCache = JsonConvert.DeserializeObject>(File.ReadAllText(this.cacheFile.FullName)) ?? new Dictionary(); + this.textCache = JsonConvert.DeserializeObject>(File.ReadAllText(this.cacheFile.FullName)) ?? new Dictionary(); } } }