4 * ReactOS MSVCRT.DLL Compatibility Library
6 * THIS SOFTWARE IS NOT COPYRIGHTED
8 * This source code is offered for use in the public domain. You may
9 * use, modify or distribute it freely.
11 * This code is distributed in the hope that it will be useful but
12 * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
13 * DISCLAMED. This includes but is not limited to warrenties of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
22 /* EXTERNAL PROTOTYPES ********************************************************/
24 extern int BlockEnvToEnvironA(void);
25 extern int BlockEnvToEnvironW(void);
26 extern void FreeEnvironment(char **environment
);
28 extern unsigned int _osplatform
;
29 extern unsigned int _osver
;
30 extern unsigned int _winminor
;
31 extern unsigned int _winmajor
;
32 extern unsigned int _winver
;
34 extern char* _acmdln
; /* pointer to ascii command line */
35 extern wchar_t* _wcmdln
; /* pointer to wide character command line */
37 extern char** _environ
; /* pointer to environment block */
38 extern char** __initenv
; /* pointer to initial environment block */
39 extern wchar_t** _wenviron
; /* pointer to environment block */
40 extern wchar_t** __winitenv
; /* pointer to initial environment block */
42 /* LIBRARY ENTRY POINT ********************************************************/
46 DllMain(PVOID hinstDll
, ULONG dwReason
, PVOID reserved
)
51 case DLL_PROCESS_ATTACH
:
52 /* initialize version info */
53 TRACE("Process Attach\n");
54 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOW
);
55 GetVersionExW( &osvi
);
56 _winver
= (osvi
.dwMajorVersion
<< 8) | osvi
.dwMinorVersion
;
57 _winmajor
= osvi
.dwMajorVersion
;
58 _winminor
= osvi
.dwMinorVersion
;
59 _osplatform
= osvi
.dwPlatformId
;
60 _osver
= osvi
.dwBuildNumber
;
62 /* create tls stuff */
63 if (!msvcrt_init_tls())
66 if (BlockEnvToEnvironA() < 0)
69 if (BlockEnvToEnvironW() < 0)
71 FreeEnvironment(_environ
);
75 _acmdln
= _strdup(GetCommandLineA());
76 _wcmdln
= _wcsdup(GetCommandLineW());
78 /* Initialization of the WINE code */
79 msvcrt_init_mt_locks();
82 //msvcrt_init_console();
84 //msvcrt_init_signals();
85 TRACE("Attach done\n");
88 case DLL_THREAD_ATTACH
:
89 //msvcrt_get_thread_data creates data when first called
92 case DLL_THREAD_DETACH
:
93 msvcrt_free_tls_mem();
96 case DLL_PROCESS_DETACH
:
98 /* Deinit of the WINE code */
100 msvcrt_free_mt_locks();
101 //msvcrt_free_console();
102 //msvcrt_free_args();
103 //msvcrt_free_signals();
104 msvcrt_free_tls_mem();
105 if (!msvcrt_free_tls())
108 MSVCRT__free_locale(global_locale
);
110 if (__winitenv
&& __winitenv
!= _wenviron
)
111 FreeEnvironment((char**)__winitenv
);
113 FreeEnvironment((char**)_wenviron
);
115 if (__initenv
&& __initenv
!= _environ
)
116 FreeEnvironment(__initenv
);
118 FreeEnvironment(_environ
);
120 TRACE("Detach done\n");