Commit 38440f56 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Moved initialisation of the console handles to DllMain.

parent c70bf5aa
...@@ -97,6 +97,7 @@ static void thread_detach(void) ...@@ -97,6 +97,7 @@ static void thread_detach(void)
static BOOL process_attach(void) static BOOL process_attach(void)
{ {
SYSTEM_INFO si; SYSTEM_INFO si;
RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
/* FIXME: should probably be done in ntdll */ /* FIXME: should probably be done in ntdll */
GetSystemInfo( &si ); GetSystemInfo( &si );
...@@ -108,6 +109,25 @@ static BOOL process_attach(void) ...@@ -108,6 +109,25 @@ static BOOL process_attach(void)
/* Setup computer name */ /* Setup computer name */
COMPUTERNAME_Init(); COMPUTERNAME_Init();
/* convert value from server:
* + 0 => INVALID_HANDLE_VALUE
* + console handle needs to be mapped
*/
if (!params->hStdInput)
params->hStdInput = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdInput)))
params->hStdInput = console_handle_map(params->hStdInput);
if (!params->hStdOutput)
params->hStdOutput = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdOutput)))
params->hStdOutput = console_handle_map(params->hStdOutput);
if (!params->hStdError)
params->hStdError = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdError)))
params->hStdError = console_handle_map(params->hStdError);
/* copy process information from ntdll */ /* copy process information from ntdll */
ENV_CopyStartupInformation(); ENV_CopyStartupInformation();
...@@ -127,7 +147,7 @@ static BOOL process_attach(void) ...@@ -127,7 +147,7 @@ static BOOL process_attach(void)
/* finish the process initialisation for console bits, if needed */ /* finish the process initialisation for console bits, if needed */
__wine_set_signal_handler(SIGINT, CONSOLE_HandleCtrlC); __wine_set_signal_handler(SIGINT, CONSOLE_HandleCtrlC);
if (NtCurrentTeb()->Peb->ProcessParameters->ConsoleHandle == (HANDLE)1) /* FIXME */ if (params->ConsoleHandle == (HANDLE)1) /* FIXME */
{ {
HMODULE mod = GetModuleHandleA(0); HMODULE mod = GetModuleHandleA(0);
if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
......
...@@ -743,25 +743,6 @@ static BOOL process_init(void) ...@@ -743,25 +743,6 @@ static BOOL process_init(void)
init_windows_dirs(); init_windows_dirs();
init_current_directory( &params->CurrentDirectory ); init_current_directory( &params->CurrentDirectory );
/* convert value from server:
* + 0 => INVALID_HANDLE_VALUE
* + console handle needs to be mapped
*/
if (!params->hStdInput)
params->hStdInput = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdInput)))
params->hStdInput = console_handle_map(params->hStdInput);
if (!params->hStdOutput)
params->hStdOutput = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdOutput)))
params->hStdOutput = console_handle_map(params->hStdOutput);
if (!params->hStdError)
params->hStdError = INVALID_HANDLE_VALUE;
else if (VerifyConsoleIoHandle(console_handle_map(params->hStdError)))
params->hStdError = console_handle_map(params->hStdError);
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment