gpt4 book ai didi

c++ - 如何接受常量的用户输入并使用 writeprocessmemory?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:43:26 26 4
gpt4 key购买 nike

如何使用 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;
}

最佳答案

您以读取权限打开进程:

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

尝试:

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

关于c++ - 如何接受常量的用户输入并使用 writeprocessmemory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44428152/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com