ReactOS 0.4.16-dev-92-g0c2cdca
dll_startup.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for static C++ object construction/destruction in a DLL
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <apitest.h>
9#include "dll_startup.h"
10
11// we test the initial value of m_uninit variable here, so this is required
12#ifdef __GNUC__
13#pragma GCC diagnostic ignored "-Wuninitialized"
14#endif
15
17{
18 0, 0, 0, 0, 5656, 0, 0
19};
21
22static struct init_static
23{
26
28 m_counter(2)
29 {
33 m_uninit++;
34 }
35
37 {
38 p_counter_values->dtor_counter++;
39 }
41
42extern "C"
43{
45void
48 _Out_ struct counter_values *pcv)
49{
50 p_counter_values = pcv;
51 memcpy(pcv, &counter_values, sizeof(counter_values));
52}
53
54BOOL
57 _In_ HINSTANCE hinstDLL,
58 _In_ DWORD fdwReason,
60{
61 if (fdwReason == DLL_PROCESS_ATTACH)
62 {
65 }
66 else if (fdwReason == DLL_PROCESS_DETACH)
67 {
68 p_counter_values->dtor_counter_at_detach = p_counter_values->dtor_counter;
69 }
70 return TRUE;
71}
72
73}
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
static struct init_static init_static
SET_COUNTER_VALUES_POINTER SetCounterValuesPointer
Definition: dll_startup.cpp:44
static struct counter_values * p_counter_values
Definition: dll_startup.cpp:20
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition: dll_startup.cpp:56
void WINAPI SET_COUNTER_VALUES_POINTER(_Out_ struct counter_values *pcv)
Definition: dll_startup.h:24
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
int static_construct_counter
Definition: dll_startup.h:16
int static_construct_counter_at_startup
Definition: dll_startup.h:15
int m_uninit_at_startup
Definition: dll_startup.h:12
#define WINAPI
Definition: msvc.h:6