Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendllmain.c
Go to the documentation of this file.
00001 /* 00002 * dllmain.c 00003 * 00004 * ReactOS MSVCRT.DLL Compatibility Library 00005 * 00006 * THIS SOFTWARE IS NOT COPYRIGHTED 00007 * 00008 * This source code is offered for use in the public domain. You may 00009 * use, modify or distribute it freely. 00010 * 00011 * This code is distributed in the hope that it will be useful but 00012 * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY 00013 * DISCLAMED. This includes but is not limited to warrenties of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00015 * 00016 */ 00017 00018 #include <precomp.h> 00019 00020 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); 00021 00022 /* EXTERNAL PROTOTYPES ********************************************************/ 00023 00024 extern int BlockEnvToEnvironA(void); 00025 extern int BlockEnvToEnvironW(void); 00026 extern void FreeEnvironment(char **environment); 00027 00028 extern unsigned int _osplatform; 00029 extern unsigned int _osver; 00030 extern unsigned int _winminor; 00031 extern unsigned int _winmajor; 00032 extern unsigned int _winver; 00033 00034 extern char* _acmdln; /* pointer to ascii command line */ 00035 extern wchar_t* _wcmdln; /* pointer to wide character command line */ 00036 #undef _environ 00037 extern char** _environ; /* pointer to environment block */ 00038 extern char** __initenv; /* pointer to initial environment block */ 00039 extern wchar_t** _wenviron; /* pointer to environment block */ 00040 extern wchar_t** __winitenv; /* pointer to initial environment block */ 00041 00042 /* LIBRARY ENTRY POINT ********************************************************/ 00043 00044 BOOL 00045 WINAPI 00046 DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved) 00047 { 00048 OSVERSIONINFOW osvi; 00049 switch (dwReason) 00050 { 00051 case DLL_PROCESS_ATTACH: 00052 /* initialize version info */ 00053 TRACE("Process Attach\n"); 00054 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); 00055 GetVersionExW( &osvi ); 00056 _winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion; 00057 _winmajor = osvi.dwMajorVersion; 00058 _winminor = osvi.dwMinorVersion; 00059 _osplatform = osvi.dwPlatformId; 00060 _osver = osvi.dwBuildNumber; 00061 00062 /* create tls stuff */ 00063 if (!msvcrt_init_tls()) 00064 return FALSE; 00065 00066 if (BlockEnvToEnvironA() < 0) 00067 return FALSE; 00068 00069 if (BlockEnvToEnvironW() < 0) 00070 { 00071 FreeEnvironment(_environ); 00072 return FALSE; 00073 } 00074 00075 _acmdln = _strdup(GetCommandLineA()); 00076 _wcmdln = _wcsdup(GetCommandLineW()); 00077 00078 /* Initialization of the WINE code */ 00079 msvcrt_init_mt_locks(); 00080 //if(!msvcrt_init_locale()) { 00081 // msvcrt_free_mt_locks(); 00082 // msvcrt_free_tls_mem(); 00083 // return FALSE; 00084 //} 00085 //msvcrt_init_math(); 00086 msvcrt_init_io(); 00087 //msvcrt_init_console(); 00088 //msvcrt_init_args(); 00089 //msvcrt_init_signals(); 00090 _setmbcp(_MB_CP_LOCALE); 00091 TRACE("Attach done\n"); 00092 break; 00093 00094 case DLL_THREAD_ATTACH: 00095 //msvcrt_get_thread_data creates data when first called 00096 break; 00097 00098 case DLL_THREAD_DETACH: 00099 msvcrt_free_tls_mem(); 00100 break; 00101 00102 case DLL_PROCESS_DETACH: 00103 TRACE("Detach\n"); 00104 /* Deinit of the WINE code */ 00105 msvcrt_free_io(); 00106 msvcrt_free_mt_locks(); 00107 //msvcrt_free_console(); 00108 //msvcrt_free_args(); 00109 //msvcrt_free_signals(); 00110 msvcrt_free_tls_mem(); 00111 if (!msvcrt_free_tls()) 00112 return FALSE; 00113 //MSVCRT__free_locale(MSVCRT_locale); 00114 00115 if (__winitenv && __winitenv != _wenviron) 00116 FreeEnvironment((char**)__winitenv); 00117 if (_wenviron) 00118 FreeEnvironment((char**)_wenviron); 00119 00120 if (__initenv && __initenv != _environ) 00121 FreeEnvironment(__initenv); 00122 if (_environ) 00123 FreeEnvironment(_environ); 00124 00125 TRACE("Detach done\n"); 00126 break; 00127 } 00128 00129 return TRUE; 00130 } 00131 00132 /* EOF */ Generated on Sat May 26 2012 04:21:09 for ReactOS by
1.7.6.1
|