1.简介
《命令与征服:红色警戒(报)3》作为经典游戏,是不少人儿时的记忆,同时也是博主童年最爱的一款游戏,为此最近我重新下载了该款游戏,红警3的下载地址如下:
链接:https://pan.baidu.com/s/1yCDmmmYpiDfW4TnwSGme9g?pwd=ajsi
提取码:ajsi
本文针对金币和电量无线修改的源码和相关教程
2.破解方法
1.获取红色警戒3游戏程序的句柄
const char* text = "命令与征服:红色警报3";
HWND hwnd = FindWindow(NULL, text);
if (hwnd == NULL)
{
MessageBox(NULL, TEXT("RA3 is not found! ACanary must find it again!"), TEXT("crack_ra3"), MB_ICONSTOP);
return 1;
}
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
2.通过游戏金币初始值(默认为10000,可在开始游戏界面修改)查找存储金币数值的地址
由于查找到的地址较多,因此需要在此基础上继续搜索
int value[1024] = { -1 };
int value_input = 1;
cout << "请输入需要寻找的值:";
cin >> value_input;
int ans[1024] = { 0 };
int num = 0;
for (int addr = 0x00000000; addr < 0x08000000; )
{
ReadProcessMemory(handle, (LPVOID)addr, &value, 4096, NULL);
for (int i = 0; i < 1024; i++) {
if (value[i] == value_input)
{
ans[num++] = addr + 4 * i;
cout << num << " . 0x";
printf("%x\n", addr + 4 * i);
}
}
addr += 4096;
}
cout << "find addr number is: " << num << endl;
3.使用金币(可以建造建筑或是训练士兵?这个无所谓,主要目的是使得金币数改变)
4.遍历步骤2中找到的地址,筛选出地址存储值为当前金币数的地址,直到地址条数为较少数值时停止筛选
int v = -1;
int n = 0;
int res[512];
n = 10;
while (n > 4) {
n = 0;
cout << "请输入需要寻找的值(设置的值不得为-1,即-1为退出查找):";
cin >> value_input;
for (int i = 0; i < num; i++)
{
ReadProcessMemory(handle, (LPVOID)ans[i], &v, 4, NULL);
if (v == value_input)
{
res[n++]= ans[i];
cout << n << " . 0x";
printf("%x\n", ans[i]);
}
}
}
5.修改金币存储地址处的数值
int money = 1000000000;
cout << "ACanary,what money do you want:";
cin >> money;
switch(n){
case 1:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
break;
case 2:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
break;
case 3:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[2], &money, 4, NULL);
break;
case 4:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[2], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[3], &money, 4, NULL);
break;
}
关闭程序句柄,破解成功
3.破解测试
1.打开游戏遭遇战或局域网(初始资源为10000)
2.初次搜索(当前资源金币为10000)
3.使用资源(建造发电站)
3.第二次搜索(当前资源金币为9200)
4.输入修改值99999999,游戏资源修改为99999999
【注意:】更改游戏资源金币后并不会立刻刷新资源金币,需要再次使用金币资源,此时游戏资源才会刷新
4.完整代码(如果无法运行那就是需要以管理员身份运行exe文件,权限不够)
#include<iostream>
#include<Windows.h>
using namespace std;
int main()
{
const char* text = "命令与征服:红色警报3";
HWND hwnd = FindWindow(NULL, text);
if (hwnd == NULL)
{
MessageBox(NULL, TEXT("RA3 is not found! ywh must find it again!"), TEXT("crack_ra3"), MB_ICONSTOP);
return 1;
}
DWORD pid;
GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (!handle)
{
printf("ErrorCode=%x\n", GetLastError());
}
int value[1024] = { -1 };
int value_input = 1;
cout << "请输入需要寻找的值:";
cin >> value_input;
int ans[1024] = { 0 };
int num = 0;
for (int addr = 0x00000000; addr < 0x08000000; )
{
ReadProcessMemory(handle, (LPVOID)addr, &value, 4096, NULL);
for (int i = 0; i < 1024; i++) {
if (value[i] == value_input)
{
ans[num++] = addr + 4 * i;
cout << num << " . 0x";
printf("%x\n", addr + 4 * i);
}
}
addr += 4096;
}
cout << "find addr number is: " << num << endl;
int v = -1;
int n = 0;
int res[512];
n = 10;
while (n > 4) {
n = 0;
cout << "请输入需要寻找的值(设置的值不得为-1,即-1为退出查找):";
cin >> value_input;
for (int i = 0; i < num; i++)
{
ReadProcessMemory(handle, (LPVOID)ans[i], &v, 4, NULL);
if (v == value_input)
{
res[n++]= ans[i];
cout << n << " . 0x";
printf("%x\n", ans[i]);
}
}
}
int money = 1000000000;
cout << "ACanary,what money do you want:";
cin >> money;
switch(n){
case 1:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
break;
case 2:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
break;
case 3:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[2], &money, 4, NULL);
break;
case 4:
WriteProcessMemory(handle, (LPVOID)res[0], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[1], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[2], &money, 4, NULL);
WriteProcessMemory(handle, (LPVOID)res[3], &money, 4, NULL);
break;
}
CloseHandle(handle);
return 0;
}
文章原创,禁止私自转载,转载前请联系博客获得同意,本文仅供学习交流