From b3399c68e9cde2baeb10c36332fc6da421f0caf8 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Fri, 4 Jan 2019 19:38:36 +0200 Subject: [PATCH] [WINSRV] ConSrvConnect: Always store the control dispatcher routine This shouldn't be used only for console applications but can potentially be used by any application to receive shutdown notifications. MSDN provides more information in the documentation for SetConsoleCtrlHandler. Our services.exe also expect to receive shutdown notifications in this way. --- win32ss/user/winsrv/consrv/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win32ss/user/winsrv/consrv/init.c b/win32ss/user/winsrv/consrv/init.c index ab89f7f76e8..eea8cf890f7 100644 --- a/win32ss/user/winsrv/consrv/init.c +++ b/win32ss/user/winsrv/consrv/init.c @@ -428,6 +428,9 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess, return STATUS_UNSUCCESSFUL; } + /* Set Control-Dispatcher handler */ + ProcessData->CtrlRoutine = ConnectInfo->CtrlRoutine; + /* If we don't need a console, then get out of here */ DPRINT("ConnectInfo->IsConsoleApp = %s\n", ConnectInfo->IsConsoleApp ? "True" : "False"); if (!ConnectInfo->IsConsoleApp) return STATUS_SUCCESS; @@ -525,9 +528,8 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess, } } - /* Set the Property-Dialog and Control-Dispatcher handlers */ + /* Set the Property-Dialog handler */ ProcessData->PropRoutine = ConnectInfo->PropRoutine; - ProcessData->CtrlRoutine = ConnectInfo->CtrlRoutine; return STATUS_SUCCESS; }