[IronPython] Cast to a method pointer using CTYPES

Andrew Evans evans.d.andrew at gmail.com
Wed Feb 9 21:22:49 CET 2011


Hey thank you for the fast reply :-)

I am working on building a security framework in Python for exploit
development as a part time hobby. But I am missing something key to what I
am doing. I am having a hard time understanding it as well.

from ctypes import *

myCode = ("\x31\xc0\x31\xdb\x31\xc9\x31\xd2"
    "\x51\x68\x6c\x6c\x20\x20\x68\x33") #example hex not full for post don't
want to put up red flags

my_callback = CFUNCTYPE(c_int, c_void_p,
                        POINTER(myCode),
                        POINTER(c_int32), c_void_p)

print type(my_callback)

this returns <type '_ctypes.PyCFuncPtrType'> which is what I want I assume.

but when I run this code nothing happens. Maybe in how I am running it just
by adding my_callback to the source. Any idea what I am doing wrong.

*cheers in advance if you can help

If not I understand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20110209/b5de4121/attachment.html>


More information about the Ironpython-users mailing list