c++ - 我将如何将 AOB 从 Cheat Engine 修改为 C++?

标签 c++ arrays byte reverse-engineering cheat-engine

我一直在尝试修改在 C++ 内部的 Cheat Engine 中找到的字节数组,但是当我尝试从中读取或写入时遇到了访问冲突崩溃。

    // Writes pillarbox removal into memory ("33 83 4C 02" to "33 83 4C 00").
    *(BYTE*)(*((intptr_t*)((intptr_t)baseModule + 0x1E14850)) + 0x3) = 00;

我想知道我做错了什么,因为一旦我取消保护主模块句柄,对我修改的浮点值使用类似的东西就可以正常工作。

最佳答案

试试这个 :

void WriteToMemory(uintptr_t 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);
}

并这样称呼它:
MODULEINFO mInfo = GetModuleInfo("name.exe");

//Assign our base and module size
DWORD baseModule = (DWORD)mInfo.lpBaseOfDll;
uintptr_t addressToWrite = (uintptr_t)baseModule + 0x1E14850;
char writeThis[] = "\x33\x83\x4c\x00";
WriteToMemory(addressToWrite, writeThis, 4);

请让我知道它是否有效

关于c++ - 我将如何将 AOB 从 Cheat Engine 修改为 C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61509943/

相关文章:

c - C中的for循环只返回数组的第一个值

c - 从 C 中的文本文件中读取

c - 通过引用将字节加载到 C 字符串中

c++ - 重建三角形网格中的所有边

c++ - 使用 bool 导出压缩结构

c++ - Linux - 有时只会出现段错误 - 如何调试

C++ 类设计 - 轻松初始化/构建对象

php - 如何访问 protected 数组值?

c++ - 排序数组——issue

python - Python 3.x 中的日志记录错误 : TypeError: a bytes-like object is required, 而不是 'str'