gpt4 book ai didi

python - ctype - python - long int 太长无法转换 -

转载 作者:行者123 更新时间:2023-12-04 18:05:39 24 4
gpt4 key购买 nike

问题:

Traceback (most recent call last): File "C:\Users\Nutzer\Google Drive\Code\Code\memory_read.py", line 26, in byref(bytesRead)) ctypes.ArgumentError: argument 2: : long int too long to convert

代码:

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) 更改为其他一些 ctypes,但没有成功。我在 Windows 8.1 系统 64 位上。经过数小时的搜索,我找不到任何解决方案或类似的问题。有人知道这里出了什么问题吗?

最佳答案

经过长时间的失败和错误,我终于有了答案。

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)

关于python - ctype - python - long int 太长无法转换 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27284050/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com