mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-23 17:09:17 +01:00
Fix GameNetwork sig (#2031)
* Fix GameNetwork sig * Fix SigScanner and add safeguard to prevent bad jmp resolution
This commit is contained in:
parent
42a10a1215
commit
063f58a49a
2 changed files with 13 additions and 5 deletions
|
|
@ -21,6 +21,6 @@ internal sealed class GameNetworkAddressResolver : BaseAddressResolver
|
||||||
// ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 7A FF 0F B7 57 02 8D 42 89 3D 5F 02 00 00 0F 87 60 01 00 00 4C 8D 05");
|
// ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 7A FF 0F B7 57 02 8D 42 89 3D 5F 02 00 00 0F 87 60 01 00 00 4C 8D 05");
|
||||||
// ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 73 FF 0F B7 57 02 8D 42 ?? 3D ?? ?? 00 00 0F 87 60 01 00 00 4C 8D 05");
|
// ProcessZonePacket = sig.ScanText("48 89 74 24 18 57 48 83 EC 50 8B F2 49 8B F8 41 0F B7 50 02 8B CE E8 ?? ?? 73 FF 0F B7 57 02 8D 42 ?? 3D ?? ?? 00 00 0F 87 60 01 00 00 4C 8D 05");
|
||||||
this.ProcessZonePacketDown = sig.ScanText("40 53 56 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 44 24 ?? 8B F2");
|
this.ProcessZonePacketDown = sig.ScanText("40 53 56 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 44 24 ?? 8B F2");
|
||||||
this.ProcessZonePacketUp = sig.ScanText("E8 ?? ?? ?? ?? 48 83 C4 28 C3 32 C0 48 83 C4 28 C3 CC");
|
this.ProcessZonePacketUp = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 4C 89 64 24 ?? 55 41 56 41 57 48 8B EC 48 83 EC 70");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,8 +276,7 @@ public class SigScanner : IDisposable, ISigScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mBase = this.IsCopy ? this.moduleCopyPtr : this.TextSectionBase;
|
var scanRet = Scan(this.TextSectionBase, this.TextSectionSize, signature);
|
||||||
var scanRet = Scan(mBase, this.TextSectionSize, signature);
|
|
||||||
|
|
||||||
if (this.IsCopy)
|
if (this.IsCopy)
|
||||||
scanRet = new IntPtr(scanRet.ToInt64() - this.moduleCopyOffset);
|
scanRet = new IntPtr(scanRet.ToInt64() - this.moduleCopyOffset);
|
||||||
|
|
@ -285,7 +284,15 @@ public class SigScanner : IDisposable, ISigScanner
|
||||||
var insnByte = Marshal.ReadByte(scanRet);
|
var insnByte = Marshal.ReadByte(scanRet);
|
||||||
|
|
||||||
if (insnByte == 0xE8 || insnByte == 0xE9)
|
if (insnByte == 0xE8 || insnByte == 0xE9)
|
||||||
|
{
|
||||||
scanRet = ReadJmpCallSig(scanRet);
|
scanRet = ReadJmpCallSig(scanRet);
|
||||||
|
var rel = scanRet - this.Module.BaseAddress;
|
||||||
|
if (rel < 0 || rel >= this.TextSectionSize)
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException(
|
||||||
|
$"Signature \"{signature}\" resolved to 0x{rel:X} which is outside .text section. Possible signature conflicts?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If this is below the module, there's bound to be a problem with the sig/resolution... Let's not save it
|
// 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!
|
// TODO: THIS IS A HACK! FIX THE ROOT CAUSE!
|
||||||
|
|
@ -319,8 +326,9 @@ public class SigScanner : IDisposable, ISigScanner
|
||||||
public IEnumerable<nint> ScanAllText(string signature, CancellationToken cancellationToken)
|
public IEnumerable<nint> ScanAllText(string signature, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var (needle, mask, badShift) = ParseSignature(signature);
|
var (needle, mask, badShift) = ParseSignature(signature);
|
||||||
var mBase = this.IsCopy ? this.moduleCopyPtr : this.TextSectionBase;
|
var mBase = this.TextSectionBase;
|
||||||
while (mBase < this.TextSectionBase + this.TextSectionSize)
|
var mTo = this.TextSectionBase + this.TextSectionSize;
|
||||||
|
while (mBase < mTo)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue