From 38440f561d4dc8a80855460bacea313a895da19b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 13 Jul 2006 14:04:40 +0200 Subject: [PATCH] kernel32: Moved initialisation of the console handles to DllMain. --- dlls/kernel/kernel_main.c | 22 +++++++++++++++++++++- dlls/kernel/process.c | 19 ------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/dlls/kernel/kernel_main.c b/dlls/kernel/kernel_main.c index dea83b2a0c5..f6eeba99ba7 100644 --- a/dlls/kernel/kernel_main.c +++ b/dlls/kernel/kernel_main.c @@ -97,6 +97,7 @@ static void thread_detach(void) static BOOL process_attach(void) { SYSTEM_INFO si; + RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters; /* FIXME: should probably be done in ntdll */ GetSystemInfo( &si ); @@ -108,6 +109,25 @@ static BOOL process_attach(void) /* Setup computer name */ 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 */ ENV_CopyStartupInformation(); @@ -127,7 +147,7 @@ static BOOL process_attach(void) /* finish the process initialisation for console bits, if needed */ __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); if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c index 4a9d01e50e9..389899c9f28 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -743,25 +743,6 @@ static BOOL process_init(void) init_windows_dirs(); init_current_directory( ¶ms->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; }