Article ID: 119333
Article Last Modified on 11/21/2006
BOOL WINAPI _DllMainCRTStartup( HINSTANCE, DWORD, LPVOID );
extern "C" BOOL WINAPI
NewDLLEntry( HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved )
{
BOOL bRet = TRUE;
static DWORD dwVer = 0;
static int nAttached = 0;
if( !dwVer )
dwVer = GetVersion();
// Check for Win32s and version < 4.0 (Windows "Chicago").
if( ((HIWORD(dwVer) & 0x8000) != 0x8000) || ((dwVer & 0xFF) >= '4') )
bRet = _DllMainCRTStartup( hInstDLL, dwReason, lpReserved );
else
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
if( nAttached++ == 0 ) // Call CRT entry if first process.
bRet = _DllMainCRTStartup( hInstDLL, dwReason, lpReserved );
break;
case DLL_PROCESS_DETACH:
if( --nAttached == 0 ) // Call CRT entry if last process.
bRet = _DllMainCRTStartup( hInstDLL, dwReason, lpReserved );
break;
}
}
return bRet;
}
You can still run into problems with memory allocation even after you have
replaced the entry point. Whichever process allocates the memory owns it;
therefore, when the process goes away, the object is destroyed and no other
process can use the object. This is a problem for any object shared by
multiple processes.
Additional query words: 1.00 2.00 2.10 noupdate kbNoUpdate
Keywords: kbdll kbprb KB119333