C++/作弊引擎,在谷歌浏览器中写入内存 - WriteProcessMemory & ReadProcessMemory

C++/Cheat Engine, Writing to memory in Google Chrome - WriteProcessMemory & ReadProcessMemory

本文关键字:内存 WriteProcessMemory ReadProcessMemory 谷歌浏览器 引擎 C++      更新时间:2023-10-16

为了学习更多的C++,我选择了 - 你知道 - 一些有趣的事情来做,那就是写入随机应用程序的内存。我编写的代码似乎适用于所有应用程序,但我很难让它与谷歌浏览器标签一起使用。

我正在尝试做的只是在作弊引擎的帮助下更改我在 Slope(y8.com 上)上的分数,我有内存地址。问题似乎是检索选项卡的进程 ID。 使用 Chrome 的任务管理器,我将选项卡的地址转换为十六进制,在作弊引擎中打开进程并找到分数地址。

问题来了。每当我使用GetWindowThreadProcessId(window, &processID); cout << processID时,它都不会打印 ID,可以在 chrome 的任务管理器中看到游戏选项卡。 事实上,它打印了整个 chrome 的 ID(我知道这一点,因为在 chrome 的任务管理器中,"chrome"具有该 ID)。并且分数不能写入或读取chrome的processID。如果我忽略这个问题,buffer似乎总是打印为 0.。没有变化。

我对此很陌生,希望自己不知道我在说什么。如果您自己测试游戏,则必须找到Chrome当时使用的地址。但是这是代码(我已经注释掉了WriteProcessMemory并放了Read,以便在我编写任何内容之前让它工作):

#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
int main() {
int buffer = 0;
LPVOID address = (LPVOID)0x15E7E1B0FB8/*(0x000000000192DFA0 + 0x0000291D8FE04000 + 0x18)*/;
cout << "Begin playing the game and wait for the 0 score to appear" << endl;
HWND window = FindWindow(NULL, "Slope Game - Play online at Y8.com");
if (window) {
cout << "Game found running! You ready to hax?" << endl;
DWORD processID = 11180;
GetWindowThreadProcessId(window, &processID);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, false, processID);
if (handle) {
/*string hackedScoreInput = "0";
cout << "Desired Score: " << flush;  getline(cin, hackedScoreInput);
int hackedScore = stoi(hackedScoreInput);
int suc = WriteProcessMemory(handle, address, &hackedScore, sizeof(hackedScore), NULL);
if (suc > 0) {
cout << "HAXED!" << endl;
CloseHandle(handle);
}
else {
cerr << GetLastError() << endl;
cerr << hackedScore << " of size: " << sizeof(hackedScore) << endl;
return 3;
}*/
while (true) {
ReadProcessMemory(handle, address, &buffer, sizeof(buffer), NULL);
cout << buffer << " at adress: " << processID << endl;
Sleep(100);
system("CLS");
}
}
else {
cerr << "Could not open the process" << endl;
return 2;
}
}
else {
cerr << "Error! Could not find window!" << endl;
Sleep(3000);
return 1;
}
return 0;
}

代码有什么问题?

现代浏览器使用多个进程,并且没有规则说浏览器选项卡 HWND 必须由网页"运行"的进程拥有。

某些浏览器实现可能有一个主进程来托管 UI,包括所有选项卡,但实际的网页内容可能会呈现到不同进程中的共享位图/内存中,在该进程中可以安全地运行脚本等。

Chrome 是开源的,因此您可以查看是否有办法通过查看子进程命令行参数来找出哪个渲染进程渲染某个选项卡。