blob: 5010a27665b98244805f0bb36cb6ddc00af62cf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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: dllmain1.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;
}
|