How is JIT compiled code injected in memory and executed?

后端 未结 1 1660
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 12:11

"Consider a typical Windows x86 or AMD64 architecture, the memory is divided in executable sections that cannot be written to and data sections that can be wri

1条回答
  •  伪装坚强ぢ
    2021-02-20 12:54

    It is simply done with the Windows VirtualProtect() API function. It changes the virtual memory page attributes. From PAGE_READWRITE so the JIT compiler can write the machine code to PAGE_EXECUTE_READ so it can be executed. No special privileges are required to do so since the page is owned by the process that also runs the JIT compiler.

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