From 91bc5b5e9488fd674639b7102fb6b973a2b5f299 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 1 Nov 2024 14:43:37 +0100 Subject: [PATCH] [UMPNPMGR] PNP_GetGlobalState returns CM_GLOBAL_STATE_SHUTTING_DOWN on service shutdown --- base/services/umpnpmgr/precomp.h | 1 + base/services/umpnpmgr/rpcserver.c | 3 +++ base/services/umpnpmgr/umpnpmgr.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/base/services/umpnpmgr/precomp.h b/base/services/umpnpmgr/precomp.h index a9dabcc25c813..21c3622d92924 100644 --- a/base/services/umpnpmgr/precomp.h +++ b/base/services/umpnpmgr/precomp.h @@ -88,6 +88,7 @@ RpcServerThread( extern HKEY hEnumKey; extern HKEY hClassKey; extern BOOL g_IsUISuppressed; +extern BOOL g_ShuttingDown; BOOL GetSuppressNewUIValue(VOID); diff --git a/base/services/umpnpmgr/rpcserver.c b/base/services/umpnpmgr/rpcserver.c index db6a474a0f650..ff7a15ac0fbf5 100644 --- a/base/services/umpnpmgr/rpcserver.c +++ b/base/services/umpnpmgr/rpcserver.c @@ -687,6 +687,9 @@ PNP_GetGlobalState( *pulState = CM_GLOBAL_STATE_CAN_DO_UI | CM_GLOBAL_STATE_SERVICES_AVAILABLE; + if (g_ShuttingDown) + *pulState |= CM_GLOBAL_STATE_SHUTTING_DOWN; + return CR_SUCCESS; } diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 14b7c1a9e6fc8..60194bd458d76 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -44,6 +44,7 @@ static SERVICE_STATUS ServiceStatus; HKEY hEnumKey = NULL; HKEY hClassKey = NULL; BOOL g_IsUISuppressed = FALSE; +BOOL g_ShuttingDown = FALSE; /* FUNCTIONS *****************************************************************/ @@ -52,6 +53,9 @@ UpdateServiceStatus( _In_ DWORD dwState, _In_ DWORD dwCheckPoint) { + if ((dwState == SERVICE_STOPPED) || (dwState == SERVICE_STOP_PENDING)) + g_ShuttingDown = TRUE; + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; ServiceStatus.dwCurrentState = dwState; ServiceStatus.dwWin32ExitCode = 0;