Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to read double at memory address?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Morbod
How do I cheat?
Reputation: 0

Joined: 17 Jun 2017
Posts: 2

PostPosted: Wed Dec 13, 2017 4:30 am    Post subject: How to read double at memory address? Reply with quote

Hi. I have two questions actually. The first one is, if I have a pointer that points to a double value, how do I properly read this value?
I found a few examples on the net, but none of it works, one of the things being something like this:

Code:

UINT32* pAddress = 0x200000;
double* pValue = (double*)pAddress;
double value = *pValue;


- which just end up crashing. I know the value is there though, as Cheat Engine can read it when I click on the address in the memory viewer.

The second question is, if I have a pointer like this:
Code:

UINT32* pAddress = new UINT32(0x200000);


And I did this:
Code:

UINT32* pAddress2 = (UINT32*)pAddress[8];


Would pAddress2 then point to an offset of 8 from pAddress, or what does it mean? I just saw this in an example on the internet and wasn't sure what exactly it meant.

Thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Wed Dec 13, 2017 5:20 am    Post subject: Reply with quote

Are you sure the the address is there and you're not just following a pointer? (nr1 mistake when people follow pointers from CE is that they just calculate base with offsets by just adding them)

this code should work:
Code:

double value = *(*double)0x200000;


when you test the code, do you run it in your own process or in the target process, because if your own, then that may be why it crashes

---

as for your second question:
Code:

UINT32* pAddress = new UINT32(0x200000);


why new ? What language is this ?

anyhow,
Code:

UINT32* pAddress2 = (UINT32*)pAddress[8];

will read the value at pAddress[8] (that's 0x200020) and store it as a pointer to pAddress2
Not quite sure what that would accomplish

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Morbod
How do I cheat?
Reputation: 0

Joined: 17 Jun 2017
Posts: 2

PostPosted: Wed Dec 13, 2017 6:01 am    Post subject: Reply with quote

Thanks for your reply. As for the second question, it seems like it was used to access different properties within a structure in a game, so I guess that's a way to do it.

Code:

double value = *(*double)0x200000;


I suppose you meant "(double*)" here, so after not before, right? The other one wouldn't compile anyway. However, this still doesn't seem to work for whatever reason.
And yes the code is in a DLL which I inject into the target process when testing it. I logged the address that the DLL uses, and when I go to that address in the memory viewer, it does in fact give me the correct double value, but when my DLL tries getting it, it still crashes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites