How can i read a string from memory?

How can i read a string from memory?



I'm working on a c++ windows application project. A portion of this project requires me to read the value of a memory address used in a separate process and use this value as a "trigger" within a function. I know the value is a string, and constantly changes, but i have no idea how to read or use it. Any ideas? Any help would be wonderful.





What do you mean by "string"? Is it a std::string object? Or just plain char array?
– Galik
Aug 26 at 1:41


std::string


char





Forgive me. When looking at the address with a memory scanner it tells me that it's storing "string[9]".
– Jake
Aug 26 at 1:48





1 Answer
1



Are you allowed to use standard IPC? If not, you're going to run into issues. Processes are not supposed to share memory space like that. In fact, if you compile with standard settings and try to read outside your application's memory space, you'll get a fatal seg-fault.



What you're going to want to do is essentially design a very rudimentary debugger, which is no small task. I would recommend starting by looking at existing debugger source code (e.g., x64dbg, or cheat engine: https://github.com/cheat-engine/cheat-engine).



What is the purpose of this project?





I'm competing to make a game bot. I thought that if i could use the memory to feed the bot information I could save time. But it's proving to be very difficult. I am able to read ints and double using ReadProccessMemory() but it does't seem to work with strings. I must say I am quite new at this.
– Jake
Aug 26 at 1:55





Well if you can read ints and doubles, you can read strings too. Just read the strings in 4 or 8 byte chunks (ints or doubles) into a buffer and then read it as a string as you normally would.
– Scott Mudge
Aug 26 at 2:08





I have tried that , and tried to cout the results but nothing is written to the console. Now I'm not very knowledgeable with this sort of thing but I thought it was because the value was changing or something so i ran it on a loop and still nothing.
– Jake
Aug 26 at 2:10






Have you tried inspecting the data in a debugger? You're likely just reading nulls if nothing shows up. How are you finding the memory address of the string you want to read to begin with? If it's not a compile-time constant, you would have to scan the entire memory space of the process you're inspecting for the string you're interested in. Especially if the process is using ASLR. If it is a constant, make sure the address you're reading isn't the pointer to the string you're actually interested in.
– Scott Mudge
Aug 26 at 2:21





Also bear in mind if you are getting the address using a memory scanner (e.g., cheat engine or artmoney), that address is going to change every time the application launches.
– Scott Mudge
Aug 26 at 2:23






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?