Reloaded-Project / Reloaded.Core.Bootstrap

Tiny Visual C++ library/example that allows you to inject CoreCLR (the .NET Core Runtime) into the current unmanaged process and execute a .NET library.
MIT License
24 stars 5 forks source link

Using this example in a DLL? #2

Open HeroXx opened 2 years ago

HeroXx commented 2 years ago

I'm having problems translating this into a DLL startup. I've tried expanding out the bootstrap example to use DllMain and running the CLR from within the attach but injection always fails.

I don't suppose you have any guidance you could give?

Sewer56 commented 2 years ago

Loading libraries from DllMain will cause a deadlock due to the loader lock.

Consider starting a separate thread and starting the runtime from there. Example.

Alternatively, if you need your code to execute as part of startup before target process' code; either start the process suspended, inject into that and resume when done; or hijack one of the DLLs supported by the application and run your bootstrapper from there (like ASI loaders etc. do)