4 ms·
i used to use that same function pointer cast trick to execute bytes from memory a long time ago. you should find that it fails in most modern execution enviro
by jheriko 11y ago
i used to use that same function pointer cast trick to execute bytes from memory a long time ago.
you should find that it fails in most modern execution environments...
in legacy/desktop windows you can virtualalloc things to be executable but the same is not true in the general case, and this code doesn't do that.
even a long time ago (before windows 8, ios etc.) i wasn't able to just execute things on the stack or heap reliably and had to write code that explicitly allocated executable memory.
- lultimouomo 11y agoThe assembler strings are not allocated at run time, but stored in a read only section of the program (which apparently is marked as executable, if this works)
- jheriko 11y agoyeah, but the fact that the static data area is marked as executable is luck rather than reliability.