如何修改另一个进程的内存?

时间:2019-07-18 22:08:27

标签: c++

我正在尝试制作一个软件,该软件要求一个名为 AssaultCube 的游戏的进程ID,如果找不到该软件,则答复“错误”。但是,如果显示,它将显示一个菜单。现在基本上我想要实现的是,当我键入newbullets然后键入一个值时,我希望该软件编辑游戏的内存。然而,正如我尝试的那样,我一次又一次失败。感谢您的帮助。

#include <iostream>
#include <windows.h>
using namespace std;

int main()
{

    int procid;
    string command;
    int value;

    cout << "Enter the process id : ";
    cin >> procid;
    HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procid);
    if(procid == NULL)
    {
        cout << " Error " << endl;
    }
    else
    {
        cout << "Welcome To T ! \n - Bullets [shack] \n";
        cin >> command;
        if(command == "newbullets")
        {
            cout << "Enter the value : \n";
            cin >> value;
            if(value != 0)
            {
                char ahad = WriteProcessMemory(handle, (LPVOID)0x4BC74A44, &value, sizeof(value), 0);
                if(ahad)
                {
                    cout << "done";
                }
                else{
                    cout << "error";
                }
            }
        }
    }
}

0 个答案:

没有答案
相关问题