Posted: Sun Dec 02, 2018 4:40 am Post subject: Convert hex string from memory to ASCII and rewrite
Hey guys,
I've been beating my pathetic ape brain against the wall because I can't work this one out so I thought I'd turn to the pros. What I'd like to do is simply read a hex value from memory, and rewrite it to memory so that I can display it in game via a script I've made. For example, my value at 07821000 is 1B8AEAB8, I'd like this to appear next to a unit's name in-game, however I'm not sure how to do so.
I need to somehow convert e.g. 1B8AEAB8 into 0x31 0x42 0x38 0x41 0x45 0x41 0x42 0x38 so that I can rewrite this to memory somewhere so that it appears in ASCII as it's hex representation (so that the game can successfully read this in as a string). Alas, I am not familiar enough with assembly or LUA to really figure this one out. I would love and appreciate any assistance!
Pretty sure that's the string "1B8AEAB8" in ascii. In which case you can probably use something like this in lua "unitname .. tostring(unit_address)" and writeString... somewhere with enough space for the string that will then be used by the game, that's the hard part.
in pure asm you'd probably want to call C's sprintf, yes, knowing C can help in asm hacking too if nothing else because you can compile C code and look at the assembly code the compiler turned it into instead of having to actually be good at assembly lol. _________________
Thanks for the replies guys. Parkour, I got those bytes as they are the ASCII code representation of each letter of hex in that value. Love your replies as always, just quickly tested your suggestion there and it's worked straight away for me. Writing exactly what I needed to memory. Now that the hex representation is on the ASCII side there the game will be able to read it and just print straight to the screen (after I reverse the order first)
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