这段代码从程序中写入和读取内存。该程序是64位构建的。我使用mem.write_float没有问题,但是当使用mem.read时,会发生错误
pymem.exception.MemoryReadError: Could not read memory at: 16, length: 8 - GetLastError: 29
有人有主意吗?
from pymem import *
from pymem.process import *
mem = Pymem("###.exe")
game_module = module_from_name(mem.process_handle, "###.exe").lpBaseOfDll
def getPtrAddr(address, offsets):
addr = mem.read_longlong(address)
for offset in offsets:
if offset != offsets[-1]:
addr = mem.read_longlong(addr + offset)
addr = addr + offsets[-1]
return addr
while True:
mem.write_float(getPtrAddr(game_module + 0x06D26780, [0x28, 0x20, 0X08, 0x08, 0x170, 0x10, 0xE8]), 1000.233)
mem.read_longlong(getPtrAddr(game_module + 0x06D26780, [0x28, 0x20, 0X08, 0x08, 0x170,0x10, 0xE8]))
发布于 2022-07-22 16:20:44
在您的函数中,read_longlong正在读取整数。要从指针跳转到指针,需要读取指针值。您可以使用“ptype”(请参阅:https://pymem.readthedocs.io/en/latest/api.html#module-pymem.ptypes )来代替阅读int。
你可以像这样使用ptype;
from pymem import Pymem
from pymem.ptypes import RemotePointer
pm = Pymem("###.exe")
def getPointerAddress(base, offsets):
remote_pointer = RemotePointer(pm.process_handle, base)
for offset in offsets:
if offset != offsets[-1]:
remote_pointer = RemotePointer(pm.process_handle, remote_pointer.value + offset)
else:
return remote_pointer.value + offset
pm.write_int(getPointerAddress(pm.base_address + 0x123ABC, offsets=[offset1, offset2, offset3]), 123456)
在你的代码中;
game_module = module_from_name(mem.process_handle, "###.exe").lpBaseOfDll
和
pm.base_address
基本上是一样的
https://stackoverflow.com/questions/72411354
复制相似问题