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 _osplatform
;
39 extern unsigned int _osver
;
40 extern unsigned int _winminor
;
41 extern unsigned int _winmajor
;
42 extern unsigned int _winver
;
44 extern char* _acmdln
; /* pointer to ascii command line */
45 extern wchar_t* _wcmdln
; /* pointer to wide character command line */
47 extern char** _environ
; /* pointer to environment block */
48 extern char** __initenv
; /* pointer to initial environment block */
49 extern wchar_t** _wenviron
; /* pointer to environment block */
50 extern wchar_t** __winitenv
; /* pointer to initial environment block */
53 /* LIBRARY GLOBAL VARIABLES ***************************************************/
55 HANDLE hHeap
= NULL
; /* handle for heap */
58 /* LIBRARY ENTRY POINT ********************************************************/
62 DllMain(PVOID hinstDll
, ULONG dwReason
, PVOID reserved
)
67 case DLL_PROCESS_ATTACH
://1
68 /* initialize version info */
69 //DPRINT1("Process Attach %d\n", nAttachCount);
70 //DPRINT1("Process Attach\n");
71 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOW
);
72 GetVersionExW( &osvi
);
73 _winver
= (osvi
.dwMajorVersion
<< 8) | osvi
.dwMinorVersion
;
74 _winmajor
= osvi
.dwMajorVersion
;
75 _winminor
= osvi
.dwMinorVersion
;
76 _osplatform
= osvi
.dwPlatformId
;
77 _osver
= osvi
.dwBuildNumber
;
78 hHeap
= HeapCreate(0, 100000, 0);
82 /* create tls stuff */
83 if (!CreateThreadData())
86 if (BlockEnvToEnvironA() < 0)
89 if (BlockEnvToEnvironW() < 0)
91 FreeEnvironment(_environ
);
95 _acmdln
= _strdup(GetCommandLineA());
96 _wcmdln
= _wcsdup(GetCommandLineW());
98 /* FIXME: more initializations... */
100 /* Initialization of the WINE code */
101 msvcrt_init_mt_locks();
104 //_setmbcp(_MB_CP_LOCALE);
106 TRACE("Attach done\n");
109 case DLL_THREAD_ATTACH
:
112 case DLL_THREAD_DETACH
:
113 FreeThreadData(NULL
);
116 case DLL_PROCESS_DETACH
:
117 //DPRINT1("Detach %d\n", nAttachCount);
118 //DPRINT("Detach\n");
119 /* FIXME: more cleanup... */
120 /* Deinit of the WINE code */
122 msvcrt_free_mt_locks();
127 /* destroy tls stuff */
130 if (__winitenv
&& __winitenv
!= _wenviron
)
131 FreeEnvironment((char**)__winitenv
);
133 FreeEnvironment((char**)_wenviron
);
135 if (__initenv
&& __initenv
!= _environ
)
136 FreeEnvironment(__initenv
);
138 FreeEnvironment(_environ
);
143 TRACE("Detach done\n");