mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 12:55:43 +00:00
[CRT] Implement crt_process_init()
This commit is contained in:
parent
8043b76e85
commit
e91f201be2
5 changed files with 76 additions and 76 deletions
|
@ -29,14 +29,10 @@ extern void __getmainargs( int *argc, char ***argv, char ***envp,
|
||||||
|
|
||||||
/* EXTERNAL PROTOTYPES ********************************************************/
|
/* EXTERNAL PROTOTYPES ********************************************************/
|
||||||
|
|
||||||
extern int BlockEnvToEnvironA(void);
|
BOOL crt_process_init(void);
|
||||||
extern int BlockEnvToEnvironW(void);
|
|
||||||
extern void FreeEnvironment(char **environment);
|
extern void FreeEnvironment(char **environment);
|
||||||
|
|
||||||
extern unsigned int _osver;
|
|
||||||
extern unsigned int _winminor;
|
|
||||||
extern unsigned int _winmajor;
|
|
||||||
extern unsigned int _winver;
|
|
||||||
|
|
||||||
unsigned int CRTDLL__basemajor_dll = 0;
|
unsigned int CRTDLL__basemajor_dll = 0;
|
||||||
unsigned int CRTDLL__baseminor_dll = 0;
|
unsigned int CRTDLL__baseminor_dll = 0;
|
||||||
|
@ -48,8 +44,6 @@ unsigned int CRTDLL__osmode_dll = 0;
|
||||||
unsigned int CRTDLL__osversion_dll = 0;
|
unsigned int CRTDLL__osversion_dll = 0;
|
||||||
int _fileinfo_dll;
|
int _fileinfo_dll;
|
||||||
|
|
||||||
extern char* _acmdln; /* pointer to ascii command line */
|
|
||||||
extern wchar_t* _wcmdln; /* pointer to wide character command line */
|
|
||||||
#undef _environ
|
#undef _environ
|
||||||
extern char** _environ; /* pointer to environment block */
|
extern char** _environ; /* pointer to environment block */
|
||||||
extern char** __initenv; /* pointer to initial environment block */
|
extern char** __initenv; /* pointer to initial environment block */
|
||||||
|
@ -112,40 +106,12 @@ DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
||||||
CRTDLL__osmode_dll = 1; /* FIXME */
|
CRTDLL__osmode_dll = 1; /* FIXME */
|
||||||
CRTDLL__osversion_dll = (version & 0xFFFF);
|
CRTDLL__osversion_dll = (version & 0xFFFF);
|
||||||
|
|
||||||
_winmajor = (_osver >> 8) & 0xFF;
|
if (!crt_process_init())
|
||||||
_winminor = _osver & 0xFF;
|
|
||||||
_winver = (_winmajor << 8) + _winminor;
|
|
||||||
_osver = (_osver >> 16) & 0xFFFF;
|
|
||||||
|
|
||||||
/* create tls stuff */
|
|
||||||
if (!msvcrt_init_tls())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (BlockEnvToEnvironA() < 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (BlockEnvToEnvironW() < 0)
|
|
||||||
{
|
{
|
||||||
FreeEnvironment(_environ);
|
ERR("crt_init() failed!\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_acmdln = _strdup(GetCommandLineA());
|
|
||||||
_wcmdln = _wcsdup(GetCommandLineW());
|
|
||||||
|
|
||||||
/* Initialization of the WINE code */
|
|
||||||
msvcrt_init_mt_locks();
|
|
||||||
//if(!msvcrt_init_locale()) {
|
|
||||||
//msvcrt_free_mt_locks();
|
|
||||||
// msvcrt_free_tls_mem();
|
|
||||||
//return FALSE;
|
|
||||||
//}
|
|
||||||
//msvcrt_init_math();
|
|
||||||
msvcrt_init_io();
|
|
||||||
//msvcrt_init_console();
|
|
||||||
//msvcrt_init_args();
|
|
||||||
//msvcrt_init_signals();
|
|
||||||
_setmbcp(_MB_CP_LOCALE);
|
|
||||||
TRACE("Attach done\n");
|
TRACE("Attach done\n");
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
|
|
|
@ -21,18 +21,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
||||||
|
|
||||||
/* EXTERNAL PROTOTYPES ********************************************************/
|
/* EXTERNAL PROTOTYPES ********************************************************/
|
||||||
|
|
||||||
extern int BlockEnvToEnvironA(void);
|
BOOL crt_process_init(void);
|
||||||
extern int BlockEnvToEnvironW(void);
|
|
||||||
extern void FreeEnvironment(char **environment);
|
extern void FreeEnvironment(char **environment);
|
||||||
|
|
||||||
extern unsigned int _osplatform;
|
|
||||||
extern unsigned int _osver;
|
|
||||||
extern unsigned int _winminor;
|
|
||||||
extern unsigned int _winmajor;
|
|
||||||
extern unsigned int _winver;
|
|
||||||
|
|
||||||
extern char* _acmdln; /* pointer to ascii command line */
|
|
||||||
extern wchar_t* _wcmdln; /* pointer to wide character command line */
|
|
||||||
#undef _environ
|
#undef _environ
|
||||||
extern char** _environ; /* pointer to environment block */
|
extern char** _environ; /* pointer to environment block */
|
||||||
extern char** __initenv; /* pointer to initial environment block */
|
extern char** __initenv; /* pointer to initial environment block */
|
||||||
|
@ -45,43 +37,18 @@ BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOW osvi;
|
|
||||||
switch (dwReason)
|
switch (dwReason)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
/* initialize version info */
|
|
||||||
TRACE("Process Attach\n");
|
TRACE("Process Attach\n");
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
|
||||||
GetVersionExW( &osvi );
|
|
||||||
_winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
|
|
||||||
_winmajor = osvi.dwMajorVersion;
|
|
||||||
_winminor = osvi.dwMinorVersion;
|
|
||||||
_osplatform = osvi.dwPlatformId;
|
|
||||||
_osver = osvi.dwBuildNumber;
|
|
||||||
|
|
||||||
/* create tls stuff */
|
if (!crt_process_init())
|
||||||
if (!msvcrt_init_tls())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (BlockEnvToEnvironA() < 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (BlockEnvToEnvironW() < 0)
|
|
||||||
{
|
{
|
||||||
FreeEnvironment(_environ);
|
ERR("crt_init() failed!\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_acmdln = _strdup(GetCommandLineA());
|
|
||||||
_wcmdln = _wcsdup(GetCommandLineW());
|
|
||||||
|
|
||||||
/* Initialization of the WINE code */
|
|
||||||
msvcrt_init_mt_locks();
|
|
||||||
//msvcrt_init_math();
|
|
||||||
msvcrt_init_io();
|
|
||||||
//msvcrt_init_console();
|
|
||||||
//msvcrt_init_args();
|
|
||||||
//msvcrt_init_signals();
|
|
||||||
TRACE("Attach done\n");
|
TRACE("Attach done\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
59
sdk/lib/crt/misc/crt_init.c
Normal file
59
sdk/lib/crt/misc/crt_init.c
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
|
||||||
|
#include <precomp.h>
|
||||||
|
|
||||||
|
extern int BlockEnvToEnvironA(void);
|
||||||
|
extern int BlockEnvToEnvironW(void);
|
||||||
|
extern void FreeEnvironment(char **environment);
|
||||||
|
|
||||||
|
extern void msvcrt_init_mt_locks(void);
|
||||||
|
extern void msvcrt_init_io(void);
|
||||||
|
|
||||||
|
extern char* _acmdln; /* pointer to ascii command line */
|
||||||
|
extern wchar_t* _wcmdln; /* pointer to wide character command line */
|
||||||
|
#undef _environ
|
||||||
|
extern char** _environ; /* pointer to environment block */
|
||||||
|
extern char** __initenv; /* pointer to initial environment block */
|
||||||
|
extern wchar_t** _wenviron; /* pointer to environment block */
|
||||||
|
extern wchar_t** __winitenv; /* pointer to initial environment block */
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
crt_process_init(void)
|
||||||
|
{
|
||||||
|
OSVERSIONINFOW osvi;
|
||||||
|
|
||||||
|
/* initialize version info */
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||||
|
GetVersionExW(&osvi);
|
||||||
|
_winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
|
||||||
|
_winmajor = osvi.dwMajorVersion;
|
||||||
|
_winminor = osvi.dwMinorVersion;
|
||||||
|
_osplatform = osvi.dwPlatformId;
|
||||||
|
_osver = osvi.dwBuildNumber;
|
||||||
|
|
||||||
|
/* create tls stuff */
|
||||||
|
if (!msvcrt_init_tls())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (BlockEnvToEnvironA() < 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (BlockEnvToEnvironW() < 0)
|
||||||
|
{
|
||||||
|
FreeEnvironment(_environ);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
_acmdln = _strdup(GetCommandLineA());
|
||||||
|
_wcmdln = _wcsdup(GetCommandLineW());
|
||||||
|
|
||||||
|
/* Initialization of the WINE code */
|
||||||
|
msvcrt_init_mt_locks();
|
||||||
|
|
||||||
|
//msvcrt_init_math();
|
||||||
|
msvcrt_init_io();
|
||||||
|
//msvcrt_init_console();
|
||||||
|
//msvcrt_init_args();
|
||||||
|
//msvcrt_init_signals();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ list(APPEND CRT_MISC_SOURCE
|
||||||
misc/__crt_MessageBoxA.c
|
misc/__crt_MessageBoxA.c
|
||||||
misc/amsg.c
|
misc/amsg.c
|
||||||
misc/assert.c
|
misc/assert.c
|
||||||
|
misc/crt_init.c
|
||||||
misc/environ.c
|
misc/environ.c
|
||||||
misc/getargs.c
|
misc/getargs.c
|
||||||
misc/i10output.c
|
misc/i10output.c
|
||||||
|
|
|
@ -163,6 +163,7 @@ int __cdecl WinMainCRTStartup (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int __cdecl mainCRTStartup (void);
|
int __cdecl mainCRTStartup (void);
|
||||||
|
BOOL crt_process_init(void);
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
int __mingw_init_ehandler (void);
|
int __mingw_init_ehandler (void);
|
||||||
|
@ -171,6 +172,12 @@ int __mingw_init_ehandler (void);
|
||||||
int __cdecl mainCRTStartup (void)
|
int __cdecl mainCRTStartup (void)
|
||||||
{
|
{
|
||||||
int ret = 255;
|
int ret = 255;
|
||||||
|
#ifndef _DLL
|
||||||
|
if (!crt_process_init())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef __SEH__
|
#ifdef __SEH__
|
||||||
asm ("\t.l_start:\n"
|
asm ("\t.l_start:\n"
|
||||||
"\t.seh_handler __C_specific_handler, @except\n"
|
"\t.seh_handler __C_specific_handler, @except\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue