How could I generate and execute machine code at runtime?

前端 未结 3 1295
夕颜
夕颜 2021-02-02 04:37

The closest I have gotten to assembly is building my own Java Class library which loads class files and allows you to create, compile, and decompile classes. While endeavoring t

3条回答
  •  抹茶落季
    2021-02-02 05:31

    To execute a piece of x86 machine, use the jmp instruction to jump to its beginning. Note that the CPU doesn't know where the code ends so you have to make manual arrangements. A better way is to use call to call that machine code and then return with a ret instruction somewhere in the code.

    There is no direct way to execute just a single instruction as that is usually pretty pointless. I'm not sure what you are trying to achieve.

提交回复
热议问题