2

如何使用WriteProcessMemory更改我当前弹药地址的弹药?我知道怎么读,只是不知道怎么写。是 SetAmmo 。我以为我做的一切都是对的?

代码:

#include <iostream>
#include <math.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <Windows.h>
using namespace std;

 DWORD pid;
 DWORD Ammo = 0x07823C5EC;
 int MyAmmo;
 int SetAmmo = 1;
int main(){

    HWND hwnd = FindWindowA(0, ("Garry's Mod"));

    GetWindowThreadProcessId(hwnd, &pid);
    HANDLE pHandle = OpenProcess(PROCESS_VM_READ, FALSE, pid);

    ReadProcessMemory(pHandle, (LPVOID)Ammo, &MyAmmo, sizeof(MyAmmo), 0);
    cout<<"Current Ammo = "<<MyAmmo<<endl;

    WriteProcessMemory(pHandle, (LPVOID)Ammo, &SetAmmo, sizeof(SetAmmo), 0);
    system("Pause");
    return 0;
}  
4

1 回答 1

0

您以读取权限打开进程:

HANDLE pHandle = OpenProcess(PROCESS_VM_READ, FALSE, pid);

尝试:

HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
于 2017-06-08T06:29:42.493 回答