Python ReadProcessMemory int太长,无法转换

2024-05-20 16:25:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从进程的内存地址(在本例中为OBS64)中获取一个值。 我有这段代码,带有OBS的进程ID和我想要的值的内存地址。 作弊引擎显示该值为4字节

from ctypes import *
import ctypes

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

PROCESS_ALL_ACCESS = 0x1F0FFF

pid = 15352
address = 0x1AF91A490C4  # From Cheat Engine, it's a 4 Bytes int

buffer = c_uint()
val = c_int()

processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)

if ReadProcessMemory(processHandle, address, buffer, 32, 0):  # Error here
    memmove(ctypes.byref(val), buffer, ctypes.sizeof(val))

    print("Success: " + str(val.value))
else:
    print("Failed.")

CloseHandle(processHandle)

我得到一个错误: ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert 但我不知道为什么。我想这是因为缓冲区的长度,但我尝试了很多次并不断得到错误


Tags: import进程buffervalallctypesprocessint