I'm trying to get a value from a memory address of a process(In this case, OBS64). I have this code with the Process ID of the OBS and the memory address of the value I want. Cheat Engine says the value is 4 Bytes
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)
I get the error:
ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert
But I'm not sure why. I think it's because of the length of the buffer, but I tried to play with it a lot and kept getting the error...