Folleach / GeometryDashAPI

API for Geometry Dash
MIT License
62 stars 8 forks source link

More information on how the GameProcess works? #10

Closed Starpelly closed 3 years ago

Starpelly commented 3 years ago

Just a quick question on how this block of code necessarily works. For example how the new[] array works, and what it does and means. What these numbers are and how you found out what they do. (Is there like a program I can use for it?) And why you do IntPtr.Add. I feel like there could be a lot documented on this. Thanks.

GameProcess process = new GameProcess();
process.Initialize(Access.PROCESS_VM_OPERATION | Access.PROCESS_VM_READ | Access.PROCESS_VM_WRITE);
IntPtr Player = process.Read<IntPtr>(process.GetModule("GeometryDash.exe"), new[] { 0x003222D0, 0x164, 0x224, 0x4E8, 0xB4});
int AddressPositionX = IntPtr.Add(Player, 0x62C).ToInt32();
while (true)
{
     float posX = process.Read<float>(AddressPositionX);
     if (posX > 2500)
     process.Write<float>(AddressPositionX, 0);
     Console.WriteLine($"Position X: {posX}");
     Thread.Sleep(16);
}
Folleach commented 3 years ago

This array are specify some offsets, which indicate where some value is located. If we read the pointers one by one with such offsets, then we will end up with the desired value. I used the Cheat Engine to find these offsets. Feature is named Pointer scan.

IntPrt.Add is used to add numbers with their address arithmetic. We can't just use pointer + offset.

Starpelly commented 3 years ago

Thanks, this was extremely helpful actually. Just one more quick question, what exactly does 0x62C mean? I know It is supposed to be a pointer but I don't know where to find it. Thanks.

Folleach commented 3 years ago

This is still the same offset, it's just the final offset from the chain, which means that for it we should already read not IntPtr but a specific type. In fact, this is an optimization, and as far as I remember, we can do this: float x = process.Read<float>(process.GetModule("GeometryDash.exe"), new[] { 0x003222D0, 0x164, 0x224, 0x4E8, 0xB4, 0x62C });

Starpelly commented 3 years ago

K Thanks