Ok so I have a question about step 3 of C++ Dll Injection, that is:
Use CreateRemoteThread(). You can point it at
LoadLibrary()
as the entry point and the file path from steps 1 and 2 as the argument. That's a bit hacky, to be honest, but if you are injecting a DLL you're already being quite hacky. Another technique would be to use steps 1 & 2 to load some machine code into the remote proceess and point it at that.
So my question is: After I allocated memory using VirtualAllocEx
, and writing the code with WriteProcessMemory
, how do I make the call to CreateRemoteThread
— and by that I mean what are the fourth and fifth parameters?
My code:
AllocatedMem = VirtualAllocEx(Proc, IntPtr.Zero, code.Length,
AllocationType.Reserve | AllocationType.Commit, MemoryProtection.ReadWrite);
WriteProcessMemory(Proc, AllocatedMem, code, code.Length, IntPtr.Zero);
CreateRemoteThread(Proc, IntPtr.Zero, 0, AllocatedMem,
IntPtr.Zero, 0, IntPtr.Zero);