Search code examples
pythonwindowsmmap

mmap.PROT_EXEC windows equivalent in mmap python


I'm looking for the equivalent of the linux "mmap.PROT_EXEC" method for windows. (Inside mmap module on python)


Solution

  • Without going down to raw ctypes access to the underlying APIs (CreateFileMapping/MapViewOfFile), this can't be done. The access arguments (used on Windows, and mapped to equivalent flags/prot flags on Linux) defined by Python are strictly limited to ACCESS_READ, ACCESS_WRITE, ACCESS_COPY and ACCESS_DEFAULT, and none of them allow the memory to be mapped executable.