You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Management;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace godtier_patcher
{
public class Patcherino
{
public const long FunctionRVA = 0x4A49;
public readonly byte[] Shellcode = { 0x90, 0x90, 0x90, 0x90, 0x90 };
public Process Process;
public IntPtr ProcessHandle;
[DllImport("kernel32.dll")]
private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, uint lpNumberOfBytesWritten);
public Patcherino(Process proc)
{
Process = proc;
this.ProcessHandle = proc.Handle;
if (this.ProcessHandle == IntPtr.Zero)
throw new Exception("OpenProcess failed");
}
public bool WriteByteArray(long addr, byte[] buffer)
{
return WriteProcessMemory(ProcessHandle, (IntPtr)addr, buffer, (uint)buffer.Length, 0);
}
public async Task<bool> Patch()
{
Log.Info("Module Base Address -> 0x" + Process.MainModule.BaseAddress.ToString("X8"));
var functionAddress = (long)Process.MainModule.BaseAddress + FunctionRVA;
Log.Info("Instruction Address (RVA 0x4A49) -> 0x" + functionAddress.ToString("X8") + "\n");
Log.Critical("Patching...");
var success = WriteByteArray(functionAddress, Shellcode);
if (success)
{
Log.Critical("Function patched successfully! Thanks for using! Press enter to close this!");
}
else
{
Log.Error("Could not patch function.");
}
return success;
}
}
}