C++/作弊引擎,在谷歌浏览器中写入内存 - WriteProcessMemory & ReadProcessMemory
C++/Cheat Engine, Writing to memory in Google Chrome - WriteProcessMemory & ReadProcessMemory
为了学习更多的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 是开源的,因此您可以查看是否有办法通过查看子进程命令行参数来找出哪个渲染进程渲染某个选项卡。
- 将字符串存储在c++中的稳定内存中
- C++ 指针的内存地址和指向数组的内存地址如何相同?
- Win32编译器选项和内存分配
- 当vector是tje全局变量时,c++中vector的内存管理
- 带内存和隔离功能的SQLite
- 是否可以通过C++扩展强制多个python进程共享同一内存
- 迭代时从向量和内存中删除对象
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 多个文件的内存分配错误"在抛出 'std :: bad_alloc' what (): std :: bad_alloc 的实例后终止调用" [C++]
- 为什么示例代码访问IUnknown中已删除的内存
- 如何在C++类内存结构中创建"spacer"?
- 从构造函数抛出异常时如何克服内存泄漏
- malloc() 可能出现内存泄漏
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 如何针对特定情况调试和修复此双自由内存损坏问题
- 类型总是使用其大小存储在内存中吗
- 有没有一种方法可以测量c++程序的运行时内存使用情况
- 有没有一种方法可以使用placement new将堆叠对象分配给分配的内存