C++ 读内存代码
2022-12-02 / C/C++ / 395 次围观 / 0 次吐槽 ///注入Dll读内存地址 DWORD ReadMemory(UINT_PTR 地址) { __try { return *(DWORD*)地址; } __except(1){ return 0; } }
跨进程读写:
const HWND 窗口句柄{ FindWindowA("窗口类名", "窗口名称") }; DWORD Pid, Tid = GetWindowThreadProcessId(窗口句柄, &Pid); HANDLE 进程句柄 = OpenProcess(PROCESS_ALL_ACCESS, 0, Pid); DWORD ReadMemory4Byte(UINT_PTR MemoryAddress = 0x0) { DWORD buffer{ 0x0 }; ReadProcessMemory(进程句柄, (LPCVOID)MemoryAddress, &buffer, 4, 0); std::cout << "调试输出:\n 游戏窗口句柄:" << 窗口句柄 << " tid:" << Tid << " pid:" << Pid << " 进程句柄:" << 进程句柄 << " 读取的数据:" << buffer << std::endl; return buffer; } bool WriteMemory4Byte(UINT_PTR MemoryAddress, int MemoryValue) { bool 结果 = WriteProcessMemory(进程句柄, (LPVOID)MemoryAddress, &MemoryValue, 4, 0); return 结果; }
- 上一篇:C++ 打开控制台/关闭控制台
- 下一篇:C++ MFC_Dll初始化窗口显示
Powered By Cheug's Blog
Copyright Cheug Rights Reserved.