mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:35:59 +00:00
[SERVICES]
Log failed service starts and stops. svn path=/trunk/; revision=56338
This commit is contained in:
parent
9024e05e55
commit
c22ce87532
2 changed files with 26 additions and 1 deletions
|
@ -1617,6 +1617,7 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
|
|||
PSERVICE_GROUP Group = Service->lpGroup;
|
||||
DWORD dwError = ERROR_SUCCESS;
|
||||
LPCWSTR ErrorLogStrings[2];
|
||||
WCHAR szErrorBuffer[32];
|
||||
|
||||
DPRINT("ScmStartService() called\n");
|
||||
|
||||
|
@ -1681,8 +1682,10 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
|
|||
{
|
||||
if (Service->dwErrorControl != SERVICE_ERROR_IGNORE)
|
||||
{
|
||||
/* Log a failed service start */
|
||||
swprintf(szErrorBuffer, L"%lu", dwError);
|
||||
ErrorLogStrings[0] = Service->lpServiceName;
|
||||
ErrorLogStrings[1] = L"Test";
|
||||
ErrorLogStrings[1] = szErrorBuffer;
|
||||
ScmLogError(EVENT_SERVICE_START_FAILED,
|
||||
2,
|
||||
ErrorLogStrings);
|
||||
|
|
|
@ -1619,6 +1619,9 @@ DWORD RSetServiceStatus(
|
|||
LPSERVICE_STATUS lpServiceStatus)
|
||||
{
|
||||
PSERVICE lpService;
|
||||
DWORD dwPreviousState;
|
||||
LPCWSTR lpErrorStrings[2];
|
||||
WCHAR szErrorBuffer[32];
|
||||
|
||||
DPRINT("RSetServiceStatus() called\n");
|
||||
DPRINT("hServiceStatus = %p\n", hServiceStatus);
|
||||
|
@ -1668,6 +1671,9 @@ DWORD RSetServiceStatus(
|
|||
/* Lock the service database exclusively */
|
||||
ScmLockDatabaseExclusive();
|
||||
|
||||
/* Save the current service state */
|
||||
dwPreviousState = lpService->Status.dwCurrentState;
|
||||
|
||||
RtlCopyMemory(&lpService->Status,
|
||||
lpServiceStatus,
|
||||
sizeof(SERVICE_STATUS));
|
||||
|
@ -1675,6 +1681,22 @@ DWORD RSetServiceStatus(
|
|||
/* Unlock the service database */
|
||||
ScmUnlockDatabase();
|
||||
|
||||
/* Log a failed service stop */
|
||||
if ((lpServiceStatus->dwCurrentState == SERVICE_STOPPED) &&
|
||||
(dwPreviousState != SERVICE_STOPPED))
|
||||
{
|
||||
if (lpServiceStatus->dwWin32ExitCode != ERROR_SUCCESS)
|
||||
{
|
||||
swprintf(szErrorBuffer, L"%lu", lpServiceStatus->dwWin32ExitCode);
|
||||
lpErrorStrings[0] = lpService->lpDisplayName;
|
||||
lpErrorStrings[1] = szErrorBuffer;
|
||||
|
||||
ScmLogError(EVENT_SERVICE_EXIT_FAILED,
|
||||
2,
|
||||
lpErrorStrings);
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState);
|
||||
DPRINT("RSetServiceStatus() done\n");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue