Is it possible to inject the CLR host into a running process?

This way is crazy, I know.

I have an executable (source code that I do not have access to) that I would like to extend through .NET. This is a regular executable, so for this I will need to add the CLR host. My main idea is to provide script-like functionality using the .NET language (e.g. C #) and provide hooks in the target executable for scripts to control and vice versa.

I know that I need to use various methods to achieve this - DLL injections, some ASM injections at runtime, etc., but I would like to know the following: what am I talking about possible? Better yet - has anyone done something similar before?

+3
source share
2 answers

You can do this using COM interop if your own executable is capable of using COM objects. If you register the .NET assembly for interaction, then your own executable can use your .NET classes as "regular" COM objects, and when the first one is created, it will deploy the CLR inside its own process. Similary, if you can expose COM objects from your own executable, then you can use them from your .NET code if you create an interop assembly (or even without a type library if you use only IDispatch).

, - . .NET COM, . , , .NET COM . , CLR , . COM, CLR , .

+2

- . EasyHook CodePlex. , IPC . , , .

+1

Source: https://habr.com/ru/post/1707079/


All Articles