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 


How to get String from DWORD (Pointer+Offset) [C++]

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

Joined: 09 Jan 2019
Posts: 3

PostPosted: Wed Jan 09, 2019 1:30 pm    Post subject: How to get String from DWORD (Pointer+Offset) [C++] Reply with quote

Good day,
I'm trying to get a String from a Pointer as pointed out in this video:
https: //ww w.youtube. com/watch?v=oC2-yjTli7g

But I have problems in getting the pointer and offset correctly:

http s://i.imgur. com/hqCB2Hx.png

Code:
   DWORD Pointer2 = 0x1D8530;
   DWORD Offset3 = 0x3C;
   char* Text = (char*)(*(DWORD*)Pointer2 + Offset3); //1 Offset
   large_img = std::string(Text);


Can anyone help me with this?

Regards



hqCB2Hx.png
 Description:
 Filesize:  36.62 KB
 Viewed:  3898 Time(s)

hqCB2Hx.png


Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Wed Jan 09, 2019 3:45 pm    Post subject: Reply with quote

MultiTasking wrote:
...
https://i.imgur.com/hqCB2Hx.png
https://www.youtube.com/watch?v=oC2-yjTli7g


010D8530 is not the static address, the static address is "nro.exe"+002588D8.

where nro.exe is equal to image base address, and 002588D8 is the offset from image base to some address that holds 010D8530.

also you have a typo there:
Code:
DWORD Pointer2 = 0x1D8530 // it should be 010D8530


assuming image base address is equal to 00400000, then add 002588D8 to it and it should be 006588D8.

so 006588D8 holds the address 010D8530, and 010D8530+3C equal to 010D856C.

010D856C holds the string 1@infi, so you have to adjust things in order to read string properly.

also keep in-mind, if the image base is not fixed (i.e. relocatable image base) then you have to find another way to get your static address.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
MultiTasking
How do I cheat?
Reputation: 0

Joined: 09 Jan 2019
Posts: 3

PostPosted: Wed Jan 09, 2019 4:37 pm    Post subject: Reply with quote

Quote:
also you have a typo there:


If I put:

Code:
010D8530
instead of
Code:
0x1D8530
the compiler (MSVS2017) throw me the follow error:
Code:
invalid literal suffix 'D8530'; literal operator or literal operator template 'operator ""D8530' not found


I'm not really skillful programming but I based me in other Address that I get:

Code:
AString = "Value " + std::to_string(*reinterpret_cast<int*>(0x010D93D8));


Address: 010D93D8=4012

And indeed "AString" is equal to "Value: 4012"

Can you explain me this?
Why 0x010D93D8 is equal to 010D93D8?

And thank you for your reply!
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Wed Jan 09, 2019 5:01 pm    Post subject: Reply with quote

MultiTasking wrote:
If I put:

Code:
010D8530
instead of
Code:
0x1D8530
the compiler (MSVS2017) throw me the follow error:
Code:
invalid literal suffix 'D8530'; literal operator or literal operator template 'operator ""D8530' not found

i did not say to remove the 0x? prefix, 1D8 is not the same as 10D8.

and im not sure what you are doing here, or where you got 010D93D8 from.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
MultiTasking
How do I cheat?
Reputation: 0

Joined: 09 Jan 2019
Posts: 3

PostPosted: Wed Jan 09, 2019 6:00 pm    Post subject: Reply with quote

Quote:
i did not say to remove the 0x? prefix, 1D8 is not the same as 10D8.

Oh my bad!

Quote:
and im not sure what you are doing here, or where you got 010D93D8 from.


With 010D93D8 I wanted read the int value and pass it to string (as you can see here):

Code:
std::string AString = "Value " + std::to_string(*reinterpret_cast<int*>(0x010D93D8));

It worked!

And now I want to do the same with 010D856C but in this case isn't a int value, is a text (or string)

I tried doing the following:

Code:
std::string AString = "String Name " + std::to_string(*reinterpret_cast<char*>(0x010D856C));

Expecting a result equal to "String Name 1@infi"
But the result is "String Name 109"
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