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 


Get value of pointer [C++]?

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

Joined: 23 Apr 2012
Posts: 3

PostPosted: Mon Apr 23, 2012 12:09 pm    Post subject: Get value of pointer [C++]? Reply with quote

I have been looking for a while after a code that lets you get the value of a pointer. I have found the pointer in Cheat Engine and it works when I restart the program. But now to the question... How can I get the value into C++.

I have found a way to get the value of the dynamic address, but it changes all the time and therefore itīs no use.

I have a photo:
hxxp://yeyfiles.net/1057152502/this.jpg

(change the xx to tt obviously Wink

And the value I want to get is 27 (of course it changes, but just so you know what I mean). I want to get the value of 004828B0 into a int. How do I do that?

Can someone please give me the code to do that and explain how it works.

Smile[/img]
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon Apr 23, 2012 1:42 pm    Post subject: Reply with quote

- Read 4 bytes at the pointer's address.
- Add the offset to the accepted value.
- Read 4 bytes from that address and you got you're value

_________________
Stylo
Back to top
View user's profile Send private message
theatom
How do I cheat?
Reputation: 0

Joined: 23 Apr 2012
Posts: 3

PostPosted: Mon Apr 23, 2012 1:52 pm    Post subject: Reply with quote

Can you write the code to me? I have tried to make it work with ReadProcessMemory but it isīnt working. Like I said I would like the value to be put in a variable. Thanks for the answer so far. Smile
Back to top
View user's profile Send private message
661089799107
Expert Cheater
Reputation: 3

Joined: 25 Jan 2009
Posts: 186

PostPosted: Tue Apr 24, 2012 10:44 pm    Post subject: Reply with quote

Code:

template <typename T>
T readMemory(HANDLE hProcess, unsigned int address, int size=4) {
// 'buffer' will be of whatever type we specify using <> (Ex: <unsigned int> making it unsigned int buffer;)
   T buffer;

   if(!ReadProcessMemory(hProcess, (LPVOID) address, &buffer, size, 0))
      return 0;

   return buffer;
}


Code:

// Read address, add offset
unsigned int address = readMemory<unsigned int>(hProcess, 0x004828B0) + 0x454; // 'address' would now be 0x01E54D78

int x = readMemory<int>(hProcess, address); // this will give you the value you want ('26' in your pic)
Back to top
View user's profile Send private message
theatom
How do I cheat?
Reputation: 0

Joined: 23 Apr 2012
Posts: 3

PostPosted: Tue Apr 24, 2012 11:13 pm    Post subject: Reply with quote

Thank you so much!!! Now itīs working. Very Happy
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