Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmsvcrt40.c
Go to the documentation of this file.
00001 /* 00002 * msvcrt40 main file 00003 * 00004 * Copyright (C) 2007 Louis Lenders 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include <stdio.h> 00022 #define _CRT_PRECOMP_H 00023 #include <internal/tls.h> 00024 #include <stdlib.h> 00025 #include <windows.h> 00026 #include <internal/wine/msvcrt.h> 00027 #include <locale.h> 00028 #include <mbctype.h> 00029 00030 #include "wine/debug.h" 00031 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); 00032 00033 /* EXTERNAL PROTOTYPES ********************************************************/ 00034 00035 extern int BlockEnvToEnvironA(void); 00036 extern int BlockEnvToEnvironW(void); 00037 extern void FreeEnvironment(char **environment); 00038 00039 extern unsigned int _osplatform; 00040 extern unsigned int _osver; 00041 extern unsigned int _winminor; 00042 extern unsigned int _winmajor; 00043 extern unsigned int _winver; 00044 00045 extern char* _acmdln; /* pointer to ascii command line */ 00046 extern wchar_t* _wcmdln; /* pointer to wide character command line */ 00047 #undef _environ 00048 extern char** _environ; /* pointer to environment block */ 00049 extern char** __initenv; /* pointer to initial environment block */ 00050 extern wchar_t** _wenviron; /* pointer to environment block */ 00051 extern wchar_t** __winitenv; /* pointer to initial environment block */ 00052 00053 /* LIBRARY ENTRY POINT ********************************************************/ 00054 00055 BOOL 00056 WINAPI 00057 DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved) 00058 { 00059 OSVERSIONINFOW osvi; 00060 switch (dwReason) 00061 { 00062 case DLL_PROCESS_ATTACH: 00063 /* initialize version info */ 00064 TRACE("Process Attach\n"); 00065 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); 00066 GetVersionExW( &osvi ); 00067 _winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion; 00068 _winmajor = osvi.dwMajorVersion; 00069 _winminor = osvi.dwMinorVersion; 00070 _osplatform = osvi.dwPlatformId; 00071 _osver = osvi.dwBuildNumber; 00072 00073 /* create tls stuff */ 00074 if (!msvcrt_init_tls()) 00075 return FALSE; 00076 00077 if (BlockEnvToEnvironA() < 0) 00078 return FALSE; 00079 00080 if (BlockEnvToEnvironW() < 0) 00081 { 00082 FreeEnvironment(_environ); 00083 return FALSE; 00084 } 00085 00086 _acmdln = _strdup(GetCommandLineA()); 00087 _wcmdln = _wcsdup(GetCommandLineW()); 00088 00089 /* Initialization of the WINE code */ 00090 msvcrt_init_mt_locks(); 00091 //if(!msvcrt_init_locale()) { 00092 // msvcrt_free_mt_locks(); 00093 // msvcrt_free_tls_mem(); 00094 // return FALSE; 00095 //} 00096 //msvcrt_init_math(); 00097 msvcrt_init_io(); 00098 //msvcrt_init_console(); 00099 //msvcrt_init_args(); 00100 //msvcrt_init_signals(); 00101 _setmbcp(_MB_CP_LOCALE); 00102 TRACE("Attach done\n"); 00103 break; 00104 00105 case DLL_THREAD_ATTACH: 00106 //msvcrt_get_thread_data creates data when first called 00107 break; 00108 00109 case DLL_THREAD_DETACH: 00110 msvcrt_free_tls_mem(); 00111 break; 00112 00113 case DLL_PROCESS_DETACH: 00114 TRACE("Detach\n"); 00115 /* Deinit of the WINE code */ 00116 msvcrt_free_io(); 00117 msvcrt_free_mt_locks(); 00118 //msvcrt_free_console(); 00119 //msvcrt_free_args(); 00120 //msvcrt_free_signals(); 00121 msvcrt_free_tls_mem(); 00122 if (!msvcrt_free_tls()) 00123 return FALSE; 00124 //MSVCRT__free_locale(MSVCRT_locale); 00125 00126 if (__winitenv && __winitenv != _wenviron) 00127 FreeEnvironment((char**)__winitenv); 00128 if (_wenviron) 00129 FreeEnvironment((char**)_wenviron); 00130 00131 if (__initenv && __initenv != _environ) 00132 FreeEnvironment(__initenv); 00133 if (_environ) 00134 FreeEnvironment(_environ); 00135 00136 TRACE("Detach done\n"); 00137 break; 00138 } 00139 00140 return TRUE; 00141 } 00142 00143 /* EOF */ Generated on Sat May 26 2012 04:23:53 for ReactOS by
1.7.6.1
|