I want to execute assembly code inside a python script. Is that possible?
In C programming would be like this
static inline getesp(){
__asm__("mov %esp, %eax");
}
But how to do that with Python? Is it possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One way you could do this would be to write a (C) extension for Python. You can take a look at this documentation for full details of how to do that.
Another way of developing C-based Python extensions would be to interface directly with an external library using the ctypes module.
In any case, you’d need some C code compiled into either a library or an extension and a way to call it from Python. Clearly for what you want to achieve this is probably not optimal but actually its not that much work to expose a few functions.