| 1 | /* | 
|---|
| 2 | * msvcrt.dll initialisation functions | 
|---|
| 3 | * | 
|---|
| 4 | * Copyright 2000 Jon Griffiths | 
|---|
| 5 | * | 
|---|
| 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. | 
|---|
| 10 | * | 
|---|
| 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. | 
|---|
| 15 | * | 
|---|
| 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 19 | */ | 
|---|
| 20 | #include "msvcrt.h" | 
|---|
| 21 | #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) | 
|---|
| 22 | #include "msvcrt/locale.h" | 
|---|
| 23 | #include "msvcrt/stdio.h" | 
|---|
| 24 |  | 
|---|
| 25 | #include "wine/debug.h" | 
|---|
| 26 |  | 
|---|
| 27 | WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); | 
|---|
| 28 |  | 
|---|
| 29 | /* Index to TLS */ | 
|---|
| 30 | DWORD MSVCRT_tls_index; | 
|---|
| 31 |  | 
|---|
| 32 | static inline BOOL msvcrt_init_tls(void); | 
|---|
| 33 | static inline BOOL msvcrt_free_tls(void); | 
|---|
| 34 | const char* msvcrt_get_reason(DWORD reason) WINE_UNUSED; | 
|---|
| 35 |  | 
|---|
| 36 | typedef void* (*MSVCRT_malloc_func)(unsigned int); | 
|---|
| 37 | typedef void (*MSVCRT_free_func)(void*); | 
|---|
| 38 |  | 
|---|
| 39 | int _CRT_init (void); | 
|---|
| 40 | void _CRT_term (void); | 
|---|
| 41 | void __ctordtorInit (void); | 
|---|
| 42 | void __ctordtorTerm (void); | 
|---|
| 43 |  | 
|---|
| 44 | static HMODULE dllHandle = 0; | 
|---|
| 45 |  | 
|---|
| 46 | BOOL WINAPI MSVCRT40_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | unsigned long _DLL_InitTerm (unsigned long mod_handle, | 
|---|
| 50 | unsigned long flag) | 
|---|
| 51 | { | 
|---|
| 52 | switch (flag) | 
|---|
| 53 | { | 
|---|
| 54 | case 0: | 
|---|
| 55 | if (_CRT_init () != 0) | 
|---|
| 56 | return 0; | 
|---|
| 57 | __ctordtorInit (); | 
|---|
| 58 |  | 
|---|
| 59 | dllHandle = RegisterLxDll(mod_handle, MSVCRT40_Init, 0,0,0,0); | 
|---|
| 60 |  | 
|---|
| 61 | return 1; | 
|---|
| 62 | case 1: | 
|---|
| 63 | __ctordtorTerm (); | 
|---|
| 64 | _CRT_term (); | 
|---|
| 65 |  | 
|---|
| 66 | if(dllHandle) { | 
|---|
| 67 | UnregisterLxDll(dllHandle); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | return 1; | 
|---|
| 71 | default: | 
|---|
| 72 | return 0; | 
|---|
| 73 | } | 
|---|
| 74 | return 1; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | /********************************************************************* | 
|---|
| 78 | *                  Init | 
|---|
| 79 | */ | 
|---|
| 80 | BOOL WINAPI MSVCRT40_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | 
|---|
| 81 | { | 
|---|
| 82 | return MSVCRT_Init(hinstDLL, fdwReason, lpvReserved); | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 |  | 
|---|