From abaebc22ca1746db578e115e4d58debeb8b63910 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 18 Apr 2009 15:14:49 +0000 Subject: [PATCH] - Partly implement SERVICE_CONFIG_FAILURE_ACTIONS in RQueryServiceConfig2W svn path=/trunk/; revision=40582 --- reactos/base/system/services/rpcserver.c | 57 +++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index f1e33ed2a53..ae7405a00b4 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -4333,6 +4333,8 @@ DWORD RQueryServiceConfig2W( HKEY hServiceKey = NULL; DWORD dwRequiredSize; LPWSTR lpDescription = NULL; + LPWSTR lpFailureCommand = NULL; + LPWSTR lpRebootMessage = NULL; DPRINT("RQueryServiceConfig2W() called\n"); @@ -4397,8 +4399,55 @@ DWORD RQueryServiceConfig2W( } else if (dwInfoLevel & SERVICE_CONFIG_FAILURE_ACTIONS) { + LPWSTR lpStr; + LPSERVICE_FAILURE_ACTIONSW lpFailureActions = (LPSERVICE_FAILURE_ACTIONSW)lpBuffer; + UNIMPLEMENTED; - dwError = ERROR_CALL_NOT_IMPLEMENTED; + + dwError = ScmReadString(hServiceKey, + L"FailureCommand", + &lpFailureCommand); + + dwError = ScmReadString(hServiceKey, + L"RebootMessage", + &lpRebootMessage); + + dwRequiredSize = sizeof(SERVICE_FAILURE_ACTIONSW); + + if (lpFailureCommand) + dwRequiredSize += (wcslen(lpFailureCommand) + 1) * sizeof(WCHAR); + + if (lpRebootMessage) + dwRequiredSize += (wcslen(lpRebootMessage) + 1) * sizeof(WCHAR); + + if (cbBufSize < dwRequiredSize) + { + *pcbBytesNeeded = dwRequiredSize; + dwError = ERROR_INSUFFICIENT_BUFFER; + goto done; + } + + lpFailureActions->cActions = 0; + lpFailureActions->dwResetPeriod = 0; + lpFailureActions->lpCommand = NULL; + lpFailureActions->lpRebootMsg = NULL; + lpFailureActions->lpsaActions = NULL; + + lpStr = (LPWSTR)(lpFailureActions + 1); + if (lpRebootMessage) + { + wcscpy(lpStr, lpRebootMessage); + lpFailureActions->lpRebootMsg = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpRebootMessage); + lpStr += wcslen(lpRebootMessage) + 1; + } + + if (lpFailureCommand) + { + wcscpy(lpStr, lpFailureCommand); + lpFailureActions->lpCommand = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpFailureCommand); + lpStr += wcslen(lpRebootMessage) + 1; + } + dwError = STATUS_SUCCESS; goto done; } @@ -4406,6 +4455,12 @@ done: if (lpDescription != NULL) HeapFree(GetProcessHeap(), 0, lpDescription); + if (lpRebootMessage != NULL) + HeapFree(GetProcessHeap(), 0, lpRebootMessage); + + if (lpFailureCommand != NULL) + HeapFree(GetProcessHeap(), 0, lpFailureCommand); + if (hServiceKey != NULL) RegCloseKey(hServiceKey);