Fix GameNetwork sig (#2031)

* Fix GameNetwork sig

* Fix SigScanner and add safeguard to prevent bad jmp resolution
This commit is contained in:
srkizer 2024-08-28 00:33:47 +09:00 committed by GitHub
parent 42a10a1215
commit 063f58a49a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View file

@ -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 ?? ?? 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.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");
}
}

View file

@ -276,8 +276,7 @@ public class SigScanner : IDisposable, ISigScanner
}
}
var mBase = this.IsCopy ? this.moduleCopyPtr : this.TextSectionBase;
var scanRet = Scan(mBase, this.TextSectionSize, signature);
var scanRet = Scan(this.TextSectionBase, this.TextSectionSize, signature);
if (this.IsCopy)
scanRet = new IntPtr(scanRet.ToInt64() - this.moduleCopyOffset);
@ -285,7 +284,15 @@ public class SigScanner : IDisposable, ISigScanner
var insnByte = Marshal.ReadByte(scanRet);
if (insnByte == 0xE8 || insnByte == 0xE9)
{
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
// 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)
{
var (needle, mask, badShift) = ParseSignature(signature);
var mBase = this.IsCopy ? this.moduleCopyPtr : this.TextSectionBase;
while (mBase < this.TextSectionBase + this.TextSectionSize)
var mBase = this.TextSectionBase;
var mTo = this.TextSectionBase + this.TextSectionSize;
while (mBase < mTo)
{
cancellationToken.ThrowIfCancellationRequested();