GetLastError()获取错误代码299
本帖最后由 SuperGodkill 于 2023-7-24 10:03 编辑用ReadProcessMemory函数第一次读取成功但是第二次失败了,显示错误代码299,具体查了原因是“仅完成部分的 ReadProcessMemory 或 WriteProcessMemory 请求。”
#include <iostream>
#include<Windows.h>
int main()
{
//找到窗口句柄
HWND hwnd = FindWindowA("MainWindow", "植物大战僵尸中文版");
//通过窗口句柄找到进程
DWORD pid;
DWORD tid = GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
DWORD value = 0;
bool checkread;
unsigned long base = 0x006A9EC0;
unsigned long basevalue = 0;
unsigned long size = 0;
checkread = ReadProcessMemory(handle, (LPCVOID)(base), &value, sizeof(unsigned long), &size);
if (checkread == 0)
{
printf("读取失败,错误代码为%d\n", GetLastError());
}
else
{
printf("读取成功\n");
}
unsigned firstoffset = 0x768;
unsigned long firstvalue = 0;
checkread = ReadProcessMemory(handle, (LPCVOID)(firstoffset + basevalue), &value, sizeof(unsigned long), &size);
if (checkread == 0)
{
printf("读取失败,错误代码为%d\n", GetLastError());
}
else
{
printf("读取成功\n");
}
} https://img1.imgtp.com/2023/07/24/SHshI0MJ.png 第一次读取完以后,把size归0试试 在检查一下吧,第一个read接收的内存变量是不是填错了 bester 发表于 2023-7-24 09:48
第一次读取完以后,把size归0试试
他应该是变量填错了,第一次获取基址的变量和第二次计算的用的不是一个
页:
[1]