2
Vote

DllMain rule violation in _g_smtp_init's constructor

description

In the atlsmtpconnection.h file, the global variable declaration "__declspec(selectany) CSMTPWSAStartup _g_smtp_init;" calls "WSAStartup(ATLSMTP_WSA_VERSION, &wsadata)" in its constructor (see init() method).
This violates the rule that we may not call imported functions other than those located in Kernel32.dll (see "DllMain Restrictions" section at http://msdn.microsoft.com/en-us/library/aa290048%28VS.71%29.aspx).
 
Possible solutions (IMHO):
1) remove the init() call from the constructor of CSMTPWSAStartup
2) wrap the _g_smtp_init object in a songleton
 
Note:
Because of this issue, we had a crash when the DLLS were loaded (DllMain) -> hard to diagnose & debug. DLL Delay Load (in Visual Studio) helped, but it isn't a "real" solution...

comments