Suppose I want to inject a DLL into a process that wants to edit the value of address A every 250 ms. I would need to use DllMain, right? The issue is that I'm not allowed to wait inside DllMain. So I would have to create a thread? Or does that not bypass the limitation? How would I go about doing this?
Also, are there any benefits for using DLL injection to edit the memory of an application over using an EXE?
Also, what should the stack size be in CreateThread? What if it is too small or too large? How do I know how much I need?
From your description it seems you already know how to have the target process load your DLL. If my assumption is correct, then the answer is simple: create a thread from DLLMain and implement your logic in the thread. As long as your code respects the rules outlined below you should be fine.
This document describes what can and cannot be done in DLLMain and why.
As documented, you should never perform the following tasks from within DllMain:
The following tasks are safe to perform within DllMain:
Your second question is less clear to me. To inject code into another process you must start from somewhere (browser, exe, whatever), then write into the target process memory to have it load your DLL.