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 


[help]Using pointers with offsets in (c++)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Aug 24, 2008 11:07 am    Post subject: Reply with quote

WafflesFTW wrote:
Slugsnack wrote:
For the offset, just dereference the pointer then add the offset and you then will have the current dynamic address of that buffer or whatever.

For the second question, as Symbol says, create a new thread and do it there and it would be smart to add some Sleep to it too. You can actually do it in your main thread if you don't have any other functions to your application.


No, you dereference the pointer after adding the offset.

No, you dereference the pointer and then add the offset. The whole point of a pointer is that it is a 4 byte value holding the address of something else. If you add the offset then you will not be dereferencing the pointer anymore but dereferencing something else further on. There'd be no point in an offset if it was done how you are suggesting. Since it would be a static address + static offset = static address. So you could just dereference the static address and there would be no pointer.
Back to top
View user's profile Send private message
WafflesFTW
Expert Cheater
Reputation: 0

Joined: 21 Mar 2008
Posts: 131

PostPosted: Sun Aug 24, 2008 9:31 pm    Post subject: Reply with quote

Damn, I must have got it all wrong then. Thanks for the correction.
Back to top
View user's profile Send private message AIM Address
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sun Aug 24, 2008 11:15 pm    Post subject: Reply with quote

pointer is static based on how your program is built
and if u load up your program it finds a random spot in memory (RAM)
now that random address + your pointer gives you your value or address to another pointer however its built.

Now if u got a dll file u built in C++ injected into ur programs it becomes part of it.. so it starts to share pointers with ya. Then u dont need to worry bout any random address.

But seriouslyss just do a pointer example in C++ make a bunch of int's near each other do a printf("1: %X, &first); etc.. and u will find out the address goes up by 4.. if its a int.. etc.. so thats what a pointer is.. its a address in memory which isn't random its like part of the program source code.

the addresses u find in cheat engine is just like finding a needle in a haystack.. its random loaded spot + program pointer to get your value.

so u reload ur program it won't be same address cuz random loaded spot changed..

Now if u dont want to do injections but still get that random address. i said there some api to get where its loaded. i think its called OpenProcess() then u use it with WriteProcessmemory() or something like that and change by pointers

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Mon Aug 25, 2008 2:17 pm    Post subject: Reply with quote

Alternatively, if you have direct memory access (injected dll case), you can do this:
Code:

void *p;
p = 0xBAADFOOD; //random example of base
p = (void *)((char *)p)[OFFSET1];
p = (void *)((char *)p)[OFFSET2];
p = (void *)((char *)p)[OFFSET3];
*(DWORD *)p = VALUE;


When you deference as an array, it multiplies the index ([i]) by sizeof(ptr type). So for char *, it multiplies by 1.
You could also use DWORD * the whole time, and divide your offsets by sizeof(DWORD).

~nog_lorp

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Mon Aug 25, 2008 3:58 pm    Post subject: Reply with quote

or instead of using char* if you have a array full of int's u could use DWORD* and it will increment by 4 instead of 1 aka (char*)

DWORD p[4] = {1111111,2222222,123123};
DWORD p1,p2,p3;

p1 = ((DWORD *)&p)[1];
p2 = ((DWORD *)&p)[2];
p3 = ((DWORD *)&p)[3];

DWORD* abc = p;

p1 = ((DWORD *)abc)[1];
p2 = ((DWORD *)abc)[2];
p3 = ((DWORD *)abc)[3];


*(DWORD*)abc[1] = blahlbah
*(DWORD*)abc[2] = blahlbah
*(DWORD*)abc[3] = blahlbah


meh just fooling around

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Mon Aug 25, 2008 6:03 pm    Post subject: Reply with quote

Code:
DWORD p[4] = {1111111,2222222,123123};
DWORD p1,p2,p3;

p1 = ((DWORD *)&p)[1];
p2 = ((DWORD *)&p)[2];
p3 = ((DWORD *)&p)[3];


This will crash.
p is already a dword pointer. &p is a double pointer, but then you cast it to dword pointer and try to dereference it with an offset.

This will not compile or warn and crash:
Code:
DWORD* abc = p;

*(DWORD*)abc[1] = blahlbah
*(DWORD*)abc[2] = blahlbah
*(DWORD*)abc[3] = blahlbah


abc is is a DWORD pointer, you dereference it with * then try to take the resulting DWORD and dereference it with an offset.

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
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
Goto page Previous  1, 2
Page 2 of 2

 
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