C#多重偏移

时间:2018-04-20 01:46:17

标签: c# pointers memory cheat-engine

当我写入具有多个偏移的地址时,我遇到了问题。

值不会改变。

代码:

int Base = 0x00477958;
VAMemory vam = new VAMemory("gameNameHere");

int localPlayer = vam.ReadInt32((IntPtr)Base);

while (true)
{
    int address = localPlayer + 0x34 + 0x6c + 0x6fc; // base + offsets (Score Pointer)
    vam.WriteInt32((IntPtr)(address), 5000000); // here if i replaced address with 0x02379F1C, it will work but that's not dynamic

    Thread.Sleep(500);
}

我使用作弊引擎获得抵消,我重新启动游戏以检查我是否有正确的偏移量

00477958 -> 02522880
02522880 + 6FC -> 023D5B00
023D5B00 + 6C -> 02379EE8
02379EE8 + 34 -> 02379F1C

02379F1C = 5034500 // Score

1 个答案:

答案 0 :(得分:0)

指针不是那样工作的,您需要在每个级别上“取消引用”。 我继续并修复了您的代码。

应该很容易跟进并了解正在发生的事情。

代码

int Base = 0x00477958;
VAMemory vam = new VAMemory("gameNameHere");

// So first you dereference the base address (read it)
int localPlayer = vam.ReadInt32((IntPtr)Base);

while (true)
{
    // for every offset you do the same until the last one
    int buffer = vam.ReadInt32((IntPtr)(localPlayer + 0x6FC));
    buffer = vam.ReadInt32((IntPtr)(buffer + 0x6C));

    // last offset you can just add to the buffer and it'll point to the memory address you intend on writing to. 
    IntPtr pScore = (IntPtr)(buffer + 0x34);

    vam.WriteInt32(pScore, 5000000); 

    Thread.Sleep(500);
}

此外,与发布的指针路径相比,您似乎是在向后添加偏移量(尽管这并不重要,因为您做错了,加上可交换属性...),或者至少是向后看我,希望上面的代码中的顺序是正确的,但是如果不正确,那么您知道问题出在哪里。