dnSpyEx / dnSpy

Unofficial revival of the well known .NET debugger and assembly editor, dnSpy
GNU General Public License v3.0
7k stars 458 forks source link

Inject managed DLL #273

Open Symbai opened 11 months ago

Symbai commented 11 months ago

Problem Description

I need to inject a managed DLL into a managed (.NET core) process and execute the entry method. Maybe dnSpyEx already supports this? I couldn't find it

Proposal

When debugging a target allow us to select a managed DLL to inject and perhaps select a method to execute

Alternatives

I couldn't find any simple injector that works with .NET (core) targets Target has detection for DOTNET_STARTUP_HOOKS so I cannot use this either.

Additional Context

No response

GazziFX commented 11 months ago

Maybe you should try to write a loader that will run the target program and your DLL using Assembly.Load?

Symbai commented 11 months ago

Thank you for your valuable(?) response. I still think this would be a useful feature for dnSpyEx/a debugger.

Dump-GUY commented 10 months ago

Hello. Shameless plug here... Could you please try to do something we did in our publication regarding .NET Hooking: https://research.checkpoint.com/2024/net-hooking-harmonizing-managed-territory/

Check the last section "Harmony Hooking from the DnSpyEx Debugging Context" - where we used the "Watch" window to load our managed hooking dll and invoke some functions etc. Hopefully, it could be useful in your case too.