Python 3.x ReadProcessMemory无效句柄
我正在尝试使用Python从另一个进程读取一个值 我遇到过,虽然它似乎不起作用 我的代码:Python 3.x ReadProcessMemory无效句柄,python-3.x,winapi,Python 3.x,Winapi,我正在尝试使用Python从另一个进程读取一个值 我遇到过,虽然它似乎不起作用 我的代码: from ctypes import * from ctypes.wintypes import * OpenProcess = windll.kernel32.OpenProcess ReadProcessMemory = windll.kernel32.ReadProcessMemory CloseHandle = windll.kernel32.CloseHandle PROCESS_ALL_ACC
from ctypes import *
from ctypes.wintypes import *
OpenProcess = windll.kernel32.OpenProcess
ReadProcessMemory = windll.kernel32.ReadProcessMemory
CloseHandle = windll.kernel32.CloseHandle
PROCESS_ALL_ACCESS = 0x1F0FFF
pid = 4580
address = 0x04782FF8
buffer = c_uint()
bufferSize = sizeof(buffer)
bytesRead = c_ulong(0)
processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
if ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead)):
print("Success:", buffer)
else:
print("Failed.")
CloseHandle(processHandle)
GetLastError()
似乎返回6,这意味着句柄无效
但是,OpenProcess()
返回一个非零值,GetLastError()
没有显示任何关于它的信息
我尝试编辑传入的第一个参数
OpenProcess()
(我创建了0x0010),但仍然没有结果。进程ID是dec,而不是hex,这破坏了一些东西
我还必须将c_uint()替换为缓冲区的create_string_buffer(4)
现在似乎很好用