【问题标题】:How do i read memory using pymem?如何使用 pymem 读取内存?
【发布时间】:2022-07-23 00:20:44
【问题描述】:

此代码从程序中写入和读取内存。该程序内置于 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]))

【问题讨论】:

    标签: python


    【解决方案1】:

    在您的函数中,read_longlong 正在读取整数。要从指针跳转到指针,您需要读取指针值。而不是阅读 int,您应该使用“ptypes”参见:https://pymem.readthedocs.io/en/latest/api.html#module-pymem.ptypes

    你可以像这样使用 ptypes;

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 2020-04-30
      • 2020-05-24
      相关资源
      最近更新 更多