我如何从Cheat Engine修改一个AOB到C++?

问题描述 投票:0回答:1

我一直试图在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;

我想知道我做错了什么,因为用类似的东西来修改浮动值,一旦我解除了主模块句柄的保护,就能正常工作。

c++ arrays byte reverse-engineering cheat-engine
1个回答
0
投票

试试这个:

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);

请告诉我是否有效

© www.soinside.com 2019 - 2024. All rights reserved.