mirror of
https://github.com/reactos/reactos.git
synced 2025-05-09 03:37:08 +00:00
[WMISERV][WUAUSERV] Stop the service if the stop event creation fails.
This commit is contained in:
parent
85917e266a
commit
1f082ecc68
2 changed files with 24 additions and 12 deletions
|
@ -44,7 +44,7 @@ static WCHAR ServiceName[] = L"winmgmt";
|
||||||
|
|
||||||
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
||||||
static SERVICE_STATUS ServiceStatus;
|
static SERVICE_STATUS ServiceStatus;
|
||||||
static HANDLE ShutdownEvent;
|
static HANDLE hStopEvent = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
{
|
{
|
||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
DPRINT1(" SERVICE_CONTROL_STOP received\n");
|
||||||
SetEvent(ShutdownEvent);
|
SetEvent(hStopEvent);
|
||||||
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
|
|
||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
|
||||||
SetEvent(ShutdownEvent);
|
SetEvent(hStopEvent);
|
||||||
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -134,13 +134,19 @@ ServiceMain(DWORD argc, LPTSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShutdownEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
hStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (hStopEvent == NULL)
|
||||||
|
{
|
||||||
|
DPRINT1("CreateEvent() failed! (Error %lu)\n", GetLastError());
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_RUNNING);
|
UpdateServiceStatus(SERVICE_RUNNING);
|
||||||
|
|
||||||
WaitForSingleObject(ShutdownEvent, INFINITE);
|
WaitForSingleObject(hStopEvent, INFINITE);
|
||||||
CloseHandle(ShutdownEvent);
|
CloseHandle(hStopEvent);
|
||||||
|
|
||||||
|
done:
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
UpdateServiceStatus(SERVICE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ static WCHAR ServiceName[] = L"wuauserv";
|
||||||
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
|
||||||
static SERVICE_STATUS ServiceStatus;
|
static SERVICE_STATUS ServiceStatus;
|
||||||
|
|
||||||
static HANDLE exitEvent = NULL;
|
static HANDLE hStopEvent = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ ServiceControlHandler(DWORD 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(exitEvent);
|
SetEvent(hStopEvent);
|
||||||
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ ServiceControlHandler(DWORD dwControl,
|
||||||
|
|
||||||
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(exitEvent);
|
SetEvent(hStopEvent);
|
||||||
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
UpdateServiceStatus(SERVICE_STOP_PENDING);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -104,13 +104,19 @@ ServiceMain(DWORD argc, LPTSTR *argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exitEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
hStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
if (hStopEvent == NULL)
|
||||||
|
{
|
||||||
|
DPRINT1("CreateEvent() failed! (Error %lu)\n", GetLastError());
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateServiceStatus(SERVICE_RUNNING);
|
UpdateServiceStatus(SERVICE_RUNNING);
|
||||||
|
|
||||||
WaitForSingleObject(exitEvent, INFINITE);
|
WaitForSingleObject(hStopEvent, INFINITE);
|
||||||
CloseHandle(exitEvent);
|
CloseHandle(hStopEvent);
|
||||||
|
|
||||||
|
done:
|
||||||
UpdateServiceStatus(SERVICE_STOPPED);
|
UpdateServiceStatus(SERVICE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue