N-Inject help.
You mention "Two techniques are available to inject a dll: the target process can be started by using the library so the first dll loaded actually is the dll to be injected, or dlls can be injected anytime while the target process is running." You simple example is of the former but I need the latter and I can't find any examples for this.
Can anyone help?
N-Inject
I'm having difficulty getting the example solution for the injector to work. The .dll compiles and works correctly but the injector doesn't work.
I'm trying to get my head around this but I'm very new at this.
I apologize for the
I apologize for the inconvenience, I managed to get it working correctly thanks to some example code from the forums.
Regarding the original question:
You wrote:
You mention "Two techniques are available to inject a dll: the target process can be started by using the library so the first dll loaded actually is the dll to be injected, or dlls can be injected anytime while the target process is running." You simple example is of the former but I need the latter and I can't find any examples for this.
Can anyone help?
My code for injecting into a process follows.
#include "Process.h" #include "InjectLib.h" #include "GetIDFromProcName.h" char* dllName = "C:\\inject_test.dll"; LPCWSTR procName = L"calc.exe"; DWORD ProcID = 0; void main() { ProcID = GetProcIDByName(procName); if(!ProcID) return; Process targetProc(ProcID); InjectLibrary injLibrary(dllName, targetProc); if(!injLibrary.injectLib()) MessageBoxA(0,"Injection Failed!", "Argghhh!",0); return; }GetProcIDByName is a function I defined that uses the ToolHelp functions in windows to retrieve the ID of a given target process.
I hope this has helped. Thanks Jan for these excellent libraries, I'm a huge fan!