ReadProcessMemory on a 64 bit proces always returns Error 299

前提是你 提交于 2019-12-01 20:57:09

Just using MEMORY_BASIC_INFORMATION like that is incorrect. You should use either use MEMORY_BASIC_INFORMATION32 or MEMORY_BASIC_INFORMATION64 (as described in the remarks section in the MSDN) depending on whether the remote process is 32bit or 64bit.

The size and layout of the structure will be different depending on whether it's a 32bit or a 64bit process. By just using MEMORY_BASIC_INFORMATION you expect that the remote process uses whatever layout your current process uses.

In order to test whether the remote process is 32bit or 64bit you can use the IsWow64Process function like this:

bool is64BitProcess(HANDLE hProcess)
{
    const bool is64BitOS = sizeof(void *) == 8 || IsWow64Process(GetCurrentProcess());
    return is64BitOS ? IsWow64Process(hProcess)
                     : false;
}

So after some debugging and research it turned out the problem was with ASLR so i was reading from a wrong base , thanks for the help :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!