Author: ekohl
Date: Sun Apr 8 22:27:44 2012
New Revision: 56338
URL:
http://svn.reactos.org/svn/reactos?rev=56338&view=rev
Log:
[SERVICES]
Log failed service starts and stops.
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/rpcserver.c
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 Apr 8 22:27:44 2012
@@ -1617,6 +1617,7 @@
PSERVICE_GROUP Group = Service->lpGroup;
DWORD dwError = ERROR_SUCCESS;
LPCWSTR ErrorLogStrings[2];
+ WCHAR szErrorBuffer[32];
DPRINT("ScmStartService() called\n");
@@ -1681,8 +1682,10 @@
{
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);
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 Apr 8 22:27:44 2012
@@ -1619,6 +1619,9 @@
LPSERVICE_STATUS lpServiceStatus)
{
PSERVICE lpService;
+ DWORD dwPreviousState;
+ LPCWSTR lpErrorStrings[2];
+ WCHAR szErrorBuffer[32];
DPRINT("RSetServiceStatus() called\n");
DPRINT("hServiceStatus = %p\n", hServiceStatus);
@@ -1668,12 +1671,31 @@
/* Lock the service database exclusively */
ScmLockDatabaseExclusive();
+ /* Save the current service state */
+ dwPreviousState = lpService->Status.dwCurrentState;
+
RtlCopyMemory(&lpService->Status,
lpServiceStatus,
sizeof(SERVICE_STATUS));
/* 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");