Posted: Sun Sep 03, 2017 2:56 am Post subject: String replacing function
Hello, I wanted to change my name in a game using Cheat engine. I found the value, I could change it and everything is working but..
When I change the string value, the new one shouldn't be longer or shorter (length) than the old value.
When the new value is longer, it replaces only limited letters depending on the length.
Example: (Old value is 123456, new value is abcdefgh, but the new value turns out only abcdef, same length as the old one)
When the new value is shorter, it replaces with my new value + some last letters of old value to make length equal.
Example: (Old value is 123456789, new value is abcdef, but the new value turns out abcdef789, same length as the old one)
So how can I get rid of both of these issues? I want to make the text the one I wish.
Thanks.
Update: Okay, I figured out how to play with changing longer string to shorter by AOB, still need to know how to do the opposite though.
Joined: 21 Jan 2017 Posts: 105 Location: Heaven and Hell
Posted: Sun Sep 03, 2017 3:26 am Post subject:
If you use hex editing then you may know that the value length should be same.
The length of old value = the length of new value.
If you have value 1234 which length is 4 .changed value length should also be 4
Its all about hex editing _________________
"If you are good at something,never do it for free"-The Joker
I know you are looking at this post, Hitler
If it's just a basic C string, aka a pointer to memory where the characters are followed by a 0 byte (or 2 for a wide string) to mark the end, then you should be able to change the pointers that the game uses to point at the string to some allocated memory of whatever size you like instead of the original string.
If the string has memory allocated inside of a structure instead of a pointer then you'd have to find every place that the code could ever reference it and change the code to use it the way you want instead, eg. treating the first 4 bytes as a pointer to a string instead of the actual string... not usually practical.
Outside of that... I really haven't tried to mess with object-ified strings like C++ / C# have that "normally" would dynamically allocate memory as needed and have vtable pointers etc. so I can't really give any reliable info.
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