Ok, say that my application is emitting (x86) instructions into memory, making the page executable, etc. Is there any way of altering the method stub of an un-JITted method to point to my emitted instruction stream?
E.g.:
Suppose I have created an x86 instruction stream in memory, which does something arbitrary. Now, further suppose that I have a method 'int Target()'. I haven't called it yet, so it hasn't been compiled. Is there any way to:
- Get the pointer to Target's stub
- Make it point to my emitted instruction stream.
I realise that practically every single security feature of .Net is designed to prevent hijacking like this. But is it possible through, say, the hosting API?