That depends on what you intended to do. The code loads a DLL and calls a function that the DLL exports.
Or is calling a DLL thread all that it does? |
There's no such thing as a "DLL thread".
I imagine I'll have to use CreateThread() at that point somehow. |
No, injecting a DLL involves:
1. Allocating executable memory in the target process, using VirtualAllocEx().
2. Copying a small injector into this memory, using WriteProcessMemory(). The injector is usually written in Assembly (often at least partly dynamically generated to make it position-independent), since it needs to be small and simple: all it needs to do is load a DLL and execute some function in it.
3. Call CreateRemoteThread() from your process, passing a handle to the target process and using the executable memory as entry point. This will fire off a new thread in the target process starting from the injector, which will eventually jump into the DLL so you can run whatever you need.
You might want to take a look at this project:
https://github.com/nektra/Deviare-InProc/
It's made for API hooking, but it does DLL injection, so it already has an injector implemented.