Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 访问和编辑内存中的多个地址_C++_Memory_Memory Address - Fatal编程技术网

C++ 访问和编辑内存中的多个地址

C++ 访问和编辑内存中的多个地址,c++,memory,memory-address,C++,Memory,Memory Address,我想访问和编辑内存中的多个地址。 如果是模糊的,问题是:如果我使用内存扫描器,结果是一个地址列表,我将如何访问和编辑它们? 我已经被告知尝试将所有地址放入一个数组中,我该怎么做 以下是迄今为止的代码: // #include "stdafx.h" #include "iostream" #include "Windows.h" #include <cstdint> #include <stdint.h> using namespace std; int main()

我想访问和编辑内存中的多个地址。 如果是模糊的,问题是:如果我使用内存扫描器,结果是一个地址列表,我将如何访问和编辑它们? 我已经被告知尝试将所有地址放入一个数组中,我该怎么做

以下是迄今为止的代码:

//

#include "stdafx.h"
#include "iostream"
#include "Windows.h"
#include <cstdint>
#include <stdint.h>

using namespace std;
int main()
{
    int newValue = 0;
    int* p;
    p = (int*)0x4F6DCFE3DC; // now p points to address 0x220202

    HWND hwnd = FindWindowA(NULL, "Call of Duty®: Modern Warfare® 3 Multiplayer");// Finds Window
    if (hwnd == NULL) {// Tests for success
        cout << "The window is not open" << endl;
        Sleep(3000);
        exit(-1);
    }
    else {
        cout << "It's open boss!";
    }
    else {// If Successful Begins the following
        DWORD procID;
        GetWindowThreadProcessId(hwnd, &procID);
        HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);//Gets handle on process
        if (procID == NULL) {
            cout << "Cannot obtain process." << endl;
            Sleep(3000);
            exit(-1);
        }
        else {//Begins writing to memory
            while (newValue == 0) {
                 /*This Writes*/WriteProcessMemory(handle, (LPVOID)0x04F6DCFE3DC, &newValue, sizeof(newValue), 0);
                 cout << p;
                 Sleep(3000);

            }
        }
    }
}
//
#包括“stdafx.h”
#包括“iostream”
#包括“Windows.h”
#包括
#包括
使用名称空间std;
int main()
{
int newValue=0;
int*p;
p=(int*)0x4F6DCFE3DC;//现在p指向地址0x220202
HWND HWND=FindWindowA(NULL,“使命召唤®:现代战争®3多人游戏”);//查找窗口
如果(hwnd==NULL){//测试是否成功

cout这相当简单。只需使用
std::vector
来包含您要修改的所有这些地址以及它们应该达到的值:

std::vector<std::pair<int*,int>> changeMap = {
    { (int*)0x4F6DCFE3DC , 0 }
    // more address value pairs ...
};
无论你想用它实现什么


我已经被告知尝试将所有地址放入一个数组中,我该怎么做

如果要将所有地址内容设置为
0
,可以使用更简单的结构:

int newValue = 0;
std::vector<int*> changeAddrList = {
    (int*)0x4F6DCFE3DC ,
    // more addresses to change ...
};

// ...

for(auto addr : changeAddrList)
{
    WriteProcessMemory(handle, (LPVOID)addr , &newValue ,
                       sizeof(newValue), 0);
}
int newValue=0;
std::vector changeAddrList={
(int*)0x4F6DCFE3DC,
//更多要更改的地址。。。
};
// ...
用于(自动地址:changeAddrList)
{
WriteProcessMemory(句柄,(LPVOID)addr和newValue,
sizeof(newValue),0;
}

1在另一个进程内存中进行切换容易出错,并可能导致各种意外行为!

您的代码可能会在该程序的较新版本中失败,您正在尝试应用作弊代码。

请特别注意。不要发布文本图片,发布文本。制作一个。描述您想要实现的目标。描述地址列表的含义。为什么要编辑它们?描述如何访问地址列表是的,代码picutre通过常量显示访问。编辑问题以获取更多信息,不要将信息写入问题的答案。
p=(int*)0x4F6DCFE3DC;//现在p指向地址0x220202
Huh!?这就是为什么注释不应该描述明显的代码。代码经常更改,而注释不更改。然后它只会引起人们的注意。@StoryTeller您的问题是注释所说的是明显的吗?
如果{…}其他{…}其他{…}
这是错误的。我投了反对票,因为这个问题一团糟。我不想让新用户泄气,但如果你很粗鲁……你可以使用
for(自动&It:changeMap)C++以来句法糖的< /代码>11@Garmekain当然!我不想过分强调这一点。我很确定OP将足以消化我的答案;-)。你给出的答案并不难“消化”或者随便你怎么称呼它。@LEXERA.EXE好吧,那么你可以简单地接受它,如果它解决了你的问题。或者我误解了你的问题吗?误解*。希望它能解决我的问题。干得好。
int newValue = 0;
std::vector<int*> changeAddrList = {
    (int*)0x4F6DCFE3DC ,
    // more addresses to change ...
};

// ...

for(auto addr : changeAddrList)
{
    WriteProcessMemory(handle, (LPVOID)addr , &newValue ,
                       sizeof(newValue), 0);
}