Executing assembler code with python

后端 未结 7 1591
长情又很酷
长情又很酷 2021-02-01 18:00

I want to execute assembly code inside a python script. Is that possible?

In C programming would be like this

static inline getesp(){
        __asm__(\"m         


        
相关标签:
7条回答
  • 2021-02-01 18:48

    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.

    0 讨论(0)
提交回复
热议问题