3 ms·
How did you inject the machine code into a running program on anything near a modern architecture? Unless you had your own OS, wouldn't code segments be RO and
by dajt 3y ago
How did you inject the machine code into a running program on anything near a modern architecture? Unless you had your own OS, wouldn't code segments be RO and data segments not executable?
I don't know enough about any processor created in the last 30 years to know if running bare metal without a commercial OS would allow you to not have those constraints.
- silasb 3y agoCan't you use `mprotect` to allow you to write to memory and execute? https://github.com/Frodox/execute-machine-code-from-memory/tree/master https://github.com/Frodox/execute-machine-code-from-memory/t... has several examples of how to do it. EDIT: https://www.kvakil.me/posts/2022-10-13-optimizing-mprotect-in-luajit-with-pkeys.html https://www.kvakil.me/posts/2022-10-13-optimizing-mprotect-i... is another good link that explains this.
- onetimeuse92304 3y agoIf you can modify your operating system you can do pretty much anything you want (Thanks, Linus!)