Reputation: 1
I have problem when I write to address with multiple offsets.
value doesn't change.
Code:
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);
}
I used cheat engine to get offsets and i restarted the game to check that i have the correct offsets
00477958 -> 02522880
02522880 + 6FC -> 023D5B00
023D5B00 + 6C -> 02379EE8
02379EE8 + 34 -> 02379F1C
02379F1C = 5034500 // Score
Upvotes: 0
Views: 1503
Reputation: 21
Pointers don't work like that, you need to "dereference" at each level. I went ahead and fixed your code.
Should be pretty easy to follow along and understand what's happening.
Code
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);
}
Also, you were seemingly adding the offsets in a backwards order in comparison to the pointer path you posted (although it doesn't really matter cause you were doing it wrong, plus commutative property...), or at least it looked backwards to me so hopefully the order is correct in the code above, but if it's not, then you know what the problem is.
Upvotes: 2