C++:从注入的DLL读取内存的好方法是什么?

C++ : What's a good way to read memory from injected DLL?

本文关键字:方法 是什么 内存 DLL 注入 C++ 读取      更新时间:2023-10-16

我是这个专业领域的新手,所以我不完全确定......我知道外部你有两个功能:WriteProcessMemory和ReadProcessMemory,但内部情况不同......我对指针也不够熟悉,无法自己制作 - 但如果你能为我评论它,我想我会没事的:)。

那么,读取内存的最佳方法是什么?

顺便说一下,这是我的写内存功能:

void WriteToMemory(DWORD addressToWrite, char* valueToWrite, int byteNum)
{
    //used to change our file access type, stores the old
    //access type and restores it after memory is written
    unsigned long OldProtection;
    //give that address read and write permissions and store the old permissions at oldProtection
    VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
    //write the memory into the program and overwrite previous value
    memcpy((LPVOID)addressToWrite, valueToWrite, byteNum);
    //reset the permissions of the address back to oldProtection after writting memory
    VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, NULL);
}

这里有一种方法可以做到这一点:

void ReadFromMemory(DWORD addressToRead, float value)
{
    value = *(float*)addressToRead;
}

还有其他建议吗?