Closed MillhioreBT closed 3 years ago
Good work, thank you for sharing
thanks. But Unfortunately, this project cannot read float and UTF8 strings, and the author does not update anymore, I have to give up using...
thanks. But Unfortunately, this project cannot read float and UTF8 strings, and the author does not update anymore, I have to give up using...
Hi, in theory this should read UTF-8
, ASCII
perfectly, anyway you are free to improve the function for your specific purpose
If you want to show an example of what you want to do we can help.
Treat floats as ints and do the conversion in python. Likewise, treat UTF-8 as a list of bytes and do the conversion in python.
thanks. But Unfortunately, this project cannot read float and UTF8 strings, and the author does not update anymore, I have to give up using...
Hi, in theory this should read
UTF-8
,ASCII
perfectly, anyway you are free to improve the function for your specific purpose If you want to show an example of what you want to do we can help.
Thanks for the help of MillhioreBT and Bluecoreg. I try to readmemory a traditional Chinese game from Taiwan. I want to read float and UTF16 Chinese.
from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('gvo.exe')
process.open()
pos_x = process.get_pointer(0x0119E16C)
pos_x = process.read(pos_x)
print(float(pos_x))
server_name = process.get_pointer(0x0119E024, offsets=[0x0])
print(hex(server_name))
server_name = process.read(server_name)
print(server_name)
process.close()
Console display:
-->1158875914.0
-->0x5d7af40
-->2538102397
And here is snapshot in CheatEngine Memory Viewer:
pos_x( 0x0119E16C ) I want to get float, server_name( [0x0119E024]+0=0x05D7AF40 ) I want to get UTF16 string. But ReadWriteMemory can only get integer values, and there is no parameter to choose which data type to get, so I can only convert it myself?
UTF16 Chinese might be a little tricky. I don't know how much support python has for it. You'll have to look around for some converters.
As for floats you can just treat it as if you are reading an int, Assuming the game is 32bit, both floats and ints will be 4 bytes long. (May be the case for 64bit, but not guaranteed) So for reading, use read int, and then use python to convert the int into a float.
Now if you are trying to write a float, that's a little more tricky. You'll need to convert your python float into an array of 4 bytes and use write string. A string is just an array of bytes, so since you need to write an array of bytes you can use write string in this case.
Actually, now that I'm checking the project I needed this for I realized I never ended up using this one. Didn't work for what I needed it for. You might want to use Pymem instead. https://github.com/srounet/Pymem/
It even has a read_float function.
Actually, now that I'm checking the project I needed this for I realized I never ended up using this one. Didn't work for what I needed it for. You might want to use Pymem instead. https://github.com/srounet/Pymem/
It even has a read_float function.
Yes, I just noticed the pymem project, it is more complete than this project. I think I will use pymem instead of ReadWriteMemory. Thank you again for your help
Just now, I successfully read UTF16 Traditional Chinese with Pymem
if data_type == "unicode":
temp = pm.read_bytes(address, 2)
result = ""
while temp != b'\x00\x00':
result = result + temp.decode('utf-16')
address += 2
temp = pm.read_bytes(address, 2)
print(result)
Thank you for contributing the two new methods for reading and writing strings.
@MillhioreBT What do you think of these two new methods for this great module, many probably need it for some purpose in which they need to write and read text from memory
it's a lifesaver for me cause I hate writing C lol, I can do a looot of new features for my external game utilities now much easier. Thanks!
What do you think of these two new methods for this great module, many probably need it for some purpose in which they need to write and read text from memory