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 


Displaying the value from a memory address?

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

Joined: 13 Dec 2009
Posts: 6

PostPosted: Sat Mar 05, 2011 4:32 pm    Post subject: Displaying the value from a memory address? Reply with quote

Bit of a newbie question here, I'm (slowly) learning from several books, forgive my ignorance but I thought I'd ask here and see if what I'm trying to do is even possible.

Just wondering if it's possible to use cout to display the value held in a pointer/memory address?

For example, Torchlight holds the amount of gold you have in 0x12ED7E3C.

My first thought was to use:
Code:

#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
int *torchlightGold;
torchlightGold = reinterpret_cast<int*>(0x12ED7E3C);

cout << *torchlightGold << endl;
return 0;
}



But obviously that would cout the last part of the memory address and not the value it holds.

Can anyone show me how to cout this info please. My end goal is simply to display this information on the G15 keyboards' LCD display via their SDK.

Any help would be greatly appreciated, as said earlier, I r newb.... but eager to learn.

Thanks.
Back to top
View user's profile Send private message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Sat Mar 05, 2011 4:55 pm    Post subject: Reply with quote

There are several ReadPointer() functions out there, google for them.

Further do you need a .dll to read it like this.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sat Mar 05, 2011 6:37 pm    Post subject: Reply with quote

Casting pointers only works internally of the process using them. Meaning, if you want to read a pointer like that, you will have to create a DLL and inject it to gain access to the memory like that.

If you wish to stay external you will need to use ReadProcessMemory. There is a handful of other API that go along with it and there are plenty of examples on this site and across the net.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DY357LX
How do I cheat?
Reputation: 0

Joined: 13 Dec 2009
Posts: 6

PostPosted: Sat Mar 05, 2011 6:39 pm    Post subject: Reply with quote

Thanks for the info guys.

I'll continue messing with this in the morning and see what I can do.

(Google'ing for ReadPointer doesn't return much :-/ )
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Sat Mar 05, 2011 7:00 pm    Post subject: Reply with quote

DY357LX wrote:
Thanks for the info guys.

I'll continue messing with this in the morning and see what I can do.

(Google'ing for ReadPointer doesn't return much :-/ )


ReadPointer isn't an API. It will land up being a custom implementation of ReadProcessMemory. (Or direct pointers if it is injected etc.) Just read up on ReadProcessMemory to learn how to read memory of another application if you plan to stay external.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Sun Mar 06, 2011 3:54 am    Post subject: Reply with quote

Code:
__inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
{
   if (!IsBadReadPtr((void*)ulBase, sizeof(ULONG_PTR)))
   {
      if (!IsBadReadPtr((void*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)))
      {
         return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
      }
   }
   return 0;
}


It's not the best function out there, cause IsBadReadPt() is not something you should use. But it works, if the pointer exist, else it will crash you, make a __try in it.

Like Wiccaan said, it's for a .dll.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Mar 06, 2011 7:36 am    Post subject: Reply with quote

NoMercy wrote:
Code:
__inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
{
   if (!IsBadReadPtr((void*)ulBase, sizeof(ULONG_PTR)))
   {
      if (!IsBadReadPtr((void*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)))
      {
         return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
      }
   }
   return 0;
}


It's not the best function out there, cause IsBadReadPt() is not something you should use. But it works, if the pointer exist, else it will crash you, make a __try in it.

Like Wiccaan said, it's for a .dll.

Not true. The reason you shouldn't use it and the explanation behind why I highlighted what you said is here:
http://blogs.msdn.com/b/oldnewthing/archive/2006/09/27/773741.aspx
Back to top
View user's profile Send private message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Sun Mar 06, 2011 9:06 am    Post subject: Reply with quote

Slugsnack wrote:
NoMercy wrote:
Code:
__inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
{
   if (!IsBadReadPtr((void*)ulBase, sizeof(ULONG_PTR)))
   {
      if (!IsBadReadPtr((void*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)))
      {
         return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
      }
   }
   return 0;
}


It's not the best function out there, cause IsBadReadPt() is not something you should use. But it works, if the pointer exist, else it will crash you, make a __try in it.

Like Wiccaan said, it's for a .dll.

Not true. The reason you shouldn't use it and the explanation behind why I highlighted what you said is here:
http://blogs.msdn.com/b/oldnewthing/archive/2006/09/27/773741.aspx


The highlited sentences, was not ment to be poiting at IsBadReadPt, but at the entire funcition.
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