Jacek Caban : kernel32: Set PEB ConsoleHandle for bare console.

Alexandre Julliard julliard at winehq.org
Thu Aug 13 15:11:52 CDT 2020


Module: wine
Branch: master
Commit: ac94d8890558bcb34d28ee7c2f276bf994faa8a5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ac94d8890558bcb34d28ee7c2f276bf994faa8a5

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Aug 13 16:01:14 2020 +0200

kernel32: Set PEB ConsoleHandle for bare console.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/console.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index c4583d1d9c..e7894e3b02 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -176,9 +176,7 @@ static BOOL restore_console_mode(HANDLE hin)
         close(fd);
     }
 
-    if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle == KERNEL32_CONSOLE_SHELL)
-        TERM_Exit();
-
+    TERM_Exit();
     return ret;
 }
 
@@ -1109,7 +1107,7 @@ BOOL CONSOLE_Init(RTL_USER_PROCESS_PARAMETERS *params)
     memset(&S_termios, 0, sizeof(S_termios));
     if (params->ConsoleHandle == KERNEL32_CONSOLE_SHELL)
     {
-        HANDLE  conin;
+        HANDLE  conin, console;
 
         /* FIXME: to be done even if program is a GUI ? */
         /* This is wine specific: we have no parent (we're started from unix)
@@ -1162,6 +1160,8 @@ BOOL CONSOLE_Init(RTL_USER_PROCESS_PARAMETERS *params)
             }
             SERVER_END_REQ;
         }
+        console = CreateFileW( coninW, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, NULL, OPEN_EXISTING, 0, 0 );
+        if (console != INVALID_HANDLE_VALUE) params->ConsoleHandle = console;
     }
 
     /* convert value from server:




More information about the wine-cvs mailing list