各个函数解析
这是我根据b站上面的视频使用ce初步修改,自己用vs2022用c语言实现的,完成了其中的部分功能
在自己的电脑上完美运行,不知道其他的怎么样
main()
int main()
{
int *base1 = (int*)0x2433240; //所有人的子弹基址
int *base2 = (int*)0x25069bc; //自己的子弹基址
int *bblood = (int*)0x204ba020; //血基址
int* bloodadd = (int*)0x1ff8a020;
int myp = 0x2040fbc8; //僵直
DWORD csid = 0;
csid = GetPid();
//printf("%d\n", csid);
int choice = 0;
int flag = 0; //flag用来存放是否修改(1修改,0恢复)
int yon; //是否继续修改
while (1)
{
printf("\n是否继续修改?(1|0)\n");
scanf("%d", &yon);
if (yon == 1)
{
}
else
{
printf("\n\n\n\n+++++++++++++++感谢使用++++++++++++++++\n\n\n\n");
return 0;
}
printf("1:所有人无限子弹\n\n2:自己无限子弹\n\n3:血量999999(开启此项功能后控制台无反应,关闭控制台效果结束)\n\n4:无限金币\n\n5:被击中不减速(无效果请刷新游戏)\n\n6:稳定的射击\n\n7:手枪连发\n\n");
printf("\n\n\n+++++++++++++++++++++++++++++++请输入想要达到效果前面的号码,格式:<效果> <1|0> +++++++++++++++++++++++++++++++\n");
scanf("%d", &choice);
scanf("%d", &flag);
if (choice == 1)
{
Bullet(flag, csid, base1);
}
else if (choice == 2)
{
Bullet(flag, csid, base2);
}
else if (choice == 3)
{
Blood(flag, csid, bloodadd);
}
else if (choice == 4)
{
Mymoney(flag, csid, base2);
}
else if (choice == 5)
{
Speed(flag,csid, base1, myp);
}
else if (choice == 6)
{
StableShooting(flag,csid, base2);
}
else if (choice == 7)
{
ShortGun(flag,csid);
}
else
{
printf("Input error");
}
}
return 0;
}
GetPid()
DWORD GetPid()
{
DWORD pid = 0;
HWND hcs = 0;
hcs = FindWindow(NULL, L"Counter-Strike"); //第一个参数是窗口的类型,vs的spy++可以查询,第二个参数是窗口的名称)
//printf("%d\n", hcs);
if (hcs != 0)
{
GetWindowThreadProcessId(hcs, &pid); //通过FindWindow返回的窗口的句柄来获取Pid
}
else
{
printf("please open cs\n");
return 0;
}
return pid;
}
无限子弹
这一块可以修改所有人的子弹数和自己的子弹数
样的
下面的代码是根据在ce中找到的多层偏移地址,通过ReadProcessMemory() 和 WriteProcessMemory() ,对存放子弹的内存空间修改,将子弹数设置为999
也可以通过修改汇编代码实现真正的子弹数不减少,但在内存中每把枪都有自己的空间,需要一个一个进行修改,创建一个专门的函数即可)
void Bullet(int flag,DWORD pid,int *base)
{
//int buadd = 0x2038151f;
//Patch(buadd, pid);
DWORD oldprotect;
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
int base2 =0;
int base3 = 0;
int base4 = 0;
int base5 = 0;
int s1 = ReadProcessMemory(hPro, (LPCVOID)base, &base2, 4, NULL);
int t1 = GetLastError();
if (s1 == 0)
{
printf("ReadProcessMemory Error1\n");
}
int s2 = ReadProcessMemory(hPro, (LPCVOID)(base2+0x7c), &base3, 4, NULL);
int t2 = GetLastError();
if (s2 == 0)
{
printf("ReadProcessMemory Error2\n");
}
int s3 = ReadProcessMemory(hPro, (LPCVOID)(base3 +0x5ec), &base4, 4, NULL);
int t3 = GetLastError();
if (s3 == 0)
{
printf("ReadProcessMemory Error3\n");
}
int s4 = ReadProcessMemory(hPro, (LPCVOID)(base4 + 0xcc), &base5, 4, NULL);
int t4 = GetLastError();
if (s4 == 0)
{
printf("ReadProcessMemory Error4\n");
}
int address = base4+0xcc;
int nbullet = 999;
//DWORD NumberOfByteRead;
if (flag == 0)
{
nbullet = 30;
}
if (hPro == 0)
{
printf("false to get process PID\n");
return;
}
VirtualProtectEx(hPro, (LPVOID)address, 10, PAGE_READWRITE, &oldprotect);
int a = GetLastError();
int write = WriteProcessMemory(hPro, (LPVOID)address, &nbullet, 2, NULL);
if (write == 0)
{
printf("falied to WriteProcessMemory\n");
int b = GetLastError();
return ;
}
}
无限血
通过偏移地址的跟踪找到血量的内存地址并将该地址一直写入255
该方法的缺点是,只有关闭修改器才可以停止修改
int Blood(int flag,DWORD pid,int *base)
{
DWORD NumberOfByteRead;
DWORD oldprotect;
HANDLE hPro = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
int base2 = 0;
int base3 = 0;
float base4 = 0;
int s1 = ReadProcessMemory(hPro, (LPCVOID)base, &base2, 4, NULL);
int t1 = GetLastError();
if (s1 == 0)
{
printf("Blood