Python Pymem MemoryReadError GetLastError: 299

Python Pymem MemoryReadError GetLastError: 299

从 2 天开始,我尝试阅读 pymem 的文档并在论坛上搜索错误,但我看到的所有解决方案都失败了

我不能只读取内存地址中的int,我不知道这是代码问题还是我的电脑

from pymem import *
from pymem.process import module_from_name


pm = pymem.Pymem("***-Win64.exe")

gameModule = module_from_name(pm.process_handle, "***-Win64.exe").lpBaseOfDll

def GetPtrAddr(base, offsets):
    addr = pm.read_int(base) # addr = 9460301, base = 140696812060672
    for i in offsets:
        if i != offsets[-1]:
            addr = pm.read_int(addr + i) # <- here is the error line
    return addr + offsets[-1]

pm.read_int(GetPtrAddr(gameModule + 0x04D934B0, [0x50, 0x30, 0x98, 0xf0, 0x380]))

错误

pymem.exception.MemoryReadError: Could not read memory at: 9460349, length: 4 - GetLastError: 299

我也试过这个但是我有错误

ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert

但我尝试获取的唯一值是从 0 到 12

我在 for 循环中添加了一个 try catch,这是错误

Could not read memory at: 9460349, length: 4 - GetLastError: 299
Could not read memory at: 9460973, length: 4 - GetLastError: 299
Could not read memory at: 9460589, length: 4 - GetLastError: 299
Could not read memory at: 9460301, length: 4 - GetLastError: 299

我想知道为什么您将 pm.readint() 中的 return 值添加到您的偏移量中。 base 似乎是您可以访问的有效地址,而 addr + some offset 不是。

我从 documentation 中读到 read_int 从指定进程的内存区域读取 4 个字节。 return 值 addr 是您要使用的地址吗?

仅供参考,我发现错误代码是由 kernel32 抛出的,它表示 ERROR_PARTIAL_COPY。

感谢 @Joe_Bao 的帮助,我最终发现了我的错误

问题是因为我的应用程序是 64 位的,我试图读取一个 int 但这还不够,所以这里有完整的代码

from pymem import *
from pymem.process import *

offsets = [0x50,0x30,0x98,0xF0,0x380]

pm = Pymem('***-Win64.exe')

gameModule = module_from_name(pm.process_handle, '***-Win64.exe').lpBaseOfDll


def GetPointer(base, offsets):
    addr = pm.read_longlong(base+0x04D934B0) # <-- here was the probleme solved
    print(hex(addr))
    for offset in offsets:
        if offset != offsets[-1]:
            try:
                addr = pm.read_longlong(addr + offset)
                print(addr)
            except Exception as e:
                print(e)
    return addr + offsets[-1]

GetPointer(gameModule, offsets)