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 


Need help getting string value from a hexadecimal addressC++

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

Joined: 01 Nov 2013
Posts: 9

PostPosted: Fri Nov 01, 2013 6:05 pm    Post subject: Need help getting string value from a hexadecimal addressC++ Reply with quote

I am having difficulties getting the string value from an address. I did a text search in cheat engine for an address that contains string values of information I need to read in and modify for a program. However every time I read out the address I get the 4 Byte form of the value instead of text.
Is there way to convert the 4 Byte form to Text like cheat engine does.
Back to top
View user's profile Send private message
DELETED_USER
Newbie cheater
Reputation: 1

Joined: 02 Oct 2013
Posts: 24
Location: Venezuela

PostPosted: Fri Nov 01, 2013 6:16 pm    Post subject: Reply with quote

AFAIK; You need to read the number of characters that contains the string as bytes, then you must convert the result (byte by byte) in ASCII or Unicode.
Back to top
View user's profile Send private message Send e-mail
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25824
Location: The netherlands

PostPosted: Fri Nov 01, 2013 6:35 pm    Post subject: Reply with quote

Just read the bytes into a compatible string with equal or bigger size
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
voidaccess
How do I cheat?
Reputation: 0

Joined: 01 Nov 2013
Posts: 9

PostPosted: Sat Nov 02, 2013 1:49 am    Post subject: Reply with quote

Ty I figured it out now , brain just wasn't working today.

Answer for anyone else curious,

Code:
std::string* buffer[15];
ReadProcessMemory(fProcess.__HandleProcess, (LPCVOID)(address), &buffer, sizeof(buffer), NULL);
std::cout << (char*)&buffer << std::endl;
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 893

PostPosted: Sat Nov 02, 2013 3:25 pm    Post subject: Reply with quote

voidaccess wrote:
Ty I figured it out now , brain just wasn't working today.

Answer for anyone else curious,

Code:
std::string* buffer[15];
ReadProcessMemory(fProcess.__HandleProcess, (LPCVOID)(address), &buffer, sizeof(buffer), NULL);
std::cout << (char*)&buffer << std::endl;


No offense, but this is all kinds of wrong. Try replacing std::string with unsigned char.
Back to top
View user's profile Send private message
cinderstorm
How do I cheat?
Reputation: 0

Joined: 15 Jan 2014
Posts: 1

PostPosted: Wed Jan 15, 2014 1:57 am    Post subject: help Reply with quote

I'm encountering the same issue but I can't tell where I'm not scooping up the value. I'm looking at an address that has appended multiple dwords and displays it in Unicode.


AHK Code
Code:
tmp = 0x11E3F4
string .= memory.readString(tmp, length := 14, encoding := "utf-8")


Code:

readString(address, length := 0, encoding := "utf-8", aOffsets*)
    {
        size  := (encoding ="utf-16" || encoding = "cp1200") ? 2 : 1
        VarSetCapacity(buffer, length ? length * size : size, 0)
     
        if aOffsets.maxIndex()
            address := this.getAddressFromOffsets(address, aOffsets*)
     
        If !length ; read until null terminator is found or something goes wrong
        {
            Loop
            {
                success := DllCall("ReadProcessMemory", "UInt", this.hProcessCurrent, "UInt", address + (A_index - 1) * size, "str", buffer, "Uint", size, "Ptr", 0)
                if (ErrorLevel || !success || "" = char := StrGet(&buffer, 1, encoding))  ; null terminator = ""
                    break
                string .= char
            }
        }
        Else ; will read X length
        {
               
            DllCall("ReadProcessMemory", "UInt", this.hProcessCurrent, "UInt", address, "str", buffer, "Uint", length * size, "Ptr", 0) 
            string := StrGet(&buffer, length, encoding)
        }
        return string             
    }


I understand that this is not the AHK forums, but I'm trying to figure out how to extract this list of values (as strings) that I see at a given address. Because I'm fairly new to memory reading and writing, I have no clue where to even start.

Mostly what I can see from the memory address is a consistent appending of the text. For example:
Type
String

Value
Rabbit 123sDuck 80sFeet 12s

Value is currently set as a String[256] so it can read the what I'm guessing is an array of values created in assembly... but I can only guess at that because it seems logical and looking at the stack that there's the beginning of a dword, some letters 2 letters at a time (I'm guessing 4 bytes each) and a pointer at the end. The memory address that shows the values grows dynamically based on the number of objects that are "active".

Please help - I see that it might have something to do with the function I'm using but I'm kind of lost. I would prefer being able to reference the exact item rather than parse out the string but I haven't been able to figure out to do that. I appreciate any help and all help/guidance on this matter.

Thank you,

cinderstorm
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