ReactOS
0.4.16-dev-835-gd769f56
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
16
static
struct
counter_values
counter_values
=
17
{
18
0, 0, 0, 0, 5656, 0, 0
19
};
20
static
struct
counter_values
*
p_counter_values
;
21
22
static
struct
init_static
23
{
24
int
m_uninit
;
25
int
m_counter
;
26
27
init_static
() :
28
m_counter
(2)
29
{
30
counter_values
.
static_construct_counter_at_startup
=
counter_values
.
static_construct_counter
;
31
counter_values
.
m_uninit_at_startup
=
m_uninit
;
32
counter_values
.
static_construct_counter
++;
33
m_uninit
++;
34
}
35
36
~init_static
()
37
{
38
p_counter_values
->dtor_counter++;
39
}
40
}
init_static
;
41
42
extern
"C"
43
{
44
SET_COUNTER_VALUES_POINTER
SetCounterValuesPointer
;
45
void
46
WINAPI
47
SetCounterValuesPointer
(
48
_Out_
struct
counter_values
*pcv)
49
{
50
p_counter_values
= pcv;
51
memcpy
(pcv, &
counter_values
,
sizeof
(
counter_values
));
52
}
53
54
BOOL
55
WINAPI
56
DllMain
(
57
_In_
HINSTANCE
hinstDLL,
58
_In_
DWORD
fdwReason
,
59
_In_
PVOID
pvReserved
)
60
{
61
if
(
fdwReason
==
DLL_PROCESS_ATTACH
)
62
{
63
counter_values
.
m_uninit
=
init_static
.
m_uninit
;
64
counter_values
.
m_counter
=
init_static
.
m_counter
;
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
}
apitest.h
fdwReason
static DWORD const fdwReason
Definition:
appcrt_dllmain.cpp:57
TRUE
#define TRUE
Definition:
types.h:120
DLL_PROCESS_ATTACH
#define DLL_PROCESS_ATTACH
Definition:
compat.h:131
DLL_PROCESS_DETACH
#define DLL_PROCESS_DETACH
Definition:
compat.h:130
init_static
static struct init_static init_static
SetCounterValuesPointer
SET_COUNTER_VALUES_POINTER SetCounterValuesPointer
Definition:
dll_startup.cpp:44
p_counter_values
static struct counter_values * p_counter_values
Definition:
dll_startup.cpp:20
DllMain
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition:
dll_startup.cpp:56
dll_startup.h
SET_COUNTER_VALUES_POINTER
void WINAPI SET_COUNTER_VALUES_POINTER(_Out_ struct counter_values *pcv)
Definition:
dll_startup.h:24
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
void
Definition:
nsiface.idl:2307
memcpy
#define memcpy(s1, s2, n)
Definition:
mkisofs.h:878
pvReserved
static LPCSTR DWORD void * pvReserved
Definition:
str.c:196
_Out_
#define _Out_
Definition:
no_sal2.h:160
_In_
#define _In_
Definition:
no_sal2.h:158
counter_values
Definition:
dll_startup.h:11
counter_values::static_construct_counter
int static_construct_counter
Definition:
dll_startup.h:16
counter_values::m_uninit
int m_uninit
Definition:
dll_startup.h:13
counter_values::static_construct_counter_at_startup
int static_construct_counter_at_startup
Definition:
dll_startup.h:15
counter_values::m_counter
int m_counter
Definition:
dll_startup.h:14
counter_values::m_uninit_at_startup
int m_uninit_at_startup
Definition:
dll_startup.h:12
init_static
Definition:
dll_startup.cpp:23
init_static::~init_static
~init_static()
Definition:
dll_startup.cpp:36
init_static::init_static
init_static()
Definition:
dll_startup.cpp:27
init_static::m_uninit
int m_uninit
Definition:
dll_startup.cpp:24
init_static::m_counter
int m_counter
Definition:
dll_startup.cpp:25
WINAPI
#define WINAPI
Definition:
msvc.h:6
modules
rostests
apitests
crt
dll_startup.cpp
Generated on Thu Mar 20 2025 06:07:08 for ReactOS by
1.9.6