Author: ekohl
Date: Sun Sep 28 14:10:16 2014
New Revision: 64364
URL:
http://svn.reactos.org/svn/reactos?rev=64364&view=rev
Log:
[SERVICES]
Log service start, control and status change events.
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/base/system/services/services.c
trunk/reactos/base/system/services/services.h
Modified: trunk/reactos/base/system/services/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Sep 28 14:10:16 2014
@@ -1456,6 +1456,19 @@
return dwError;
}
}
+ else
+ {
+ if (dwProcessId != Service->lpImage->dwProcessId)
+ {
+/*
+ LPWSTR Strings[3]
+
+ ScmLogError(EVENT_SERVICE_DIFFERENT_PID_CONNECTED,
+ 3,
+ lpStrings);
+*/
+ }
+ }
DPRINT("ScmWaitForServiceConnect() done\n");
@@ -1578,7 +1591,7 @@
{
PSERVICE_GROUP Group = Service->lpGroup;
DWORD dwError = ERROR_SUCCESS;
- LPCWSTR ErrorLogStrings[2];
+ LPCWSTR lpErrorStrings[2];
WCHAR szErrorBuffer[32];
DPRINT("ScmLoadService() called\n");
@@ -1633,6 +1646,14 @@
{
Group->ServicesRunning = TRUE;
}
+
+ /* Log a successful service start */
+ lpErrorStrings[0] = Service->lpDisplayName;
+ lpErrorStrings[1] = L"start";
+ ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
+ EVENTLOG_INFORMATION_TYPE,
+ 2,
+ lpErrorStrings);
}
else
{
@@ -1640,11 +1661,12 @@
{
/* Log a failed service start */
swprintf(szErrorBuffer, L"%lu", dwError);
- ErrorLogStrings[0] = Service->lpServiceName;
- ErrorLogStrings[1] = szErrorBuffer;
- ScmLogError(EVENT_SERVICE_START_FAILED,
+ lpErrorStrings[0] = Service->lpServiceName;
+ lpErrorStrings[1] = szErrorBuffer;
+ ScmLogEvent(EVENT_SERVICE_START_FAILED,
+ EVENTLOG_ERROR_TYPE,
2,
- ErrorLogStrings);
+ lpErrorStrings);
}
#if 0
Modified: trunk/reactos/base/system/services/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Sep 28 14:10:16 2014
@@ -1085,6 +1085,7 @@
DWORD dwControlsAccepted;
DWORD dwCurrentState;
HKEY hServicesKey = NULL;
+ LPCWSTR lpErrorStrings[2];
DPRINT("RControlService() called\n");
@@ -1240,6 +1241,39 @@
RtlCopyMemory(lpServiceStatus,
&lpService->Status,
sizeof(SERVICE_STATUS));
+ }
+
+ if (dwError == ERROR_SUCCESS)
+ {
+ if (dwControl != SERVICE_CONTROL_INTERROGATE)
+ {
+ /* Log a sucessful send control */
+ lpErrorStrings[0] = lpService->lpDisplayName;
+
+ switch(dwControl)
+ {
+ case SERVICE_CONTROL_STOP:
+ lpErrorStrings[1] = L"stop";
+ break;
+
+ case SERVICE_CONTROL_PAUSE:
+ lpErrorStrings[1] = L"pause";
+ break;
+
+ case SERVICE_CONTROL_CONTINUE:
+ lpErrorStrings[1] = L"continue";
+ break;
+
+ default:
+ lpErrorStrings[1] = L"other";
+ break;
+ }
+
+ ScmLogEvent(EVENT_SERVICE_CONTROL_SUCCESS,
+ EVENTLOG_INFORMATION_TYPE,
+ 2,
+ lpErrorStrings);
+ }
}
return dwError;
@@ -1691,20 +1725,47 @@
/* 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);
- }
+ (dwPreviousState != SERVICE_STOPPED) &&
+ (lpServiceStatus->dwWin32ExitCode != ERROR_SUCCESS))
+ {
+ /* Log a failed service stop */
+ swprintf(szErrorBuffer, L"%lu", lpServiceStatus->dwWin32ExitCode);
+ lpErrorStrings[0] = lpService->lpDisplayName;
+ lpErrorStrings[1] = szErrorBuffer;
+
+ ScmLogEvent(EVENT_SERVICE_EXIT_FAILED,
+ EVENTLOG_ERROR_TYPE,
+ 2,
+ lpErrorStrings);
+ }
+ else if (lpServiceStatus->dwCurrentState != dwPreviousState &&
+ (lpServiceStatus->dwCurrentState == SERVICE_STOPPED ||
+ lpServiceStatus->dwCurrentState == SERVICE_RUNNING ||
+ lpServiceStatus->dwCurrentState == SERVICE_PAUSED))
+ {
+ /* Log a successful service status change */
+ lpErrorStrings[0] = lpService->lpDisplayName;
+
+ switch(lpServiceStatus->dwCurrentState)
+ {
+ case SERVICE_STOPPED:
+ lpErrorStrings[1] = L"stopped";
+ break;
+
+ case SERVICE_RUNNING:
+ lpErrorStrings[1] = L"running";
+ break;
+
+ case SERVICE_PAUSED:
+ lpErrorStrings[1] = L"paused";
+ break;
+ }
+
+ ScmLogEvent(EVENT_SERVICE_STATUS_SUCCESS,
+ EVENTLOG_INFORMATION_TYPE,
+ 2,
+ lpErrorStrings);
}
DPRINT("Set %S to %lu\n", lpService->lpDisplayName,
lpService->Status.dwCurrentState);
Modified: trunk/reactos/base/system/services/services.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sun Sep 28 14:10:16 2014
@@ -53,7 +53,8 @@
VOID
-ScmLogError(DWORD dwEventId,
+ScmLogEvent(DWORD dwEventId,
+ WORD wType,
WORD wStrings,
LPCWSTR *lpStrings)
{
@@ -68,10 +69,10 @@
}
if (!ReportEventW(hLog,
- EVENTLOG_ERROR_TYPE,
+ wType,
0,
dwEventId,
- NULL, // Sid,
+ NULL,
wStrings,
0,
lpStrings,
Modified: trunk/reactos/base/system/services/services.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.h [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sun Sep 28 14:10:16 2014
@@ -175,6 +175,7 @@
/* lock.c */
+
DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
OUT LPSC_RPC_LOCK lpLock);
DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
@@ -190,7 +191,8 @@
/* services.c */
VOID PrintString(LPCSTR fmt, ...);
-VOID ScmLogError(DWORD dwEventId,
+VOID ScmLogEvent(DWORD dwEventId,
+ WORD wType,
WORD wStrings,
LPCWSTR *lpStrings);
VOID ScmWaitForLsa(VOID);