How do you return the value a memory address holds?

Hi there how do you read the address of a program and return the value of what ever the data the address holds? I have the following code which reads an offset address of a program but I would like to return the value of the address that I'm checking to do some other stuff with it.

inline Mem *Read(DWORD64 address)
{
this->value = address;
return (this->r(0));
}

inline Mem *r(DWORD64 ofs)
{
if (!this || !value)
return 0;

if (!ReadProcessMemory(Handle, (void*)(value + ofs), &value, sizeof(DWORD64), 0))
return 0;

return this;
}



m.Read(0x1428003C0)->r(0x100);
for example so I read the offset 0x100 inside the address 0x1428003C0, I know it holds the value of vehicle speed how can I return the speed value from that address? I would like to find out the speed and depends on the speed I would apply breaks or accelerate. I have tried to cout the m.read command and I get weird garbage that I do not understand, I'm guessing its the static memory address of the program that I'm currently reading?
You need to cast the memory address to a pointer to the type of the speed variable. Then you can read the value: int speed = *((int *)address);
Topic archived. No new replies allowed.