Changing the EAX register with Python

Grant Edwards invalid at invalid.invalid
Fri Nov 19 11:32:21 EST 2010


On 2010-11-19, Tim Roberts <timr at probo.com> wrote:
> dutche <dutche at gmail.com> wrote:

>> My project is to have a python program that loads a C program and
>> sets a breakpoint at some address, and then with this breakpoint I
>> change the EAX register and then continue the program execution.

> You will need to find a Linux application equivalent to PaiMei.  Your
> question is not "how can I change EAX", your question is "where can I
> find a Linux debugger that can be controlled from Python?"
>
> I don't know the answer to that.  gdb is quite powerful, and you can
> certainly control it by connecting to its stdin and stdout
> connections.

If you're going to do that, you want to run gdb in "machine interface"
mode, which makes it a lot easier to talk to programatically.  I've
not done it in Python, but it's easy enough in C, so in Python it
ought to be trivial:

 http://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html#GDB_002fMI

If you don't want to write code to talk the gdb/mi "command language",
then another option is to use a library like libmigdb:

  http://sourceforge.net/projects/libmigdb/

You can probably call the library functions using cytpes:

 http://docs.python.org/library/ctypes.html

-- 
Grant Edwards               grant.b.edwards        Yow! Psychoanalysis??
                                  at               I thought this was a nude
                              gmail.com            rap session!!!



More information about the Python-list mailing list