Edit:
The answer of this question is here:
https://stackoverflow.com/a/27317947/996540
When you create a project in msvc, the option /DYNAMICBASE is defa
I have no idea about the unsuccess of EnumProcessModulesEx and CreateToolhelp32Snapshot, let's leave this question to the expert.
My goal is to get the load address (base address) of the child process, find the entry point and patch it - the reason to patch the entry point is here: https://opcode0x90.wordpress.com/2011/01/15/injecting-dll-into-process-on-load/
Since DLL injection is the main purpose of mine, I have to reconsider this question. I would use the "CreateRemoteThread & LoadLibrary Technique" http://www.codeproject.com/Articles/4610/Three-Ways-to-Inject-Your-Code-into-Another-Proces#section_2 to do the DLL injection (In fact ASLR is not the barrier of this technique by the way), Although there are so many limits in DLLMain http://msdn.microsoft.com/en-us/library/windows/desktop/dn633971%28v=vs.85%29.aspx , but do a little works is OK: Find the base address of an exe using GetModuleHandleA(NULL), save the HMODULE returned into shared memory, next, the caller process read shared memory and get the HMODULE. Synchronization mechanism is necessary of course.
So, the answer is IPC. (not every IPC mechanism is safe in DLLMain by the way)