xref: /reactos/sdk/lib/crt/misc/crt_init.c (revision ccef43f3)
1 
2 #include <precomp.h>
3 
4 extern int BlockEnvToEnvironA(void);
5 extern int BlockEnvToEnvironW(void);
6 extern void FreeEnvironment(char **environment);
7 
8 extern BOOL msvcrt_init_heap(void);
9 extern void msvcrt_init_mt_locks(void);
10 extern void msvcrt_init_io(void);
11 
12 extern char* _acmdln;        /* pointer to ascii command line */
13 extern wchar_t* _wcmdln;     /* pointer to wide character command line */
14 #undef _environ
15 extern char** _environ;      /* pointer to environment block */
16 extern char** __initenv;     /* pointer to initial environment block */
17 extern wchar_t** _wenviron;  /* pointer to environment block */
18 extern wchar_t** __winitenv; /* pointer to initial environment block */
19 
20 BOOL
21 crt_process_init(void)
22 {
23     OSVERSIONINFOW osvi;
24 
25     /* initialize version info */
26     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
27     GetVersionExW(&osvi);
28     _winver     = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
29     _winmajor   = osvi.dwMajorVersion;
30     _winminor   = osvi.dwMinorVersion;
31     _osplatform = osvi.dwPlatformId;
32     _osver      = osvi.dwBuildNumber;
33 
34     /* create tls stuff */
35     if (!msvcrt_init_tls())
36         return FALSE;
37 
38     if (!msvcrt_init_heap())
39         return FALSE;
40 
41     if (BlockEnvToEnvironA() < 0)
42         return FALSE;
43 
44     if (BlockEnvToEnvironW() < 0)
45     {
46         FreeEnvironment(_environ);
47         return FALSE;
48     }
49 
50     _acmdln = _strdup(GetCommandLineA());
51     _wcmdln = _wcsdup(GetCommandLineW());
52 
53     /* Initialization of the WINE code */
54     msvcrt_init_mt_locks();
55 
56     //msvcrt_init_math();
57     msvcrt_init_io();
58     //msvcrt_init_console();
59     //msvcrt_init_args();
60     //msvcrt_init_signals();
61 
62     return TRUE;
63 }
64