From f12e6016b6882a14b21ee86e708a28179885b630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Wed, 10 Feb 2021 15:09:48 +0100 Subject: [PATCH] [CONSRV] Set 0 as a console leader PID/TID when unsetting it. Instead of whatever is behind the NULL pointer. --- .../user/winsrv/consrv/frontends/gui/conwnd.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c index de9eea6053a..6dc4249dbe8 100644 --- a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c +++ b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c @@ -48,14 +48,25 @@ VOID SetConWndConsoleLeaderCID(IN PGUI_CONSOLE_DATA GuiData) { PCONSOLE_PROCESS_DATA ProcessData; - CLIENT_ID ConsoleLeaderCID; ProcessData = ConSrvGetConsoleLeaderProcess(GuiData->Console); - ConsoleLeaderCID = ProcessData->Process->ClientId; - SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_PID, - (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); - SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_TID, - (LONG_PTR)(ConsoleLeaderCID.UniqueThread)); + + DPRINT("ProcessData: %p, ProcessData->Process %p.\n", ProcessData, ProcessData->Process); + ASSERT(ProcessData != NULL); + + if (ProcessData->Process) + { + CLIENT_ID ConsoleLeaderCID = ProcessData->Process->ClientId; + SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_PID, + (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); + SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_TID, + (LONG_PTR)(ConsoleLeaderCID.UniqueThread)); + } + else + { + SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_PID, 0); + SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_TID, 0); + } } /**************************************************************/