Dll Injection Methods?
What are the most common or most effective dll or code injection methods for Windows systems? Can someone explain to me the very basics of it? This is one thing I don't quite understand. Do you create a remote thread and make it call LoadLibrary, or what? I'm just now getting into writing trainers and such, and I'd like for someone to explain this. -.-' I have googled it, but couldn't quite find a good article on it. Besides, you guys are better than random shitty articles written by elitist pricks.
Edit: Did a little more reading. So far all I understand is this: Method 1. Allocate memory for the string containing the name of the dll to be loaded in the remote process(VirtualAllocEx), write the string to that memory(WriteProcessMemory), Create a thread in the target process(CreateRemoteThread), load the dll into the remote process by calling LoadLibrary on the new thread, LoadLibrary calls the DllMain function in the injected dll.
And method 2. Allocate memory for code and data in the target process, write a function and whatever data it needs, if it needs any(only allowed a page of data for local variables on a remote thread? not sure.), Create a remote thread and pass it the address of the function you wrote to the target process's memory.
Is that generally how it works, are there other ways, and if games or programs have ways of preventing these methods from working, what other methods do you use or how do you get around the prevention?