小编Ave*_*hau的帖子

Python - 如何获取内存地址处的值?

我试图让 Python 从诸如 0x101BFFDC 之类的地址获取值/数据,这是我通过使用游戏作弊引擎找到的。我做了很多研究,并相信我需要使用ReadProcessMemory. 但是,我尝试了几个示例都没有成功。

例如,我找到了以下代码:

from ctypes import *
from ctypes.wintypes import *
import struct

OpenProcess = windll.kernel32.OpenProcess
ReadProcessMemory = windll.kernel32.ReadProcessMemory
CloseHandle = windll.kernel32.CloseHandle

PROCESS_ALL_ACCESS = 0x1F0FFF

pid = 10684 # pid of the game
address = 0x101BFFDC # I put the address here

buffer = c_char_p(b"The data goes here")
val = c_int()
bufferSize = len(buffer.value)
bytesRead = c_ulong(0)

processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
if ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead)):
    memmove(ctypes.byref(val), buffer, ctypes.sizeof(val))
    print("Success:" + str(val.value)) …
Run Code Online (Sandbox Code Playgroud)

python memory windows ctypes cheat-engine

2
推荐指数
1
解决办法
6565
查看次数

标签 统计

cheat-engine ×1

ctypes ×1

memory ×1

python ×1

windows ×1