Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRSRO BYPASS #787

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 43 additions & 21 deletions Library/RSBot.Core/Components/ClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -90,34 +91,31 @@ public static async Task<bool> Start()
ReadProcessMemory(process.Handle, process.MainModule.BaseAddress, moduleMemory,
process.MainModule.ModuleMemorySize, out _);

var pattern = !isVtcGame ? "6A 00 68 50 2D 2D 01 68 5C 2D 2D 01" : "6A 00 68 A0 D6 28 01 68 AC D6 28 01";

var patchNop = new byte[] { 0x90, 0x90 };
var patchNop2 = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };
var patchJmp = new byte[] { 0xEB };

var address = FindPattern(pattern, moduleMemory);
if (address == IntPtr.Zero)
if (isVtcGame)
{
Log.Error("XIGNCODE patching error! Maybe signatures are wrong?");
return false;
}

WriteProcessMemory(pi.hProcess, address - 0x6A, patchJmp, 1, out _);
WriteProcessMemory(pi.hProcess, address + 0x13, patchJmp, 1, out _);
var pattern = "6A 00 68 A0 D6 28 01 68 AC D6 28 01";
var patchNop = new byte[] { 0x90, 0x90 };
var patchNop2 = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };
var patchJmp = new byte[] { 0xEB };
var address = FindPattern(pattern, moduleMemory);
if (address == IntPtr.Zero)
{
Log.Error("XIGNCODE patching error! Maybe signatures are wrong?");
return false;
}

if (isTRGame)
{
WriteProcessMemory(pi.hProcess, address - 0x6A, patchJmp, 1, out _);
WriteProcessMemory(pi.hProcess, address + 0x0C, patchNop2, 5, out _);
WriteProcessMemory(pi.hProcess, address + 0x13, patchJmp, 1, out _);
WriteProcessMemory(pi.hProcess, address + 0x95, patchJmp, 1, out _);
}
else
{
WriteProcessMemory(pi.hProcess, address + 0xC, patchNop2, 5, out _);
WriteProcessMemory(pi.hProcess, address + 0x90, patchJmp, 1, out _);
}
if (isTRGame)
{
if (!PatchTRSROAddresses(pi.hProcess))
{
Log.Error("XIGNCODE patching error! Maybe signatures are wrong?");
}
}

moduleMemory = null;
GC.Collect();
Expand All @@ -144,6 +142,30 @@ public static async Task<bool> Start()
return await Task.FromResult(true);
}

/// <summary>
/// Patch TRSRO specific addresses with JMP instructions
/// </summary>
private static bool PatchTRSROAddresses(IntPtr processHandle)
{
// Addresses to patch
IntPtr address1 = new IntPtr(0x006D0964);
IntPtr address2 = new IntPtr(0x006D0BFA);

// Patch data for address1 to JMP 0x006D0B34
byte[] patchData1 = { 0xE9, 0xCB, 0x01, 0x00, 0x00 }; // JMP instruction with relative offset

// Patch data for address2 to JMP 0x006D0C17
byte[] patchData2 = { 0xE9, 0x18, 0x00, 0x00, 0x00 }; // JMP instruction with relative offset

if (!WriteProcessMemory(processHandle, address1, patchData1, (uint)patchData1.Length, out _))
return false;

if (!WriteProcessMemory(processHandle, address2, patchData2, (uint)patchData2.Length, out _))
return false;

return true;
}

/// <summary>
/// Kill the game client process
/// </summary>
Expand Down