简体   繁体   中英

How do I read DOUBLE from a memory of a process

So I am making an AI BOT for game Bloons TD6, but for it to work I need to get money value so he knows when he can buy something. For that I decided to find pointer to in-game money but I don't know how to read memory with python, I managed to do it in cpp but for bot to work I need it in python. I already managed to get PID, now I just need to read an address from memory.

Also important to mention is that value that I want to read is double.

PROCESS_ALL_ACCESS = 0x1F0FFF
HWND = win32ui.FindWindow(None,"BloonsTD6").GetSafeHwnd()
PID = win32process.GetWindowThreadProcessId(HWND)[1]

You could try Pymem ; here you can find a quickstart showing how you can read/write integer values from/to process memory: https://pymem.readthedocs.io/en/latest/quickstart.html .

You'll find this simple example (there's actually a typo in it, it's pm.process_id , not process_id ):

from pymem import Pymem

pm = Pymem('notepad.exe')
print('Process id: %s' % pm.process_id)
address = pm.allocate(10)
print('Allocated address: %s' % address)
pm.write_int(address, 1337)
value = pm.read_int(address)
print('Allocated value: %s' % value)
pm.free(address)

In the same way it is possible to read/write a double by using the read_double() and write_double() functions. You can find some docs in here: https://pymem.readthedocs.io/en/documentation/api.html

Also check this out: reading data from process' memory with Python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM