本文介绍了ctype-python-long int时间太长,无法转换-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题:
代码:
from ctypes import *
from ctypes.wintypes import *
PID = 4016
address = 0x6C532407C
OpenProcess = windll.kernel32.OpenProcess
ReadProcessMemory = windll.kernel32.ReadProcessMemory
CloseHandle = windll.kernel32.CloseHandle
PROCESS_ALL_ACCESS = 0x1F0FFF
datadummy = b'.'*200
buffer = c_char_p(datadummy)
bufferSize = len(buffer.value)
bytesRead = c_ulong(0)
processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, int(PID))
ReadProcessMemory(processHandle,
address,
buffer,
bufferSize,
byref(bytesRead))
CloseHandle(processHandle)
我试图更改bytesRead = c_ulong(0)到其他一些ctype,但是没有成功。我在Windows 8.1系统64位上。经过数小时的搜索,我找不到任何解决方案或类似问题。有人知道这里出什么问题吗?
I tried to change the bytesRead = c_ulong(0) to some other ctypes, but no success. Im on a Windows 8.1 System 64bit. I couldnt find any solution or similiar problems after hours of searching. Does someone know whats wrong here?
推荐答案
经过长时间的失败和错误,我终于有了答案。
After a long time of fail and error I finally have an answer.
from ctypes import *
from ctypes.wintypes import *
import ctypes
OpenProcess = windll.kernel32.OpenProcess
ReadProcessMemory = windll.kernel32.ReadProcessMemory
CloseHandle = windll.kernel32.CloseHandle
PROCESS_ALL_ACCESS = 0x1F0FFF
pid = 2320
address = 0x00C98FCC
buffer = c_char_p(b"The data goes here")
val = c_int()
bufferSize = len(buffer.value)
bytesRead = c_ulong(0)
processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
if ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead)):
memmove(ctypes.byref(val), buffer, ctypes.sizeof(val))
print("Success: " + str(val.value))
else:
print("Failed.")
CloseHandle(processHandle)
这篇关于ctype-python-long int时间太长,无法转换-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!