How to change the value stored in memory address?

memory, python

Solution

>>> import ctypes
>>> memfield = (ctypes.c_char).from_address(0x0A7F03E4)

Now you can read memfield, assign to it, do whatever you want. As long as you have access to that memory location, of course.

you can also get a memarray with

>>> memarray = (ctypes.c_char*memoryfieldlen).from_address(0x0A7F03E4)

which gives you a list of memfields.

Update: I just read that you want to retrieve an integer. in this case, use ctypes.c_int, of course. In general: use the appropriate ctype ;)

Problem

Lets say that memory address `0A7F03E4` stores a value `124`. How to change it to `300` using python? Is there a module supplied for this kind of task?

Original source