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 


[C++] Pointers..

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

Joined: 08 Apr 2009
Posts: 8

PostPosted: Fri Sep 18, 2009 11:53 pm    Post subject: [C++] Pointers.. Reply with quote

I've serached for this question too and found a topic with an example source code but attempting to use it gives me errors unfortuantly =\


I have a pointer that is 0x01dc4c60 and offset of 0x051C. How do I add those together? I'm guessing find what 0x01dc4c60 is pointing too and then add 0x051C to it, but i'm kinda failing on this. any advice would be appreciated =)
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Sep 19, 2009 12:17 am    Post subject: Reply with quote

Reading the basics helps.

Int* is a pointer, so read your pointer there: int* x = 0xDEADBABE; Then, read the value from there and add the offset to it: int* y = static_cast<int*>( (*x)+0xBEEF ); And then just read the value from y: int z = *y;

Sure you can write all those on one line, but I'm trying to teach you here how to actually read the pointer, not just copy paste.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Sep 19, 2009 1:11 am    Post subject: Re: [C++] Pointers.. Reply with quote

Ganoes Paran wrote:
I've serached for this question too and found a topic with an example source code but attempting to use it gives me errors unfortuantly =\


I have a pointer that is 0x01dc4c60 and offset of 0x051C. How do I add those together? I'm guessing find what 0x01dc4c60 is pointing too and then add 0x051C to it, but i'm kinda failing on this. any advice would be appreciated =)


Yes, read 0x01DC4C60 with ReadProcessMemory then just add the offset to what you get back or if you have access to its memory, you can just do something like:

Code:
DWORD* ptr1 = 0x01DC4C60;
DWORD val = *ptr1 + 0x051C;


val is the memory location, etc etc.
Back to top
View user's profile Send private message
NooBpluSS
Cheater
Reputation: 0

Joined: 24 Jun 2007
Posts: 37

PostPosted: Sat Sep 19, 2009 2:13 pm    Post subject: Reply with quote

Simple...

Read value of 0x01dc4c60 (ex: readprocessmemory for read), add 0x051C (offset) and get ur pointer hack.

(:

_________________

Newbie cheater ;]
Back to top
View user's profile Send private message
Ganoes Paran
How do I cheat?
Reputation: 0

Joined: 08 Apr 2009
Posts: 8

PostPosted: Sat Sep 19, 2009 8:23 pm    Post subject: Reply with quote

well ReadProcessMemory does help me get the address of pointer but I hav eto add offset to it (so no problem..)

however the pointer address is put inside the LPVOID value and I can not add anyhting to it since it's basicly a "void" value of sorts =\

can anyone help me on this? thanks =)
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Sep 19, 2009 10:35 pm    Post subject: Reply with quote

show whatever code you have.

though i imagine this is just going to be a case of "just type cast it"
Back to top
View user's profile Send private message
igoticecream
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Apr 2006
Posts: 1807
Location: 0x00400000

PostPosted: Sun Sep 20, 2009 11:45 pm    Post subject: Reply with quote

Ganoes Paran wrote:
well ReadProcessMemory does help me get the address of pointer but I hav eto add offset to it (so no problem..)

however the pointer address is put inside the LPVOID value and I can not add anyhting to it since it's basicly a "void" value of sorts =\

can anyone help me on this? thanks =)


Just a simple question, are you in the context of the application?

If so you simply do:

(*(DWORD*)BaseAddress)+Offset //Get address's pointer or...
*(DWORD*) (*(DWORD*)BaseAddress)+Offset // to get value of the pointer

If you are not on the context then use ReadProcessMemory:

ReadProcessMemory(hProcess,(LPCVOID)(*(DWORD*)BaseAddress)+Offset,aBuffer,vSize,NULL);

LPVOID aBuffer = malloc(vSize+1);
hProcess can be found by OpenProcess

then if you need to read the Buffer as an unsigned long then cast it:

(unsigned long)aBuffer

Hope this helps you
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Sep 21, 2009 7:58 am    Post subject: Reply with quote

igoticecream wrote:
If you are not on the context then use ReadProcessMemory:

ReadProcessMemory(hProcess,(LPCVOID)(*(DWORD*)BaseAddress)+Offset,aBuffer,vSize,NULL);
Does that really work? I doubt it.. It'd read the value at your own program's context (the BaseAddress) and then add the offset and then read the value from the other context. So, it'd be something along these lines, too lazy to check the typecasts, but you get the idea where igoticecream got it wrong:
Code:
void *ptr = NULL;

ReadProcessMemory(hProcess, (LPCVOID)BaseAddress, &ptr, sizeof(void*), NULL);
ReadProcessMemory(hProcess, (LPCVOID)ptr+offset, buf, bufSize, NULL);
Back to top
View user's profile Send private message
igoticecream
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Apr 2006
Posts: 1807
Location: 0x00400000

PostPosted: Mon Sep 21, 2009 10:15 pm    Post subject: Reply with quote

Yea you need first the Base of the pointer, i'm sorry, you are right
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