内存补丁的写法

昨天从2008年的老EA forex Growth Bot 1.8看到内存补丁的写法,用于破解ea的限制。

#include <WinUser32.mqh>
#import "kernel32.dll"
   int  GetCurrentProcess();
   int  WriteProcessMemory(int handle, int address, int& buffer[], int size, int& written);
   int  LoadLibraryA(string file);
#import

void fgbpatch() 
{
   int patch1[] = {0xB8, 0x33, 0x33, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90};
//内存准备写入的内容
   string lib = "experts\libraries\fxgrbot.dll";
//要破解fxgrbot.dll这个dll
   if (AlreadyPatched==true) return(0);
   int h = LoadLibraryA(lib);
   if (h != 0) {
      ProcessPatch(h + 0x15B850, 0x01);
//找到线程的入口地址,然后使用偏移地址
      PatchZone(h + 0x14969C, patch1);
      AlreadyPatched = true;
   }
   else {
      Print("FGB not patched!");
   }
}

int ProcessPatch(int address, int byte)
{
   int mem[1];
   int out;
   mem[0] = byte;
   int hproc = GetCurrentProcess();
   int result = WriteProcessMemory(hproc, address, mem, 1, out);
   return (result);
}

void PatchZone(int address, int patch[]) {
   int mem[1];
   int out;
   int hproc = GetCurrentProcess();
   for (int i = 0; i < ArraySize(patch); i++) {
      mem[0] = patch[i];
      WriteProcessMemory(hproc, address + i, mem, 1, out);
   }
   return(0);
}


本博客所有文章如无特别注明均为原创。作者:天泓评测
分享到:更多

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)