I had a little too much time on my hands and started wondering if I could write a self-modifying program. To that end, I wrote a \"Hello World\" in C, then used a hex editor
If you are using Windows, you can do the following:
Step-by-Step Example:
VirtualProtect() on the code pages you want to modify, with the PAGE_WRITECOPY protection.VirtualProtect() on the modified code pages, with the PAGE_EXECUTE protection.FlushInstructionCache().For more information, see How to Modify Executable Code in Memory (Archived: Aug. 2010)