diff options
Diffstat (limited to 'src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp')
-rw-r--r-- | src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp new file mode 100644 index 0000000000..4e3f8862a4 --- /dev/null +++ b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp @@ -0,0 +1,66 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================================= +** +** Source: dllmain2.c +** +** Purpose: Test to ensure DllMain() is called with THREAD_ATTACH +** when a thread in the application is started. +** +** Dependencies: none +** +** +**===========================================================================*/ + +#include <palsuite.h> + +/* count of the number of times DllMain() was called with THREAD_DETACH */ +static int g_attachCount = 0; + + +/* standard DllMain() */ +BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) +{ + BOOL bResult = TRUE; + + switch( reason ) + { + case DLL_PROCESS_ATTACH: + { + break; + } + + case DLL_PROCESS_DETACH: + { + break; + } + + case DLL_THREAD_ATTACH: + /* increment g_attachCount */ + g_attachCount++; + break; + + case DLL_THREAD_DETACH: + break; + } + return bResult; +} + + +#ifdef WIN32 +BOOL __stdcall _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return DllMain(hinstDLL, fdwReason, lpvReserved); +} +#endif + +/* function to return the current attach count */ +#ifdef WIN32 +__declspec(dllexport) +#endif +int PALAPI GetAttachCount( void ) +{ + return g_attachCount; +} |