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 


ReadProcessMemory and strings

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Tue Aug 02, 2016 1:01 pm    Post subject: ReadProcessMemory and strings Reply with quote

A while ago I found this issue with string pointers, the one where short strings change their location if they expand to more than 15 characters; I solved it by checking if the string is valid and if not then adding the 0 pointer to the pointer path, but unfortunately I can't have my application run flawlessly for long with this simple solution. A clear example about the pointers:
string pointer: 0, 55, 8C, 200
If the string becomes longer than 15 characters:
string pointer: 0, 55, 8C, 200, 0
Now the issue is that sometimes if the string I'm looking for becomes longer then the 0, 55, 8C, 200 will still be "valid" though it becomes a random bunch of characters, for example "item name 99" turns into "dghs" and the code reads "dghs" instead of going one pointer deeper.

Is there any solution for this that will work in the long run?
Back to top
View user's profile Send private message
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Wed Aug 03, 2016 8:12 am    Post subject: Reply with quote

Could really use an anwser, had the application stuck for two hours after it ran fine for 4, it tried to interact with something that didn't exist because the name pointer wasn't read correctly.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4708

PostPosted: Wed Aug 03, 2016 9:32 am    Post subject: Reply with quote

You could get it more consistent if you always try to dereference it, but it won't be perfect.

Look around that memory region and see if you can find something that determines string length (could be a boolean indicating if it's larger than 15 characters). If that fails, look at how the game is accessing the address of that string. The game must have some way of determining if it's larger than 15 characters; if you find it, you can copy it.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Sun Oct 23, 2016 8:07 am    Post subject: Reply with quote

Still nothing, I tried looking around the string address but there's nothing that says if it's longer than 15 or not. "show what accesses this address" shows an instruction "move if greater or equal" and that's all I got. Still can't read the strings perfectly, the address which is supposed to be the string sometimes turns into a pointer which points to the string.
Back to top
View user's profile Send private message
H4x0rBattie
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 58

PostPosted: Wed Nov 23, 2016 3:28 am    Post subject: Reply with quote

Astaroth4256 wrote:
Still nothing, I tried looking around the string address but there's nothing that says if it's longer than 15 or not. "show what accesses this address" shows an instruction "move if greater or equal" and that's all I got. Still can't read the strings perfectly, the address which is supposed to be the string sometimes turns into a pointer which points to the string.


It depends are you reading a raw string from an arbitrary location or from a location that is known to have a valid string.

Methods are totally different between the two. I know because I wrote a string scanner Wink

_________________
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: Wed Nov 23, 2016 12:54 pm    Post subject: Re: ReadProcessMemory and strings Reply with quote

Astaroth4256 wrote:
A while ago I found this issue with string pointers, the one where short strings change their location if they expand to more than 15 characters; I solved it by checking if the string is valid and if not then adding the 0 pointer to the pointer path, but unfortunately I can't have my application run flawlessly for long with this simple solution. A clear example about the pointers:
string pointer: 0, 55, 8C, 200
If the string becomes longer than 15 characters:
string pointer: 0, 55, 8C, 200, 0
Now the issue is that sometimes if the string I'm looking for becomes longer then the 0, 55, 8C, 200 will still be "valid" though it becomes a random bunch of characters, for example "item name 99" turns into "dghs" and the code reads "dghs" instead of going one pointer deeper.

Is there any solution for this that will work in the long run?


Judging by how this sounds, this sounds like you are dealing with an 'std::string' object or something implemented in a similar manner.

std::string has two forms of string containment based on the size of the string. If the size is under 16 chars, it will be stored in a static buffer. Otherwise when it is larger, memory will be allocated and used instead. Other languages implement things similar but most notiable for this is std::string within C++.

If it is a std::string object, you should be able to find two more variables near the buffer that hold the allocated size / length of the string to determine if the pointer is being used or if the static buffer is being used.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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