by Zambyte · 3y ago · 0 comments
edit: There might be room for some other extension here, but as an other commenter already wrote:
1. functions might not be contiguous in memory
2. the code that you are moving should better be position independent
So any such extension should handle these issues one way or an other.
I never got into this but "GNU lightning is a free-software library for generating assembly language code at run-time." https://en.wikipedia.org/wiki/GNU_lightning
https://onesphere.hashnode.dev/upstart
And for some reason: https://news.ycombinator.com/item?id=36976878
- hot patching
- making sure sysadmins have healthy sense of panic available to them at all times
I think obfuscation is generally a really bad idea, but that was brought up in the article. One practical application for self-modifying code is hotpatching. Sometimes you really don't want to stop the process but want to change the implementation for some function.
Some systems apparently allow you to add executable without removing write as that is what the OP does with "mprotect(page, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC);". However,