DLL Injection in C# Snippet

Code snippet available for copy here

The code snippet is self documenting and will specify what failed or if it succeeded.  Simply use any of the InjectDLL functions.

I recommend using any of these

public InjectRet InjectByProcessName(string strDLLName, string strProcessName)

public InjectRet InjectDLL(string fileName, Process Process)

 

The function

public InjectRet InjectDLL(IntPtr hProcess, string strDLLName)

This was converted to C# by me from C++ from a blog post in 2008 and therefore may or may not be under GPL 3.0.  Since the post has likely been deleted at this point, I have no way of knowing.