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 


FAQ: How to use a pointer
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sun May 24, 2009 5:16 pm    Post subject: FAQ: How to use a pointer This post has 1 review(s) Reply with quote

Because this question comes back almost every week I'll try to explain how to work with pointers

I'm not going to tell you how to code it, but I will tell you what you have to do

Let's start with something easy, a level-1 pointer

you have a pointer where people say : 0048123C+10C , first off, this notation is wrong, the actual notation should be [0048123C]+10C, anyhow,
to get to the real address you have to READ the "4 BYTES" at 0048123C as a value, and add the value 10C to it. (Don't forget that the notation I use is in hexadecimal, even for offsets)
Now interpret this new value as an address, and you have the address that actually contains the address you need. Using this address you can now Write or Read from the specific item the pointer points to.


Now a little bit more complicated, a level-8 pointer:

Let's say you now have a pointer as noted down in ce:
Code:

address        offset
xxxxxxxx       108
xxxxxxxx       1c
xxxxxxxx       0
xxxxxxxx       118
xxxxxxxx       2c4
xxxxxxxx       34
xxxxxxxx       c0
0049aadc       16

Note that an alternative method of writing this down would be:
[[[[[[[[0049aadc]+16]+c0]+34]+2c4]+118]+0]+1c]+108

So, first read the "4-Bytes" value at 0049aadc
Now add to that result the first offset (16)
then interpret the new value as an address and read the 4 Bytes at that address
Add to that the 2nd offset (c0) to the value you just read
Again, interpret the value as address and read the 4 bytes there
and add the 3th offset (34) to the new value
Read 4 bytes
Add 4th offset (2c4)
Read 4 bytes
Add 5th offset (118)
Read 4 Bytes
Add 6th offset (0) Yes, 0 can be an offset, it's nothing special
Read 4 Bytes
Add 7th offset (1c)
Read 4 bytes
Add 8th offset (108)
You now finally have the final address.
This final address points to the address you want to modify. E.g add +10, or freeze(write in a in a loop), or just simply read out for stats

I hope this clears up the most common questions from people trying to add pointers to their trainer

(also check out http://forum.cheatengine.org/viewtopic.php?p=5280115#5280115 for help on how to deal with modulename+offset notations)

_________________
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


Last edited by Dark Byte on Mon Dec 05, 2011 9:16 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Mon May 25, 2009 3:40 pm    Post subject: Reply with quote

Thanks, this helped me with understanding multilevel pointers better. (never really understood it)
Back to top
View user's profile Send private message Visit poster's website
Sneak
Grandmaster Cheater Supreme
Reputation: 0

Joined: 05 Nov 2008
Posts: 1895

PostPosted: Mon May 25, 2009 9:38 pm    Post subject: Reply with quote

nice darkbyte. Now i can start ma hax xD
_________________
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Tue May 26, 2009 4:56 am    Post subject: Reply with quote

Thanks Dark Byte, I agree with talker0 this really helped me understand how to work with multilevel pointers.
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Tue May 26, 2009 4:59 am    Post subject: Reply with quote

I'll check it out when after I get my mcts.
_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
gunminiho
Expert Cheater
Reputation: 0

Joined: 15 Dec 2008
Posts: 144
Location: peru

PostPosted: Sun Jun 14, 2009 7:45 pm    Post subject: Reply with quote

Plop... it wasnt hard -.-!!! i really thought that i was gonna be hard,its just as read a 1 level pointer -.-!!!!
Back to top
View user's profile Send private message
Destrod16
Newbie cheater
Reputation: 0

Joined: 03 Aug 2009
Posts: 21

PostPosted: Mon Aug 10, 2009 12:14 am    Post subject: Reply with quote

This is really useful, thanks. I would also like to add how you would use multi-level pointers in C++. Here is an example:

Let's say you have 4 pointers, this is how you would do it.

Code:
DWORD *thefirst = (DWORD*)(*(DWORD*)0x0040014F + 0x1378);
DWORD *thesecond = (DWORD*)(*(DWORD*)thefirst + 0x18);
DWORD *thethird = (DWORD*)(*(DWORD*)thesecond + 0x974);
DWORD *thefourth = (DWORD*)(*(DWORD*)thethird + 0x34);


So there it is reading from them, but now to actually write to them you would add this simple line:
Code:
*thefourth = 100;


I hope I helped at all!
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Mon Aug 10, 2009 1:08 am    Post subject: Reply with quote

Destrod16 wrote:
This is really useful, thanks. I would also like to add how you would use multi-level pointers in C++. Here is an example:

Let's say you have 4 pointers, this is how you would do it.

Code:
DWORD *thefirst = (DWORD*)(*(DWORD*)0x0040014F + 0x1378);
DWORD *thesecond = (DWORD*)(*(DWORD*)thefirst + 0x18);
DWORD *thethird = (DWORD*)(*(DWORD*)thesecond + 0x974);
DWORD *thefourth = (DWORD*)(*(DWORD*)thethird + 0x34);


So there it is reading from them, but now to actually write to them you would add this simple line:
Code:
*thefourth = 100;


I hope I helped at all!


Rather than making 4 local variables, you could just reuse the first one.

Works nonetheless.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Aug 10, 2009 1:39 am    Post subject: Reply with quote

smartz993 wrote:
Rather than making 4 local variables, you could just reuse the first one.

Works nonetheless.


The extras will likely just get optimized away.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Aug 10, 2009 2:11 am    Post subject: Reply with quote

there's no harm in good code practice. it's better practice to write good code than to depend on the compiler to fix your messes
Back to top
View user's profile Send private message
Destrod16
Newbie cheater
Reputation: 0

Joined: 03 Aug 2009
Posts: 21

PostPosted: Mon Aug 10, 2009 2:15 am    Post subject: Reply with quote

Oh so you mean like this:
Code:
DWORD *thefirst = (DWORD*)(*(DWORD*)0x0040014F + 0x1378);
*thefirst = (DWORD*)(*(DWORD*)thefirst + 0x18);
*thefirst = (DWORD*)(*(DWORD*)thefirst+ 0x974);
*thefirst = (DWORD*)(*(DWORD*)thefirst+ 0x34);

*thefirst = 100;
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Aug 10, 2009 2:16 am    Post subject: Reply with quote

yes he does mean that, that way makes it nice and readable as well. better still, change 'thefirst' to a more meaningful name and it'd be great

i'd find that a lot easier to understand than reading the initial code. i get confused when i see people putting in obsolete/superfluous variables since i'm waiting to see their use elsewhere further in the program, etc.
Back to top
View user's profile Send private message
Destrod16
Newbie cheater
Reputation: 0

Joined: 03 Aug 2009
Posts: 21

PostPosted: Mon Aug 10, 2009 2:36 am    Post subject: Reply with quote

Ok, oh and could I have that speedhack you wrote and possibly the source of it? If you don't want to give the source then that's fine.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Aug 10, 2009 2:46 am    Post subject: Reply with quote

yes, at work right now. i'll post it when i get home in like 10 more hours..
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sat Sep 05, 2009 9:52 am    Post subject: Reply with quote

Quote:
to get to the real address you have to READ the "4 BYTES" at 0048123C as a value, and add the value 10C to it.


What if it's not a 4-byte pointer? Razz
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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