[WUAUSERV] Improve some DPRINTs

This commit is contained in:
Hermès Bélusca-Maïto 2024-10-10 22:44:46 +02:00
parent 176de8bd25
commit 016e7bb968
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -40,9 +40,8 @@ UpdateServiceStatus(DWORD dwState)
if (dwState == SERVICE_RUNNING) if (dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(ServiceStatusHandle, SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
&ServiceStatus); DPRINT1("WU UpdateServiceStatus(%lu) called\n", dwState);
DPRINT1("WU UpdateServiceStatus() called\n");
} }
static DWORD WINAPI static DWORD WINAPI
@ -54,35 +53,34 @@ ServiceControlHandler(DWORD dwControl,
switch (dwControl) switch (dwControl)
{ {
case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_STOP:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_STOP received\n"); DPRINT1("WU ServiceControlHandler(SERVICE_CONTROL_STOP) received\n");
SetEvent(hStopEvent); SetEvent(hStopEvent);
UpdateServiceStatus(SERVICE_STOP_PENDING); UpdateServiceStatus(SERVICE_STOP_PENDING);
return ERROR_SUCCESS; return ERROR_SUCCESS;
case SERVICE_CONTROL_PAUSE: case SERVICE_CONTROL_PAUSE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_PAUSE received\n"); DPRINT1("WU ServiceControlHandler(SERVICE_CONTROL_PAUSE) received\n");
UpdateServiceStatus(SERVICE_PAUSED); UpdateServiceStatus(SERVICE_PAUSED);
return ERROR_SUCCESS; return ERROR_SUCCESS;
case SERVICE_CONTROL_CONTINUE: case SERVICE_CONTROL_CONTINUE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_CONTINUE received\n"); DPRINT1("WU ServiceControlHandler(SERVICE_CONTROL_CONTINUE) received\n");
UpdateServiceStatus(SERVICE_RUNNING); UpdateServiceStatus(SERVICE_RUNNING);
return ERROR_SUCCESS; return ERROR_SUCCESS;
case SERVICE_CONTROL_INTERROGATE: case SERVICE_CONTROL_INTERROGATE:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_INTERROGATE received\n"); DPRINT1("WU ServiceControlHandler(SERVICE_CONTROL_INTERROGATE) received\n");
SetServiceStatus(ServiceStatusHandle, SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
&ServiceStatus);
return ERROR_SUCCESS; return ERROR_SUCCESS;
case SERVICE_CONTROL_SHUTDOWN: case SERVICE_CONTROL_SHUTDOWN:
DPRINT1("WU ServiceControlHandler() SERVICE_CONTROL_SHUTDOWN received\n"); DPRINT1("WU ServiceControlHandler(SERVICE_CONTROL_SHUTDOWN) received\n");
SetEvent(hStopEvent); SetEvent(hStopEvent);
UpdateServiceStatus(SERVICE_STOP_PENDING); UpdateServiceStatus(SERVICE_STOP_PENDING);
return ERROR_SUCCESS; return ERROR_SUCCESS;
default : default :
DPRINT1("WU ServiceControlHandler() Control %lu received\n", dwControl); DPRINT1("WU ServiceControlHandler(Control %lu) received\n", dwControl);
return ERROR_CALL_NOT_IMPLEMENTED; return ERROR_CALL_NOT_IMPLEMENTED;
} }
} }
@ -100,14 +98,14 @@ ServiceMain(DWORD argc, LPTSTR *argv)
NULL); NULL);
if (!ServiceStatusHandle) if (!ServiceStatusHandle)
{ {
DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError()); DPRINT1("RegisterServiceCtrlHandlerExW() failed (Error %lu)\n", GetLastError());
return; return;
} }
hStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL); hStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
if (hStopEvent == NULL) if (hStopEvent == NULL)
{ {
DPRINT1("CreateEvent() failed! (Error %lu)\n", GetLastError()); DPRINT1("CreateEvent() failed (Error %lu)\n", GetLastError());
goto done; goto done;
} }