https://git.reactos.org/?p=reactos.git;a=commitdiff;h=691a739b0246947938ef5ccc51ef9379d6320671
commit 691a739b0246947938ef5ccc51ef9379d6320671 Author: Eric Kohl <[email protected]> AuthorDate: Sun Mar 20 17:21:45 2022 +0100 Commit: Eric Kohl <[email protected]> CommitDate: Sun Mar 20 17:21:45 2022 +0100 [UMPNPMGR] Improve UpdateServiceStatus() - Set dwCheckPoint - Set dwControlAccepted depending on the service state --- base/services/umpnpmgr/umpnpmgr.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 826efbde66b..67ba42fe82d 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -22,7 +22,7 @@ * FILE: base/services/umpnpmgr/umpnpmgr.c * PURPOSE: User-mode Plug and Play manager * PROGRAMMER: Eric Kohl ([email protected]) - * Herv� Poussineau ([email protected]) + * Hervé Poussineau ([email protected]) * Colin Finck ([email protected]) */ @@ -205,14 +205,20 @@ PnpEventThread(LPVOID lpParameter) static VOID -UpdateServiceStatus(DWORD dwState) +UpdateServiceStatus( + _In_ DWORD dwState, + _In_ DWORD dwCheckPoint) { ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; ServiceStatus.dwCurrentState = dwState; - ServiceStatus.dwControlsAccepted = 0; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwServiceSpecificExitCode = 0; - ServiceStatus.dwCheckPoint = 0; + ServiceStatus.dwCheckPoint = dwCheckPoint; + + if (dwState == SERVICE_RUNNING) + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN; + else + ServiceStatus.dwControlsAccepted = 0; if (dwState == SERVICE_START_PENDING || dwState == SERVICE_STOP_PENDING || @@ -239,19 +245,20 @@ ServiceControlHandler(DWORD dwControl, { case SERVICE_CONTROL_STOP: DPRINT1(" SERVICE_CONTROL_STOP received\n"); + UpdateServiceStatus(SERVICE_STOP_PENDING, 1); /* Stop listening to RPC Messages */ RpcMgmtStopServerListening(NULL); - UpdateServiceStatus(SERVICE_STOPPED); + UpdateServiceStatus(SERVICE_STOPPED, 0); return ERROR_SUCCESS; case SERVICE_CONTROL_PAUSE: DPRINT1(" SERVICE_CONTROL_PAUSE received\n"); - UpdateServiceStatus(SERVICE_PAUSED); + UpdateServiceStatus(SERVICE_PAUSED, 0); return ERROR_SUCCESS; case SERVICE_CONTROL_CONTINUE: DPRINT1(" SERVICE_CONTROL_CONTINUE received\n"); - UpdateServiceStatus(SERVICE_RUNNING); + UpdateServiceStatus(SERVICE_RUNNING, 0); return ERROR_SUCCESS; case SERVICE_CONTROL_INTERROGATE: @@ -262,9 +269,10 @@ ServiceControlHandler(DWORD dwControl, case SERVICE_CONTROL_SHUTDOWN: DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n"); + UpdateServiceStatus(SERVICE_STOP_PENDING, 1); /* Stop listening to RPC Messages */ RpcMgmtStopServerListening(NULL); - UpdateServiceStatus(SERVICE_STOPPED); + UpdateServiceStatus(SERVICE_STOPPED, 0); return ERROR_SUCCESS; default : @@ -365,7 +373,7 @@ ServiceMain(DWORD argc, LPTSTR *argv) return; } - UpdateServiceStatus(SERVICE_START_PENDING); + UpdateServiceStatus(SERVICE_START_PENDING, 1); hThread = CreateThread(NULL, 0, @@ -376,6 +384,8 @@ ServiceMain(DWORD argc, LPTSTR *argv) if (hThread != NULL) CloseHandle(hThread); + UpdateServiceStatus(SERVICE_START_PENDING, 2); + hThread = CreateThread(NULL, 0, RpcServerThread, @@ -385,6 +395,8 @@ ServiceMain(DWORD argc, LPTSTR *argv) if (hThread != NULL) CloseHandle(hThread); + UpdateServiceStatus(SERVICE_START_PENDING, 3); + hThread = CreateThread(NULL, 0, DeviceInstallThread, @@ -394,7 +406,7 @@ ServiceMain(DWORD argc, LPTSTR *argv) if (hThread != NULL) CloseHandle(hThread); - UpdateServiceStatus(SERVICE_RUNNING); + UpdateServiceStatus(SERVICE_RUNNING, 0); DPRINT("ServiceMain() done\n"); }
