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 


Reading a Pointer Value? [C++]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 6:37 pm    Post subject: Reading a Pointer Value? [C++] Reply with quote

I want to be able to read a pointer value.
So in asm it would be like

DWORD dReturn;
_asm {
mov esi,[PointerAddy]
mov esi,[esi]
mov edx,[PointerOffset]
mov ebx,[esi+edx]
mov [dReturn],ebx
}

but im sure thats wrong, cuz the game crash's...

i also wanna try using ReadProcessMemory for it

ReadProcessMemory( hMaple, (LPVOID)&PointerAddy, (LPVOID)&dReturn, sizeof(PointerAddy), NULL );
DWORD AddOffset = dReturn + PointerOffset;
ReadProcessMemory( hMaple, (LPVOID)&AddOffset, (LPVOID)&Value, sizeof(AddOffset), NULL );

but this definintly doesnt give me the value.. or maybe i just got the wrong pointers Razz

help is appreciated.
-Lurc

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Feb 28, 2008 6:49 pm    Post subject: Reply with quote

From what I can see, you are using the addresses incorrectly, you are trying to pass the address of the storage variable and not its value. Instead, write:

Code:
ReadProcessMemory( hMaple, (BYTE*)PointerAddy, &dReturn, sizeof(DWORD), NULL );
DWORD AddOffset = dReturn + PointerOffset;
ReadProcessMemory( hMaple, (BYTE*)AddOffset, &Value, sizeof(AddOffset), NULL );


I also suggest not dumping the end result into something you are using already. Instead make a new variable to hold that value.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 6:51 pm    Post subject: Re: Reading a Pointer Value? [C++] Reply with quote

Code:
#define ReadPtrVal(x,y,z) *((z *) (x + y))

int val = ReadPtrVal(pointer, offset, int);


Or do you mean multi-level pointers?

Note: Injected dll.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Feb 28, 2008 6:54 pm    Post subject: Re: Reading a Pointer Value? [C++] Reply with quote

Flyte wrote:
Code:
#define ReadPtrVal(x,y,z) *((z *) (x + y))

int val = ReadPtrVal(pointer, offset, int);


Or do you mean multi-level pointers?

Note: Injected dll.


Based on what he asked, (using RPM) I figured it was from a stand alone trainer type thing.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 6:57 pm    Post subject: Reply with quote

Here's my code.
Trying to read the Channel Pointer

Code:
void ReadChannel()
{
   DWORD Address, Read, Value;
   TCHAR Writeto[MAX_PATH];
   HANDLE hMaple = GetCurrentProcess();

   if ( !hMaple ) { MessageBox( hWnd, L"Unable to get handle", szError, MB_OK | MB_ICONERROR ); return; }

   ReadProcessMemory( hMaple, (BYTE*)0x00850468, &Address, sizeof(DWORD), NULL );
   Read = Address + 0x20C4;
   ReadProcessMemory( hMaple, (BYTE*)Read, &Value, sizeof(Read), NULL );

   _itot_s( Value, Writeto, 15, 10 );
   SetDlgItemText( hWnd, ID_STATIC1, Writeto );
}


I get a value of 13009xxxx <-- something like that.
So im guessing my pointers wrong, or im going about doing this wrong...


Edit: wo, missed 2 posts... lmao
its an injected dll Razz
thats why i tried inline asm first... but since using RPM works fine in ms i just decided to try it too

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 7:04 pm    Post subject: Reply with quote

Ok, ReadProcessMemory isn't needed in an injected dll, you can do manual reads.

(I can notice it is injected because of: HANDLE hMaple = GetCurrentProcess(); )
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 7:09 pm    Post subject: Reply with quote

Alright i tried your method

Code:
void ReadChannel()
{
   DWORD Value = ReadPtrVal( 0x00850468, 0x20C4, DWORD );
   
   TCHAR Writeto[MAX_PATH];

   _itot_s( Value, Writeto, 15, 10 );
   SetDlgItemText( hWnd, ID_STATIC1, Writeto );
}


i got a number like 9779784

so its my pointer.... thats definintly wrong... anyone got the correct channel pointer?

the one i got: Pointer: 0x00850468, Offset: 0x20C4

using these

Channel Pointer - A1 ? ? ? ? 8B 80 ? ? ? ? 89 85 ? ? ? ? 33 C0
Channel Offset - 8B 80 ? ? ? ? 89 85 ? ? ? ? 33 C0 89 45 ?

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 7:14 pm    Post subject: Reply with quote

Is this a multi-level pointer? I don't play maple, so I don't know much about this "channel pointer".
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 7:17 pm    Post subject: Reply with quote

lmao, i dont play it either, but i dont think its a mutlilevel pointer.

heres a pic of the pointer and offset?



memview.png
 Description:
 Filesize:  55.02 KB
 Viewed:  7542 Time(s)

memview.png



_________________


Last edited by lurc on Fri Feb 29, 2008 9:36 am; edited 1 time in total
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 7:24 pm    Post subject: Reply with quote

Code:
value  = *((int *) (*((unsigned long *) 0x00850468) + 0x204C))


That's assuming the channel is actually stored in int form.

Edit: Small error with the offset value.


Last edited by Flyte on Thu Feb 28, 2008 8:18 pm; edited 2 times in total
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 7:29 pm    Post subject: Reply with quote

Now im getting randomly generated numbers..
every couple seconds it changes value.

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 8:20 pm    Post subject: Reply with quote

lurc wrote:
Now im getting randomly generated numbers..
every couple seconds it changes value.


I accidentally used a messed up offset value, fixed now.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Feb 28, 2008 8:29 pm    Post subject: Reply with quote

Woot! it works! thanks Flyte Smile
_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Feb 28, 2008 8:40 pm    Post subject: Reply with quote

I'm thinking the asm in the first post was wrong, but then again, your pointer might also be wrong.

Code:

_asm {
mov esi,[PointerAddy]
mov esi,[esi]
mov edx,[PointerOffset]
mov ebx,[esi+edx]
mov [dReturn],ebx
}


Shouldn't it be

Code:

mov esi,[Pointer]
mov edx,[Offset]
lea ebx, [esi+edx]
mov [dReturn],ebx


I might be wrong about this, but I also might not.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Feb 28, 2008 9:15 pm    Post subject: Reply with quote

samuri25404 wrote:
I'm thinking the asm in the first post was wrong, but then again, your pointer might also be wrong.

Code:

_asm {
mov esi,[PointerAddy]
mov esi,[esi]
mov edx,[PointerOffset]
mov ebx,[esi+edx]
mov [dReturn],ebx
}


Shouldn't it be

Code:

mov esi,[Pointer]
mov edx,[Offset]
lea ebx, [esi+edx]
mov [dReturn],ebx


I might be wrong about this, but I also might not.


He said he got it to work, so the pointer was fine, it was just the way he was implementing it.

Also:
Code:
mov     eax, dword [0x00850468]
mov     ax, word [eax+0x204C]
mov     word [channel], ax

channel dw ?
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 1, 2  Next
Page 1 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