Ctype - Python - Long Int Too Long To Convert -
problem: 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
Solution 1:
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)
Post a Comment for "Ctype - Python - Long Int Too Long To Convert -"