简体   繁体   English

如何从进程的 memory 中读取 DOUBLE

[英]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.所以我正在为游戏 Bloons TD6 制作一个 AI BOT,但要让它工作,我需要获得金钱价值,以便他知道什么时候可以买东西。 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.为此,我决定找到指向游戏内资金的指针,但我不知道如何使用 python 读取 memory,我设法在 cpp 中做到了,但为了让机器人工作,我需要在 Z23EEEB4347BDD26BFCZ6B7EE9A3B755DD. I already managed to get PID, now I just need to read an address from memory.我已经设法获得了 PID,现在我只需要从 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 ;你可以试试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 . 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 ):你会发现这个简单的例子(实际上有一个错字,它是pm.process_id ,而不是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.以同样的方式,可以使用read_double()write_double()函数来读/写一个 double。 You can find some docs in here: https://pymem.readthedocs.io/en/documentation/api.html你可以在这里找到一些文档: https://pymem.readthedocs.io/en/documentation/api.html

Also check this out: reading data from process' memory with Python另请查看: 使用 Python 从进程的 memory 读取数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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