I was wondering if it'd be possible to write self modifying code in C? I guess if you knew where the program is in memory it shouldn't be too hard to do, but outside of that... I was wondering if maybe anyone here knew of any good resources on this topic. Self modifying code in general, really. I'm not looking for a solution for meta-programming, like those provided in most modern day languages. It's a learning exercise more than anything.
edit: I am aware that modern OS tend to protect running processes from just this thing. I'll install an ancient build of linux on an emulator if I have to :P
I'm rusty but I used to do a lot of work with z80 asm with my graphic calculator and SOME arm asm when I found my old Ipaq pda a few years ago.
The exercise I've set up for my self is to write a program that rather than using a for-loop, modifies it's self so that it prints 1 through 10.
Ultimately I'm trying to get a better grasp of what my software looks like under the hood (so to speak). My next step in this project will be make a function return to a different point on the execution stack than it was called from. Though, I think I might need to do that to achieve the self modifying program I described above anyways. I dunno, this is all pretty new to me.
This used to be done a lot a long time ago, but sadly it's pretty shut down anymore. Ended up turning into a security risk.
Hence most modern OS do their darnedest to prevent this from happening.
Part of the reason I want to do this is that I've found that the comp sci curriculum at ever liberal arts college I've looked into are dime-a-dozen web dev farms at best and over glorified Tech support programs at worst. As I cant afford/no longer have the grades to get into a good engineering/science school I'm learning a lot of things on my own. Not that I mind doing so, I'm starting to think I'll drop out and continue to be self taught before all is said and done. I've heard from a number of advisors that it is not uncommon for self taught applicants to be on par with MIT/Cal Tech/Berkly/etc grad applicants when selecting a new employee.