3 * ReactOS MSVCRT.DLL Compatibility Library
7 #include <msvcrt/internal/tls.h>
8 #include <msvcrt/stdlib.h>
11 #include <msvcrt/msvcrtdbg.h>
13 static int nAttachCount = 0;
15 unsigned int _osver = 0;
16 unsigned int _winminor = 0;
17 unsigned int _winmajor = 0;
18 unsigned int _winver = 0;
20 char *_acmdln = NULL; /* pointer to ascii command line */
22 char **_environ = NULL; /* pointer to environment block */
23 char ***_environ_dll = &_environ;/* pointer to environment block */
25 char **__initenv = NULL;
27 char *_pgmptr = NULL; /* pointer to program name */
29 int __app_type = 0; //_UNKNOWN_APP; /* application type */
33 HANDLE hHeap = NULL; /* handle for heap */
36 /* FUNCTIONS **************************************************************/
38 int BlockEnvToEnviron()
43 DPRINT("BlockEnvToEnviron()\n");
47 FreeEnvironmentStringsA(_environ[0]);
51 ptr2 = ptr = (char*)GetEnvironmentStringsA();
54 DPRINT("GetEnvironmentStringsA() returnd NULL\n");
63 _environ = malloc((len + 1) * sizeof(char*));
66 FreeEnvironmentStringsA(ptr);
69 for (i = 0; i < len && *ptr; i++)
79 DllMain(PVOID hinstDll,
85 case DLL_PROCESS_ATTACH://1
86 /* initialize version info */
87 DPRINT("Attach %d\n", nAttachCount);
88 _osver = GetVersion();
89 _winmajor = (_osver >> 8) & 0xFF;
90 _winminor = _osver & 0xFF;
91 _winver = (_winmajor << 8) + _winminor;
92 _osver = (_osver >> 16) & 0xFFFF;
94 if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
96 hHeap = HeapCreate(0, 0, 0);
97 if (hHeap == NULL || hHeap == INVALID_HANDLE_VALUE)
107 /* create tls stuff */
108 if (!CreateThreadData())
111 _acmdln = (char *)GetCommandLineA();
113 /* FIXME: This crashes all applications */
114 if (BlockEnvToEnviron() < 0)
117 /* FIXME: more initializations... */
120 DPRINT("Attach done\n");
123 case DLL_THREAD_ATTACH://2
126 case DLL_THREAD_DETACH://4
127 FreeThreadData(NULL);
130 case DLL_PROCESS_DETACH://0
131 DPRINT("Detach %d\n", nAttachCount);
132 if (nAttachCount > 0)
136 /* FIXME: more cleanup... */
139 /* destroy tls stuff */
143 if (nAttachCount == 0)
148 FreeEnvironmentStringsA(_environ[0]);
157 DPRINT("Detach done\n");
167 void __set_app_type(int app_type)
169 __app_type = app_type;
173 char **__p__acmdln(void)
178 char ***__p__environ(void)
183 char ***__p___initenv(void)
188 int *__p___mb_cur_max(void)
190 return &__mb_cur_max;
193 unsigned int *__p__osver(void)
198 char **__p__pgmptr(void)
203 unsigned int *__p__winmajor(void)
208 unsigned int *__p__winminor(void)
213 unsigned int *__p__winver(void)