Menu

#45 would like to have ReadProcessMemory

open
nobody
win32 (43)
5
2006-06-06
2006-06-06
No

would like to see ReadProcessMemory added to the api.

Discussion

  • Jason Currey

    Jason Currey - 2006-06-06

    Logged In: YES
    user_id=543879

    I guess also WriteProcessMemory would also be helpful.
    I notice these functions are in the perl equivalent.

     
  • Andrew Barnert

    Andrew Barnert - 2007-11-10

    Logged In: YES
    user_id=1473180
    Originator: NO

    Until this is done, you can use ctypes to access these functions. I've written a little game-cheat program in Python that does exactly that, and it includes a module that wraps ReadProcessMemory and friends in a nice Process class.

    Here's a stripped-down version of the key functions:

    import ctypes
    kernel = ctypes.windll.kernel32

    class Process(object):
    def __init__(self, pid):
    self.pid = pid
    self.h = kernel.OpenProcess(0x0018, 0, pid)
    def close(self):
    if (self.h):
    kernel.CloseHandle(self.h)
    self.h = None
    def __del__(self):
    self.close()
    def read(self, addr, size):
    buf = ctypes.create_string_buffer(size)
    bytesread = ctypes.c_size_t()
    kernel.ReadProcessMemory(self.h, addr, buf,
    ctypes.c_size_t(size),
    ctypes.addressof(bytesread))
    return buf[:bytesread.value]

    You can also use win32api for most of the work and only use ctypes for the missing functions. For example, if you used the win32api.OpenProcess function, h would be a PyHANDLE, so you'd have to pass self.h.handle to ReadProcessMemory.

     
  • Valhalla

    Valhalla - 2008-07-21

    Logged In: YES
    user_id=2153795
    Originator: NO

    Yes, that would be great !

    And of course other process manipulation APIs like OpenProcess etc would be great !

     

Log in to post a comment.