'Python Pymem MemoryReadError GetLastError: 299
Since 2 day i try to read docs of pymem and search an error on forums but all solution i've seen failed
I can't just read the int in the memory address and i don't know if it's a probleme of code or my pc
from pymem import *
from pymem.process import module_from_name
pm = pymem.Pymem("***-Win64.exe")
gameModule = module_from_name(pm.process_handle, "***-Win64.exe").lpBaseOfDll
def GetPtrAddr(base, offsets):
addr = pm.read_int(base) # addr = 9460301, base = 140696812060672
for i in offsets:
if i != offsets[-1]:
addr = pm.read_int(addr + i) # <- here is the error line
return addr + offsets[-1]
pm.read_int(GetPtrAddr(gameModule + 0x04D934B0, [0x50, 0x30, 0x98, 0xf0, 0x380]))
error
pymem.exception.MemoryReadError: Could not read memory at: 9460349, length: 4 - GetLastError: 299
i tried this too Reading Memory Address from a process with a Static Address and Offsets in Python but i have error
ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert
but the only value i try to get is from 0 to 12

I add a try catch in the for loop and here is the error
Could not read memory at: 9460349, length: 4 - GetLastError: 299
Could not read memory at: 9460973, length: 4 - GetLastError: 299
Could not read memory at: 9460589, length: 4 - GetLastError: 299
Could not read memory at: 9460301, length: 4 - GetLastError: 299
Solution 1:[1]
I fanally found my error thanks to @Joe_Bao for the help
The problem was because my application is in 64bit and i tried to read a int but that's not enough so here the complete code
from pymem import *
from pymem.process import *
offsets = [0x50,0x30,0x98,0xF0,0x380]
pm = Pymem('***-Win64.exe')
gameModule = module_from_name(pm.process_handle, '***-Win64.exe').lpBaseOfDll
def GetPointer(base, offsets):
addr = pm.read_longlong(base+0x04D934B0) # <-- here was the probleme solved
print(hex(addr))
for offset in offsets:
if offset != offsets[-1]:
try:
addr = pm.read_longlong(addr + offset)
print(addr)
except Exception as e:
print(e)
return addr + offsets[-1]
GetPointer(gameModule, offsets)
Solution 2:[2]
I wonder why you add the return value from pm.readint() with your offset. It seems that base is a valid address you can access, while addr + some offset isn't.
I read from the documentation that read_int reads 4 byte from an area of memory in a specified process. Is the return value addr the address you want to use?
FYI, I found that the error code is thrown by kernel32, and it means ERROR_PARTIAL_COPY.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kal-1 |
| Solution 2 | Joe_Bao |
