I recently remembered a fellow student who, a couple of years ago, told me that he injected a (native) DLL into a foreign process and started the .NET runtime there, that is, had C# code run in a foreign native process. Well, bright eyes on my side and then I forgot about it.
Anyway, some days ago I gave it a try and it found out that this isn’t too hard to achieve. Running your .NET assembly in a native application requires basically four steps using the .NET 4 Hosting Interfaces:
- Retrieving an interface to the CLR (meta) host.
- Requesting an interface to the required runtime.
- Retrieving the actual interface of the runtime.
- Executing the assembly in the default application domain.
So here we go, ignoring all return codes on the way: Weiterlesen »