5 * ReactOS MSVCRT.DLL Compatibility Library
7 * THIS SOFTWARE IS NOT COPYRIGHTED
9 * This source code is offered for use in the public domain. You may
10 * use, modify or distribute it freely.
12 * This code is distributed in the hope that it will be useful but
13 * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
14 * DISCLAMED. This includes but is not limited to warrenties of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 #include <internal/wine/msvcrt.h>
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
31 /* EXTERNAL PROTOTYPES ********************************************************/
33 extern int BlockEnvToEnvironA(void);
34 extern int BlockEnvToEnvironW(void);
35 extern void FreeEnvironment(char **environment
);
36 extern void _atexit_cleanup(void);
38 extern unsigned int _osver
;
39 extern unsigned int _winminor
;
40 extern unsigned int _winmajor
;
41 extern unsigned int _winver
;
43 extern char* _acmdln
; /* pointer to ascii command line */
44 extern wchar_t* _wcmdln
; /* pointer to wide character command line */
46 extern char** _environ
; /* pointer to environment block */
47 extern char** __initenv
; /* pointer to initial environment block */
48 extern wchar_t** _wenviron
; /* pointer to environment block */
49 extern wchar_t** __winitenv
; /* pointer to initial environment block */
52 /* LIBRARY GLOBAL VARIABLES ***************************************************/
54 HANDLE hHeap
= NULL
; /* handle for heap */
57 /* LIBRARY ENTRY POINT ********************************************************/
61 DllMain(PVOID hinstDll
, ULONG dwReason
, PVOID reserved
)
66 case DLL_PROCESS_ATTACH
://1
67 /* initialize version info */
68 //DPRINT1("Process Attach %d\n", nAttachCount);
69 //DPRINT1("Process Attach\n");
70 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOW
);
71 GetVersionExW( &osvi
);
72 _winver
= (osvi
.dwMajorVersion
<< 8) | osvi
.dwMinorVersion
;
73 _winmajor
= osvi
.dwMajorVersion
;
74 _winminor
= osvi
.dwMinorVersion
;
75 _osver
= osvi
.dwBuildNumber
;
76 hHeap
= HeapCreate(0, 100000, 0);
80 /* create tls stuff */
81 if (!CreateThreadData())
84 if (BlockEnvToEnvironA() < 0)
87 if (BlockEnvToEnvironW() < 0)
89 FreeEnvironment(_environ
);
93 _acmdln
= _strdup(GetCommandLineA());
94 _wcmdln
= _wcsdup(GetCommandLineW());
96 /* FIXME: more initializations... */
98 /* Initialization of the WINE code */
99 msvcrt_init_mt_locks();
102 //_setmbcp(_MB_CP_LOCALE);
104 TRACE("Attach done\n");
107 case DLL_THREAD_ATTACH
:
110 case DLL_THREAD_DETACH
:
111 FreeThreadData(NULL
);
114 case DLL_PROCESS_DETACH
:
115 //DPRINT1("Detach %d\n", nAttachCount);
116 //DPRINT("Detach\n");
117 /* FIXME: more cleanup... */
118 /* Deinit of the WINE code */
120 msvcrt_free_mt_locks();
125 /* destroy tls stuff */
128 if (__winitenv
&& __winitenv
!= _wenviron
)
129 FreeEnvironment((char**)__winitenv
);
131 FreeEnvironment((char**)_wenviron
);
133 if (__initenv
&& __initenv
!= _environ
)
134 FreeEnvironment(__initenv
);
136 FreeEnvironment(_environ
);
141 TRACE("Detach done\n");