ReactOS
0.4.15-dev-8612-g0707475
dllmain.c
Go to the documentation of this file.
1
/*
2
* dllmain.c
3
*
4
* ReactOS MSVCRT.DLL Compatibility Library
5
*
6
* THIS SOFTWARE IS NOT COPYRIGHTED
7
*
8
* This source code is offered for use in the public domain. You may
9
* use, modify or distribute it freely.
10
*
11
* This code is distributed in the hope that it will be useful but
12
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
13
* DISCLAMED. This includes but is not limited to warranties of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*
16
*/
17
18
#include "
precomp.h
"
19
20
WINE_DEFAULT_DEBUG_CHANNEL
(msvcrt);
21
22
/* EXTERNAL PROTOTYPES ********************************************************/
23
24
BOOL
crt_process_init
(
void
);
25
26
extern
void
FreeEnvironment
(
char
**environment);
27
28
#undef _environ
29
extern
char
**
_environ
;
/* pointer to environment block */
30
extern
char
**
__initenv
;
/* pointer to initial environment block */
31
extern
wchar_t
**
_wenviron
;
/* pointer to environment block */
32
extern
wchar_t
**
__winitenv
;
/* pointer to initial environment block */
33
extern
void
msvcrt_init_exception
(
void
*)
DECLSPEC_HIDDEN
;
34
35
/* LIBRARY ENTRY POINT ********************************************************/
36
37
BOOL
38
WINAPI
39
DllMain
(
PVOID
hinstDll,
ULONG
dwReason
,
PVOID
reserved
)
40
{
41
switch
(
dwReason
)
42
{
43
case
DLL_PROCESS_ATTACH
:
44
45
TRACE
(
"Process Attach\n"
);
46
47
msvcrt_init_exception
(hinstDll);
48
49
if
(!
crt_process_init
())
50
{
51
ERR
(
"crt_init() failed!\n"
);
52
return
FALSE
;
53
}
54
55
TRACE
(
"Attach done\n"
);
56
break
;
57
58
case
DLL_THREAD_ATTACH
:
59
//msvcrt_get_thread_data creates data when first called
60
break
;
61
62
case
DLL_THREAD_DETACH
:
63
msvcrt_free_tls_mem
();
64
break
;
65
66
case
DLL_PROCESS_DETACH
:
67
TRACE
(
"Detach\n"
);
68
/* Deinit of the WINE code */
69
msvcrt_free_io
();
70
if
(
reserved
)
break
;
71
msvcrt_free_popen_data
();
72
msvcrt_free_mt_locks
();
73
//msvcrt_free_console();
74
//msvcrt_free_args();
75
//msvcrt_free_signals();
76
msvcrt_free_tls_mem
();
77
if
(!
msvcrt_free_tls
())
78
return
FALSE
;
79
if
(
global_locale
)
80
MSVCRT__free_locale
(
global_locale
);
81
82
if
(
__winitenv
&&
__winitenv
!=
_wenviron
)
83
FreeEnvironment
((
char
**)
__winitenv
);
84
if
(
_wenviron
)
85
FreeEnvironment
((
char
**)
_wenviron
);
86
87
if
(
__initenv
&&
__initenv
!=
_environ
)
88
FreeEnvironment
(
__initenv
);
89
if
(
_environ
)
90
FreeEnvironment
(
_environ
);
91
92
TRACE
(
"Detach done\n"
);
93
break
;
94
}
95
96
return
TRUE
;
97
}
98
99
/* FIXME: This hack is required to prevent the VC linker from linking these
100
exports to the functions from libntdll. See CORE-10753 */
101
#ifdef _MSC_VER
102
#ifdef _M_IX86
103
#pragma comment(linker, "/include:__vsnprintf"
)
104
#pragma comment(linker, "/include:_bsearch"
)
105
#pragma comment(linker, "/include:_strcspn"
)
106
#else
107
#pragma comment(linker, "/include:_vsnprintf"
)
108
#pragma comment(linker, "/include:bsearch"
)
109
#pragma comment(linker, "/include:strcspn"
)
110
#endif
// _M_IX86
111
#endif
// _MSC_VER
112
113
/* EOF */
WINE_DEFAULT_DEBUG_CHANNEL
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition:
precomp.h:23
ERR
#define ERR(fmt,...)
Definition:
precomp.h:57
dwReason
DWORD dwReason
Definition:
misc.cpp:141
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
DllMain
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
Definition:
dllmain.c:52
DECLSPEC_HIDDEN
#define DECLSPEC_HIDDEN
Definition:
precomp.h:8
FreeEnvironment
void FreeEnvironment(char **environment)
Definition:
environ.c:190
__initenv
char ** __initenv
Definition:
environ.c:24
__winitenv
wchar_t ** __winitenv
Definition:
environ.c:25
_wenviron
wchar_t ** _wenviron
Definition:
environ.c:23
crt_process_init
BOOL crt_process_init(void)
Definition:
crt_init.c:21
_environ
char ** _environ
Definition:
environ.c:22
DLL_THREAD_DETACH
#define DLL_THREAD_DETACH
Definition:
compat.h:133
DLL_PROCESS_ATTACH
#define DLL_PROCESS_ATTACH
Definition:
compat.h:131
DLL_PROCESS_DETACH
#define DLL_PROCESS_DETACH
Definition:
compat.h:130
DLL_THREAD_ATTACH
#define DLL_THREAD_ATTACH
Definition:
compat.h:132
msvcrt_init_exception
void msvcrt_init_exception(void *)
Definition:
dllmain.c:33
reserved
r reserved
Definition:
btrfs.c:3006
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
void
Definition:
nsiface.idl:2307
global_locale
MSVCRT__locale_t global_locale
Definition:
locale.c:1495
MSVCRT__free_locale
void __cdecl MSVCRT__free_locale(MSVCRT__locale_t)
Definition:
locale.c:711
msvcrt_free_mt_locks
void msvcrt_free_mt_locks(void)
Definition:
lock.c:77
msvcrt_free_io
void msvcrt_free_io(void)
Definition:
file.c:1100
msvcrt_free_tls_mem
void msvcrt_free_tls_mem(void)
Definition:
tls.c:51
msvcrt_free_tls
BOOL msvcrt_free_tls(void)
Definition:
tls.c:21
msvcrt_free_popen_data
void msvcrt_free_popen_data(void)
Definition:
popen.c:29
TRACE
#define TRACE(s)
Definition:
solgame.cpp:4
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
precomp.h
WINAPI
#define WINAPI
Definition:
msvc.h:6
dll
win32
msvcrt
dllmain.c
Generated on Fri Sep 6 2024 06:14:33 for ReactOS by
1.9.6