>Really, How do you think it is done in Unix/NT.
I do not "think" how it is done...I *know* how it is done.
Many OSes provide separate code segments (executable, not writable) and data segments (writable, not executable). If that is all you have, you cannot create self-modifying code. However, in real life (depending on the OS), you can usually do either of the following:
1) change the property of a code segment, making it a data segment, modify as needed and change it back to a code segment.
2) create a mixed segment, which is writable and executable, copy code there, modify it and execute.
Failing this, a program may be able to modify its own disk image.
Finally, any OS that includes a "DOS box" where you can run (not just emulate) DOS applications has to allow the existence of self-modifying executables. |