2 * msvcrt20 implementation
4 * Copyright 2002 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
24 #define _CRT_PRECOMP_H
25 #include <internal/tls.h>
27 //#include <windows.h>
28 #include <internal/wine/msvcrt.h>
29 #include <internal/locale.h>
31 //#include <mbctype.h>
33 #include <wine/debug.h>
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
36 /* EXTERNAL PROTOTYPES ********************************************************/
38 extern int BlockEnvToEnvironA(void);
39 extern int BlockEnvToEnvironW(void);
40 extern void FreeEnvironment(char **environment
);
42 extern unsigned int _osplatform
;
43 extern unsigned int _osver
;
44 extern unsigned int _winminor
;
45 extern unsigned int _winmajor
;
46 extern unsigned int _winver
;
48 extern char* _acmdln
; /* pointer to ascii command line */
49 extern wchar_t* _wcmdln
; /* pointer to wide character command line */
51 extern char** _environ
; /* pointer to environment block */
52 extern char** __initenv
; /* pointer to initial environment block */
53 extern wchar_t** _wenviron
; /* pointer to environment block */
54 extern wchar_t** __winitenv
; /* pointer to initial environment block */
56 extern void CDECL
__getmainargs(int *argc
, char** *argv
, char** *envp
,
57 int expand_wildcards
, int *new_mode
);
58 extern void CDECL
__wgetmainargs(int *argc
, WCHAR
** *wargv
, WCHAR
** *wenvp
,
59 int expand_wildcards
, int *new_mode
);
61 /* LIBRARY ENTRY POINT ********************************************************/
65 DllMain(PVOID hinstDll
, ULONG dwReason
, PVOID reserved
)
70 case DLL_PROCESS_ATTACH
:
71 /* initialize version info */
72 TRACE("Process Attach\n");
73 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOW
);
74 GetVersionExW( &osvi
);
75 _winver
= (osvi
.dwMajorVersion
<< 8) | osvi
.dwMinorVersion
;
76 _winmajor
= osvi
.dwMajorVersion
;
77 _winminor
= osvi
.dwMinorVersion
;
78 _osplatform
= osvi
.dwPlatformId
;
79 _osver
= osvi
.dwBuildNumber
;
81 /* create tls stuff */
82 if (!msvcrt_init_tls())
85 if (BlockEnvToEnvironA() < 0)
88 if (BlockEnvToEnvironW() < 0)
90 FreeEnvironment(_environ
);
94 _acmdln
= _strdup(GetCommandLineA());
95 _wcmdln
= _wcsdup(GetCommandLineW());
97 /* Initialization of the WINE code */
98 msvcrt_init_mt_locks();
101 //msvcrt_init_console();
102 //msvcrt_init_args();
103 //msvcrt_init_signals();
104 TRACE("Attach done\n");
107 case DLL_THREAD_ATTACH
:
108 //msvcrt_get_thread_data creates data when first called
111 case DLL_THREAD_DETACH
:
112 msvcrt_free_tls_mem();
115 case DLL_PROCESS_DETACH
:
117 /* Deinit of the WINE code */
120 msvcrt_free_popen_data();
121 msvcrt_free_mt_locks();
122 //msvcrt_free_console();
123 //msvcrt_free_args();
124 //msvcrt_free_signals();
125 msvcrt_free_tls_mem();
126 if (!msvcrt_free_tls())
129 MSVCRT__free_locale(global_locale
);
131 if (__winitenv
&& __winitenv
!= _wenviron
)
132 FreeEnvironment((char**)__winitenv
);
134 FreeEnvironment((char**)_wenviron
);
136 if (__initenv
&& __initenv
!= _environ
)
137 FreeEnvironment(__initenv
);
139 FreeEnvironment(_environ
);
141 TRACE("Detach done\n");
148 /* LIBRARY EXPORTS ************************************************************/
150 /*********************************************************************
151 * __getmainargs (MSVCRT20.@)
153 * new_mode is not a pointer in msvcrt20.
155 void CDECL
MSVCRT20__getmainargs( int *argc
, char** *argv
, char** *envp
,
156 int expand_wildcards
, int new_mode
)
158 __getmainargs( argc
, argv
, envp
, expand_wildcards
, &new_mode
);
161 /*********************************************************************
162 * __wgetmainargs (MSVCRT20.@)
164 * new_mode is not a pointer in msvcrt20.
166 void CDECL
MSVCRT20__wgetmainargs( int *argc
, WCHAR
** *wargv
, WCHAR
** *wenvp
,
167 int expand_wildcards
, int new_mode
)
169 __wgetmainargs( argc
, wargv
, wenvp
, expand_wildcards
, &new_mode
);