Skip to content

Why ReadProcessMemory error (0xC0000005) #1599

@aleaforny

Description

@aleaforny

Please note I'm referring to this issue: #1570

I'm getting 0xC0000005 while attempting to use ReadProcessMemory, nevertheless it's not happening while using the library with ctypes (proving that it's not an access violation issue).

FYI, I'm attempting to read an integer value (from process with PID 18896)

The following codes produces 0xC0000005:

process = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, False, 18896)
print(win32process.ReadProcessMemory(process, 0x20c6a34aa30, sys.getsizeof(wintypes.INT())))

When the following codes works as expected:

process = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, False, 18896)

ReadProcessMemory = ctypes.WinDLL('kernel32', use_last_error=True).ReadProcessMemory
ReadProcessMemory.argtypes = [wintypes.HANDLE, wintypes.LPCVOID, wintypes.LPVOID, ctypes.c_size_t, ctypes.POINTER(ctypes.c_size_t)]
ReadProcessMemory.restype = wintypes.BOOL

int_buffer = 0

if ReadProcessMemory(process.handle, 0x20c6a34aa30, id(int_buffer), sys.getsizeof(wintypes.INT()), None):
    print("int_buffer= {}".format(int_buffer))

Any idea?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions