Game Hacking 修改程式執行時的記憶體內容

修改概念:

先用 CE 找出要修改的關鍵 instruction,接著把這條關鍵指令, 改成我們想要執行的指令 (通常是改opcode, 例如把 JZ 改成 JNZ )

然而如果每次玩遊戲, 都要執行CE, 然後再去找關鍵指令, 接著再做修改, 實在太費力氣, 如此繁複的工作, 可以自己寫程式來完成.

首先我們得先要知道要修改的執行指令所對應的記憶體內容與位置,然後分別把它們紀錄下來.

接著寫程式去取得遊戲執行時的memory,然後把關鍵要修改的地方寫入即可, 下為對Trickster Online進行修改的範例

#include<windows.h>
#include<iostream>
using namespace std;
#define GIL  0x0047c8d4     //100%鑽地
#define GIL2 0x004be974     //白天        前進找0 (+2)
#define GIL3 0x00622bde     //鑽地無限制  倒退找1 (-1)
#define GIL4 0x00622ad4     //無限制鑽2
#define GIL5 0x00622c04     //自動鑽      後退找1 (-1)
#define GIL6 0x1211c188     //全地圖1
#define GIL7 0x1211c190     //全地圖2

void main()
{
HWND ff8Wnd;
HANDLE ff8Hnd;
DWORD pid;
ff8Wnd = FindWindow(NULL, TEXT(“卡巴拉島 – 神界系 : 宙斯”)); //or simply FindWindow(NULL, “Final Fantasy VIII”); in msvc++ 6
if(!ff8Wnd)
{
ff8Wnd = FindWindow(NULL, TEXT(“卡巴拉島 – 神界系 : 維納斯”));
}

if(!ff8Wnd)
{
cout << “Unable to locate Trickster window\n”;
}
else
{
GetWindowThreadProcessId(ff8Wnd, &pid);
ff8Hnd = OpenProcess(PROCESS_ALL_ACCESS, false, pid); //now we got process handle, ready to read/write
if(!ff8Hnd)
{
cout << “OpenProcess failed\n”;
}
DWORD bytes;
int tmpValue;
ReadProcessMemory(ff8Hnd, (void*)GIL, (void*)&tmpValue, 4, &bytes);

//cout << “Gil: ” << int(tmpValue) << endl << endl;

int gil = 0x9090;
if(WriteProcessMemory(ff8Hnd, (void*)GIL, (void*)&gil, 2, &bytes) > 0)
{
cout << “100%鑽地啟動\n\n”;
}

int gil2 = 0xffffffff;
if(WriteProcessMemory(ff8Hnd, (void*)GIL2, (void*)&gil2, 4, &bytes) > 0)
{
cout << “天亮啟動\n\n”;
}

int gil3 = 0x00007400;
if(WriteProcessMemory(ff8Hnd, (void*)GIL3, (void*)&gil3, 2, &bytes) > 0)
{
cout << “無限制鑽地啟動(沒有上限)\n\n”;
}

int gil4 = 0x00009090;
if(WriteProcessMemory(ff8Hnd, (void*)GIL4, (void*)&gil4, 2, &bytes) > 0)
{
cout << “無限制鑽地2啟動(沒有下限)\n\n”;
}

int gil5 = 0x00007400;
if(WriteProcessMemory(ff8Hnd, (void*)GIL5, (void*)&gil5, 2, &bytes) > 0)
{
cout << “自動鑽啟動\n\n”;
}

//cout << “全地圖啟動\n\n”;
//全地圖啟動

/*
while(true)
{
int gil6 = 0x0082008c;
WriteProcessMemory(ff8Hnd, (void*)GIL6, (void*)&gil6, 4, &bytes);

int gil7 = 0x0082008c;
WriteProcessMemory(ff8Hnd, (void*)GIL7, (void*)&gil7, 4, &bytes);

Sleep(1000);
//cout<<“sleep”;
}
*/

int gil6 = 0x0082008c;
WriteProcessMemory(ff8Hnd, (void*)GIL6, (void*)&gil6, 4, &bytes);

int gil7 = 0x0082008c;
WriteProcessMemory(ff8Hnd, (void*)GIL7, (void*)&gil7, 4, &bytes);

cout<<“Programmed by TARONO, 2008-10-02. \n\n”;
system(“PAUSE”);
}
}

Advertisements

4 thoughts on “Game Hacking 修改程式執行時的記憶體內容

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s