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 static struct counter_values counter_values = 12 { 13 0, 0, 0, 0, 5656, 0, 0 14 }; 15 static struct counter_values *p_counter_values; 16 17 static struct init_static 18 { 19 int m_uninit; 20 int m_counter; 21 22 init_static() : 23 m_counter(2) 24 { 25 counter_values.static_construct_counter_at_startup = counter_values.static_construct_counter; 26 counter_values.m_uninit_at_startup = m_uninit; 27 counter_values.static_construct_counter++; 28 m_uninit++; 29 } 30 31 ~init_static() 32 { 33 p_counter_values->dtor_counter++; 34 } 35 } init_static; 36 37 extern "C" 38 { 39 SET_COUNTER_VALUES_POINTER SetCounterValuesPointer; 40 void 41 WINAPI 42 SetCounterValuesPointer( 43 _Out_ struct counter_values *pcv) 44 { 45 p_counter_values = pcv; 46 memcpy(pcv, &counter_values, sizeof(counter_values)); 47 } 48 49 BOOL 50 WINAPI 51 DllMain( 52 _In_ HINSTANCE hinstDLL, 53 _In_ DWORD fdwReason, 54 _In_ PVOID pvReserved) 55 { 56 if (fdwReason == DLL_PROCESS_ATTACH) 57 { 58 counter_values.m_uninit = init_static.m_uninit; 59 counter_values.m_counter = init_static.m_counter; 60 } 61 else if (fdwReason == DLL_PROCESS_DETACH) 62 { 63 p_counter_values->dtor_counter_at_detach = p_counter_values->dtor_counter; 64 } 65 return TRUE; 66 } 67 68 }