mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:42:57 +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;
|
PSERVICE_GROUP Group = Service->lpGroup;
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
LPCWSTR ErrorLogStrings[2];
|
LPCWSTR ErrorLogStrings[2];
|
||||||
|
WCHAR szErrorBuffer[32];
|
||||||
|
|
||||||
DPRINT("ScmStartService() called\n");
|
DPRINT("ScmStartService() called\n");
|
||||||
|
|
||||||
|
@ -1681,8 +1682,10 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
|
||||||
{
|
{
|
||||||
if (Service->dwErrorControl != SERVICE_ERROR_IGNORE)
|
if (Service->dwErrorControl != SERVICE_ERROR_IGNORE)
|
||||||
{
|
{
|
||||||
|
/* Log a failed service start */
|
||||||
|
swprintf(szErrorBuffer, L"%lu", dwError);
|
||||||
ErrorLogStrings[0] = Service->lpServiceName;
|
ErrorLogStrings[0] = Service->lpServiceName;
|
||||||
ErrorLogStrings[1] = L"Test";
|
ErrorLogStrings[1] = szErrorBuffer;
|
||||||
ScmLogError(EVENT_SERVICE_START_FAILED,
|
ScmLogError(EVENT_SERVICE_START_FAILED,
|
||||||
2,
|
2,
|
||||||
ErrorLogStrings);
|
ErrorLogStrings);
|
||||||
|
|
|
@ -1619,6 +1619,9 @@ DWORD RSetServiceStatus(
|
||||||
LPSERVICE_STATUS lpServiceStatus)
|
LPSERVICE_STATUS lpServiceStatus)
|
||||||
{
|
{
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
|
DWORD dwPreviousState;
|
||||||
|
LPCWSTR lpErrorStrings[2];
|
||||||
|
WCHAR szErrorBuffer[32];
|
||||||
|
|
||||||
DPRINT("RSetServiceStatus() called\n");
|
DPRINT("RSetServiceStatus() called\n");
|
||||||
DPRINT("hServiceStatus = %p\n", hServiceStatus);
|
DPRINT("hServiceStatus = %p\n", hServiceStatus);
|
||||||
|
@ -1668,6 +1671,9 @@ DWORD RSetServiceStatus(
|
||||||
/* Lock the service database exclusively */
|
/* Lock the service database exclusively */
|
||||||
ScmLockDatabaseExclusive();
|
ScmLockDatabaseExclusive();
|
||||||
|
|
||||||
|
/* Save the current service state */
|
||||||
|
dwPreviousState = lpService->Status.dwCurrentState;
|
||||||
|
|
||||||
RtlCopyMemory(&lpService->Status,
|
RtlCopyMemory(&lpService->Status,
|
||||||
lpServiceStatus,
|
lpServiceStatus,
|
||||||
sizeof(SERVICE_STATUS));
|
sizeof(SERVICE_STATUS));
|
||||||
|
@ -1675,6 +1681,22 @@ DWORD RSetServiceStatus(
|
||||||
/* Unlock the service database */
|
/* Unlock the service database */
|
||||||
ScmUnlockDatabase();
|
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("Set %S to %lu\n", lpService->lpDisplayName, lpService->Status.dwCurrentState);
|
||||||
DPRINT("RSetServiceStatus() done\n");
|
DPRINT("RSetServiceStatus() done\n");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue