DLL_PROCESS_ATTACH == 1
The DLL is being loaded into the virtual address space of the current process as a result of the process starting up or as a result of a call to LoadLibrary.
DLL_THREAD_ATTACH == 2
The current process is creating a new thread. When this occurs, the system calls the entry-point function of all DLLs currently attached to the process. The call is made in the context of the new thread.
DLL_THREAD_DETACH == 3
A thread is exiting cleanly.
DLL_PROCESS_DETACH==0
The DLL is being unloaded from the virtual address space of the calling process
对函数的描述:
DllMain Callback Function
An optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. The system also calls the entry-point function for a DLL when it is loaded or unloaded using the LoadLibrary and FreeLibrary functions.