1
我想讓Python從諸如0x101BFFDC這樣的地址獲取值/數據,這是我通過使用遊戲的作弊引擎找到的。我做了很多研究,並且認爲我需要使用ReadProcessMemory
。但是,我嘗試了幾個例子,但沒有成功。Python - 如何獲取內存地址的值?
例如,我發現下面的代碼:
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))
else:
print("Failed.")
CloseHandle(processHandle)
我希望它給我值56,這是我從作弊引擎獲得。但是,它只是打印「失敗」。每次。
如何獲得正確的價值?
嘗試這樣做:https://stackoverflow.com/questi ons/8250625/access-memory-address-in-python? – sharath
@sharath不適用於從另一個進程讀取內存,只能用於Python進程。 –