首页 > 解决方案 > INC 操作码编译到错误的地址

问题描述

我正在编译以下代码,但它没有按预期工作。

有人可以解释为什么以下代码不起作用以及如何纠正它吗?

DWORD data_location = 0x0100579C;
DWORD ret = 0x1002FFA;

void __declspec(naked) inc()
{
    // The following is what I'm trying to accomplish which works
    *(DWORD*)data_location = *(DWORD*)data_location + 1;

    __asm
    {   
        inc [data_location] //Should compile as FF 05 9C570001, instead compiles to the address containing the pointer to data_location
        // inc data_location also compiles to the same thing above

        jmp [ret]
    }
}

标签: c++pointersx86inline-assemblycheat-engine

解决方案


如果我对你的理解正确,你想要一些类似的东西

DWORD data_location = 0x0100579C;
DWORD ret = 0x1002FFA;

void __declspec(naked) inc()
{
    __asm
    {   
        mov eax, [data_location]
        inc dword ptr [eax]

        jmp [ret]
    }
}

推荐阅读