#include <advapi32.h>
-#define NDEBUG
-#include <debug.h>
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(advapi);
+
/* FUNCTIONS *****************************************************************/
-handle_t BindingHandle = NULL;
+handle_t __RPC_USER
+SVCCTL_HANDLEA_bind(SVCCTL_HANDLEA szMachineName)
+{
+ handle_t hBinding = NULL;
+ UCHAR *pszStringBinding;
+ RPC_STATUS status;
-static VOID
-HandleBind(VOID)
+ TRACE("SVCCTL_HANDLEA_bind() called\n");
+
+ status = RpcStringBindingComposeA((UCHAR *)szMachineName,
+ (UCHAR *)"ncacn_np",
+ NULL,
+ (UCHAR *)"\\pipe\\ntsvcs",
+ NULL,
+ (UCHAR **)&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
+ return NULL;
+ }
+
+ /* Set the binding handle that will be used to bind to the server. */
+ status = RpcBindingFromStringBindingA(pszStringBinding,
+ &hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+ }
+
+ status = RpcStringFreeA(&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringFree returned 0x%x\n", status);
+ }
+
+ return hBinding;
+}
+
+
+void __RPC_USER
+SVCCTL_HANDLEA_unbind(SVCCTL_HANDLEA szMachineName,
+ handle_t hBinding)
+{
+ RPC_STATUS status;
+
+ TRACE("SVCCTL_HANDLEA_unbind() called\n");
+
+ status = RpcBindingFree(&hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFree returned 0x%x\n", status);
+ }
+}
+
+
+handle_t __RPC_USER
+SVCCTL_HANDLEW_bind(SVCCTL_HANDLEW szMachineName)
+{
+ handle_t hBinding = NULL;
+ LPWSTR pszStringBinding;
+ RPC_STATUS status;
+
+ TRACE("SVCCTL_HANDLEW_bind() called\n");
+
+ status = RpcStringBindingComposeW(szMachineName,
+ L"ncacn_np",
+ NULL,
+ L"\\pipe\\ntsvcs",
+ NULL,
+ &pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
+ return NULL;
+ }
+
+ /* Set the binding handle that will be used to bind to the server. */
+ status = RpcBindingFromStringBindingW(pszStringBinding,
+ &hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
+ }
+
+ status = RpcStringFreeW(&pszStringBinding);
+ if (status)
+ {
+ ERR("RpcStringFree returned 0x%x\n", status);
+ }
+
+ return hBinding;
+}
+
+
+void __RPC_USER
+SVCCTL_HANDLEW_unbind(SVCCTL_HANDLEW szMachineName,
+ handle_t hBinding)
+{
+ RPC_STATUS status;
+
+ TRACE("SVCCTL_HANDLEW_unbind() called\n");
+
+ status = RpcBindingFree(&hBinding);
+ if (status)
+ {
+ ERR("RpcBindingFree returned 0x%x\n", status);
+ }
+}
+
+
+handle_t __RPC_USER
+RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus)
{
+ handle_t hBinding = NULL;
LPWSTR pszStringBinding;
RPC_STATUS status;
- if (BindingHandle != NULL)
- return;
+ TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n");
status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
&pszStringBinding);
if (status)
{
- DPRINT1("RpcStringBindingCompose returned 0x%x\n", status);
- return;
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
+ return NULL;
}
/* Set the binding handle that will be used to bind to the server. */
status = RpcBindingFromStringBindingW(pszStringBinding,
- &BindingHandle);
+ &hBinding);
if (status)
{
- DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", status);
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeW(&pszStringBinding);
if (status)
{
- DPRINT1("RpcStringFree returned 0x%x\n", status);
+ ERR("RpcStringFree returned 0x%x\n", status);
}
+
+ return hBinding;
}
-#if 0
-static VOID
-HandleUnbind(VOID)
+void __RPC_USER
+RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus,
+ handle_t hBinding)
{
RPC_STATUS status;
- if (BindingHandle == NULL)
- return;
+ TRACE("RPC_SERVICE_STATUS_HANDLE_unbind() called\n");
- status = RpcBindingFree(&BindingHandle);
+ status = RpcBindingFree(&hBinding);
if (status)
{
- DPRINT1("RpcBindingFree returned 0x%x\n", status);
+ ERR("RpcBindingFree returned 0x%x\n", status);
+ }
+}
+
+
+DWORD
+ScmRpcStatusToWinError(RPC_STATUS Status)
+{
+ switch (Status)
+ {
+ case RPC_X_SS_IN_NULL_CONTEXT:
+ return ERROR_INVALID_HANDLE;
+
+ case RPC_X_NULL_REF_POINTER:
+ return ERROR_INVALID_PARAMETER;
+
+ case STATUS_ACCESS_VIOLATION:
+ return ERROR_INVALID_ADDRESS;
+
+ default:
+ return (DWORD)Status;
}
}
-#endif
/**********************************************************************
DWORD dwInfoLevel,
LPVOID lpInfo)
{
- DWORD lpInfoSize;
+ SC_RPC_CONFIG_INFOA Info;
DWORD dwError;
- DPRINT("ChangeServiceConfig2A() called\n");
+ TRACE("ChangeServiceConfig2A() called\n");
- /* Determine the length of the lpInfo parameter */
+ /* Fill relevent field of the Info structure */
+ Info.dwInfoLevel = dwInfoLevel;
switch (dwInfoLevel)
{
case SERVICE_CONFIG_DESCRIPTION:
- lpInfoSize = sizeof(SERVICE_DESCRIPTIONA);
+ Info.psd = (LPSERVICE_DESCRIPTIONA)&lpInfo;
break;
case SERVICE_CONFIG_FAILURE_ACTIONS:
- lpInfoSize = sizeof(SERVICE_FAILURE_ACTIONSA);
+ Info.psfa = (LPSERVICE_FAILURE_ACTIONSA)&lpInfo;
break;
default:
- DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel);
+ WARN("Unknown info level 0x%lx\n", dwInfoLevel);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (lpInfo == NULL)
return TRUE;
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = RChangeServiceConfig2A((SC_RPC_HANDLE)hService,
+ Info);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrChangeServiceConfig2A(BindingHandle,
- (unsigned int)hService,
- dwInfoLevel,
- lpInfo,
- lpInfoSize);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrChangeServiceConfig2A() failed (Error %lu)\n", dwError);
+ ERR("RChangeServiceConfig2A() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DWORD dwInfoLevel,
LPVOID lpInfo)
{
- DWORD lpInfoSize;
+ SC_RPC_CONFIG_INFOW Info;
DWORD dwError;
- DPRINT("ChangeServiceConfig2W() called\n");
+ TRACE("ChangeServiceConfig2W() called\n");
- /* Determine the length of the lpInfo parameter */
+ /* Fill relevent field of the Info structure */
+ Info.dwInfoLevel = dwInfoLevel;
switch (dwInfoLevel)
{
case SERVICE_CONFIG_DESCRIPTION:
- lpInfoSize = sizeof(SERVICE_DESCRIPTIONW);
+ {
+ Info.psd = (LPSERVICE_DESCRIPTIONW)&lpInfo;
break;
+ }
case SERVICE_CONFIG_FAILURE_ACTIONS:
- lpInfoSize = sizeof(SERVICE_FAILURE_ACTIONSW);
+ Info.psfa = (LPSERVICE_FAILURE_ACTIONSW)&lpInfo;
break;
default:
- DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel);
+ WARN("Unknown info level 0x%lx\n", dwInfoLevel);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (lpInfo == NULL)
return TRUE;
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = RChangeServiceConfig2W((SC_RPC_HANDLE)hService,
+ Info);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrChangeServiceConfig2W(BindingHandle,
- (unsigned int)hService,
- dwInfoLevel,
- lpInfo,
- lpInfoSize);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrChangeServiceConfig2W() failed (Error %lu)\n", dwError);
+ ERR("RChangeServiceConfig2W() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DWORD dwLength;
LPSTR lpStr;
- DPRINT("ChangeServiceConfigA() called\n");
+ TRACE("ChangeServiceConfigA() called\n");
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
/* FIXME: Encrypt the password */
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RChangeServiceConfigA((SC_RPC_HANDLE)hService,
+ dwServiceType,
+ dwStartType,
+ dwErrorControl,
+ (LPSTR)lpBinaryPathName,
+ (LPSTR)lpLoadOrderGroup,
+ lpdwTagId,
+ (LPSTR)lpDependencies,
+ dwDependenciesLength,
+ (LPSTR)lpServiceStartName,
+ NULL, /* FIXME: lpPassword */
+ 0, /* FIXME: dwPasswordLength */
+ (LPSTR)lpDisplayName);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrChangeServiceConfigA(BindingHandle,
- (unsigned int)hService,
- dwServiceType,
- dwStartType,
- dwErrorControl,
- (LPSTR)lpBinaryPathName,
- (LPSTR)lpLoadOrderGroup,
- lpdwTagId,
- (LPSTR)lpDependencies,
- dwDependenciesLength,
- (LPSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
- (LPSTR)lpDisplayName);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrChangeServiceConfigA() failed (Error %lu)\n", dwError);
+ ERR("RChangeServiceConfigA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DWORD dwLength;
LPWSTR lpStr;
- DPRINT("ChangeServiceConfigW() called\n");
+ TRACE("ChangeServiceConfigW() called\n");
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
/* FIXME: Encrypt the password */
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RChangeServiceConfigW((SC_RPC_HANDLE)hService,
+ dwServiceType,
+ dwStartType,
+ dwErrorControl,
+ (LPWSTR)lpBinaryPathName,
+ (LPWSTR)lpLoadOrderGroup,
+ lpdwTagId,
+ (LPBYTE)lpDependencies,
+ dwDependenciesLength,
+ (LPWSTR)lpServiceStartName,
+ NULL, /* FIXME: lpPassword */
+ 0, /* FIXME: dwPasswordLength */
+ (LPWSTR)lpDisplayName);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrChangeServiceConfigW(BindingHandle,
- (unsigned int)hService,
- dwServiceType,
- dwStartType,
- dwErrorControl,
- (LPWSTR)lpBinaryPathName,
- (LPWSTR)lpLoadOrderGroup,
- lpdwTagId,
- (LPWSTR)lpDependencies,
- dwDependenciesLength,
- (LPWSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
- (LPWSTR)lpDisplayName);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrChangeServiceConfigW() failed (Error %lu)\n", dwError);
+ ERR("RChangeServiceConfigW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
{
DWORD dwError;
- DPRINT("CloseServiceHandle() called\n");
+ TRACE("CloseServiceHandle() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RCloseServiceHandle((LPSC_RPC_HANDLE)&hSCObject);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrCloseServiceHandle(BindingHandle,
- (unsigned int)hSCObject);
if (dwError)
{
- DPRINT1("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError);
+ ERR("RCloseServiceHandle() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- DPRINT("CloseServiceHandle() done\n");
+ TRACE("CloseServiceHandle() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("ControlService(%x, %x, %p)\n",
+ TRACE("ControlService(%x, %x, %p)\n",
hService, dwControl, lpServiceStatus);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RControlService((SC_RPC_HANDLE)hService,
+ dwControl,
+ lpServiceStatus);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrControlService(BindingHandle,
- (unsigned int)hService,
- dwControl,
- lpServiceStatus);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrControlService() failed (Error %lu)\n", dwError);
+ ERR("RControlService() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- DPRINT("ControlService() done\n");
+ TRACE("ControlService() done\n");
return TRUE;
}
IN DWORD dwInfoLevel,
IN OUT PVOID pControlParams)
{
- DPRINT1("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
+ FIXME("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
hService, dwControl, dwInfoLevel, pControlParams);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
-
/**********************************************************************
* CreateServiceA
*
LPWSTR lpPasswordW = NULL;
DWORD dwDependenciesLength = 0;
DWORD dwLength;
+ int len;
LPSTR lpStr;
- int len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0);
- lpServiceNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpServiceNameW)
+ if (lpServiceName)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0);
+ lpServiceNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpServiceNameW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
- len = MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, NULL, 0);
- lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpDisplayNameW)
+ if (lpDisplayName)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, NULL, 0);
+ lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpDisplayNameW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
- len = MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, NULL, 0);
- lpBinaryPathNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpBinaryPathNameW)
+ if (lpBinaryPathName)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, NULL, 0);
+ lpBinaryPathNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpBinaryPathNameW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpBinaryPathNameW, len);
- len = MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, NULL, 0);
- lpLoadOrderGroupW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpLoadOrderGroupW)
+ if (lpLoadOrderGroup)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, NULL, 0);
+ lpLoadOrderGroupW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpLoadOrderGroupW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
- if (lpDependencies != NULL)
+ if (lpDependencies)
{
lpStr = (LPSTR)lpDependencies;
while (*lpStr)
lpStr = lpStr + dwLength;
}
dwDependenciesLength++;
- }
- lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength * sizeof(WCHAR));
- if (!lpDependenciesW)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength * sizeof(WCHAR));
+ if (!lpDependenciesW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpDependencies, dwDependenciesLength, lpDependenciesW, dwDependenciesLength);
}
- MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW, dwDependenciesLength);
- len = MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, NULL, 0);
- lpServiceStartName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpServiceStartNameW)
+ if (lpServiceStartName)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, NULL, 0);
+ lpServiceStartNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpServiceStartNameW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW, len);
- len = MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, NULL, 0);
- lpPasswordW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!lpPasswordW)
+ if (lpPassword)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ len = MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, NULL, 0);
+ lpPasswordW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!lpPasswordW)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
}
- MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
RetVal = CreateServiceW(hSCManager,
lpServiceNameW,
lpPasswordW);
cleanup:
- HeapFree(GetProcessHeap(), 0, lpServiceNameW);
- HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
- HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
- HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
- HeapFree(GetProcessHeap(), 0, lpDependenciesW);
- HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
- HeapFree(GetProcessHeap(), 0, lpPasswordW);
+ if (lpServiceNameW !=NULL)
+ HeapFree(GetProcessHeap(), 0, lpServiceNameW);
+
+ if (lpDisplayNameW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+
+ if (lpBinaryPathNameW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
+
+ if (lpLoadOrderGroupW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupW);
+
+ if (lpDependenciesW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpDependenciesW);
+
+ if (lpServiceStartNameW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpServiceStartNameW);
+
+ if (lpPasswordW != NULL)
+ HeapFree(GetProcessHeap(), 0, lpPasswordW);
return RetVal;
}
DWORD dwLength;
LPWSTR lpStr;
- DPRINT("CreateServiceW() called\n");
+ TRACE("CreateServiceW() called\n");
/* Calculate the Dependencies length*/
if (lpDependencies != NULL)
lpStr = lpStr + dwLength;
}
dwDependenciesLength++;
+
+ dwDependenciesLength *= sizeof(WCHAR);
}
/* FIXME: Encrypt the password */
- HandleBind();
-
- /* Call to services.exe using RPC */
- dwError = ScmrCreateServiceW(BindingHandle,
- (unsigned int)hSCManager,
- (LPWSTR)lpServiceName,
- (LPWSTR)lpDisplayName,
- dwDesiredAccess,
- dwServiceType,
- dwStartType,
- dwErrorControl,
- (LPWSTR)lpBinaryPathName,
- (LPWSTR)lpLoadOrderGroup,
- lpdwTagId,
- (LPWSTR)lpDependencies,
- dwDependenciesLength,
- (LPWSTR)lpServiceStartName,
- NULL, /* FIXME: lpPassword */
- 0, /* FIXME: dwPasswordLength */
- (unsigned int *)&hService);
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RCreateServiceW((SC_RPC_HANDLE)hSCManager,
+ (LPWSTR)lpServiceName,
+ (LPWSTR)lpDisplayName,
+ dwDesiredAccess,
+ dwServiceType,
+ dwStartType,
+ dwErrorControl,
+ (LPWSTR)lpBinaryPathName,
+ (LPWSTR)lpLoadOrderGroup,
+ lpdwTagId,
+ (LPBYTE)lpDependencies,
+ dwDependenciesLength,
+ (LPWSTR)lpServiceStartName,
+ NULL, /* FIXME: lpPassword */
+ 0, /* FIXME: dwPasswordLength */
+ (SC_RPC_HANDLE *)&hService);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
+
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrCreateServiceW() failed (Error %lu)\n", dwError);
+ ERR("RCreateServiceW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
{
DWORD dwError;
- DPRINT("DeleteService(%x)\n", hService);
+ TRACE("DeleteService(%x)\n", hService);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RDeleteService((SC_RPC_HANDLE)hService);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrDeleteService(BindingHandle,
- (unsigned int)hService);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrDeleteService() failed (Error %lu)\n", dwError);
+ ERR("RDeleteService() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
LPDWORD lpServicesReturned)
{
LPENUM_SERVICE_STATUSA lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusA() called\n");
+ TRACE("EnumServicesStatusA() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = REnumDependentServicesA((SC_RPC_HANDLE)hService,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrEnumDependentServicesA(BindingHandle,
- (unsigned int)hService,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned);
+ if (dwError != ERROR_SUCCESS)
+ {
+ ERR("REnumDependentServicesA() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
lpStatusPtr = (LPENUM_SERVICE_STATUSA)lpServices;
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
lpStatusPtr++;
}
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT("ScmrEnumDependentServicesA() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- DPRINT("EnumDependentServicesA() done\n");
+ TRACE("EnumDependentServicesA() done\n");
return TRUE;
}
LPDWORD lpServicesReturned)
{
LPENUM_SERVICE_STATUSW lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusW() called\n");
+ TRACE("EnumServicesStatusW() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = REnumDependentServicesW((SC_RPC_HANDLE)hService,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrEnumDependentServicesW(BindingHandle,
- (unsigned int)hService,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned);
+ if (dwError != ERROR_SUCCESS)
+ {
+ ERR("REnumDependentServicesW() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
lpStatusPtr = (LPENUM_SERVICE_STATUSW)lpServices;
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
lpStatusPtr++;
}
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT("ScmrEnumDependentServicesW() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- DPRINT("EnumDependentServicesW() done\n");
+ TRACE("EnumDependentServicesW() done\n");
return TRUE;
}
LPDWORD lpResumeHandle,
LPCWSTR lpGroup)
{
- DPRINT1("EnumServiceGroupW is unimplemented\n");
+ FIXME("EnumServiceGroupW is unimplemented\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
LPDWORD lpResumeHandle)
{
LPENUM_SERVICE_STATUSA lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusA() called\n");
+ TRACE("EnumServicesStatusA() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = REnumServicesStatusA((SC_RPC_HANDLE)hSCManager,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrEnumServicesStatusA(BindingHandle,
- (unsigned int)hSCManager,
- dwServiceType,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned,
- lpResumeHandle);
+ if (dwError != ERROR_SUCCESS)
+ {
+ ERR("REnumServicesStatusA() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
lpStatusPtr = (LPENUM_SERVICE_STATUSA)lpServices;
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
lpStatusPtr++;
}
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT("ScmrEnumServicesStatusA() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- DPRINT("EnumServicesStatusA() done\n");
+ TRACE("EnumServicesStatusA() done\n");
return TRUE;
}
LPDWORD lpResumeHandle)
{
LPENUM_SERVICE_STATUSW lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusW() called\n");
+ TRACE("EnumServicesStatusW() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = REnumServicesStatusW((SC_RPC_HANDLE)hSCManager,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrEnumServicesStatusW(BindingHandle,
- (unsigned int)hSCManager,
- dwServiceType,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned,
- lpResumeHandle);
+ if (dwError != ERROR_SUCCESS)
+ {
+ ERR("REnumServicesStatusW() failed (Error %lu)\n", dwError);
+ SetLastError(dwError);
+ return FALSE;
+ }
lpStatusPtr = (LPENUM_SERVICE_STATUSW)lpServices;
for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
lpStatusPtr++;
}
- if (dwError != ERROR_SUCCESS)
- {
- DPRINT("ScmrEnumServicesStatusW() failed (Error %lu)\n", dwError);
- SetLastError(dwError);
- return FALSE;
- }
-
- DPRINT("EnumServicesStatusW() done\n");
+ TRACE("EnumServicesStatusW() done\n");
return TRUE;
}
LPCSTR pszGroupName)
{
LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusExA() called\n");
-
- HandleBind();
+ TRACE("EnumServicesStatusExA() called\n");
- dwError = ScmrEnumServicesStatusExA(BindingHandle,
- (unsigned int)hSCManager,
- (unsigned long)InfoLevel,
- dwServiceType,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned,
- lpResumeHandle,
- (char *)pszGroupName);
+ _SEH_TRY
+ {
+ dwError = REnumServicesStatusExA((SC_RPC_HANDLE)hSCManager,
+ InfoLevel,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle,
+ (LPSTR)pszGroupName);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ if (dwError == ERROR_MORE_DATA)
{
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ WARN("Required buffer size %ul\n", *pcbBytesNeeded);
+ SetLastError(dwError);
+ return FALSE;
+ }
+ else if (dwError == ERROR_SUCCESS)
+ {
+ lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSA)lpServices;
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ {
+ if (lpStatusPtr->lpServiceName)
+ lpStatusPtr->lpServiceName =
+ (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
- if (lpStatusPtr->lpDisplayName)
- lpStatusPtr->lpDisplayName =
- (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
+ if (lpStatusPtr->lpDisplayName)
+ lpStatusPtr->lpDisplayName =
+ (LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
- lpStatusPtr++;
+ lpStatusPtr++;
+ }
}
-
- if (dwError != ERROR_SUCCESS)
+ else
{
- DPRINT1("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError);
+ ERR("REnumServicesStatusExA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- DPRINT("EnumServicesStatusExA() done\n");
+ TRACE("EnumServicesStatusExA() done\n");
return TRUE;
}
LPCWSTR pszGroupName)
{
LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr;
- DWORD dwError = ERROR_SUCCESS;
+ DWORD dwError;
DWORD dwCount;
- DPRINT("EnumServicesStatusExW() called\n");
-
- HandleBind();
+ TRACE("EnumServicesStatusExW() called\n");
- dwError = ScmrEnumServicesStatusExW(BindingHandle,
- (unsigned int)hSCManager,
- (unsigned long)InfoLevel,
- dwServiceType,
- dwServiceState,
- (unsigned char *)lpServices,
- cbBufSize,
- pcbBytesNeeded,
- lpServicesReturned,
- lpResumeHandle,
- (wchar_t *)pszGroupName);
+ _SEH_TRY
+ {
+ dwError = REnumServicesStatusExW((SC_RPC_HANDLE)hSCManager,
+ InfoLevel,
+ dwServiceType,
+ dwServiceState,
+ (LPBYTE)lpServices,
+ cbBufSize,
+ pcbBytesNeeded,
+ lpServicesReturned,
+ lpResumeHandle,
+ (LPWSTR)pszGroupName);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
- for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ if (dwError == ERROR_MORE_DATA)
{
- if (lpStatusPtr->lpServiceName)
- lpStatusPtr->lpServiceName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
+ WARN("Required buffer size %ul\n", *pcbBytesNeeded);
+ SetLastError(dwError);
+ return FALSE;
+ }
+ else if (dwError == ERROR_SUCCESS)
+ {
+ lpStatusPtr = (LPENUM_SERVICE_STATUS_PROCESSW)lpServices;
+ for (dwCount = 0; dwCount < *lpServicesReturned; dwCount++)
+ {
+ if (lpStatusPtr->lpServiceName)
+ lpStatusPtr->lpServiceName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpServiceName);
- if (lpStatusPtr->lpDisplayName)
- lpStatusPtr->lpDisplayName =
- (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
+ if (lpStatusPtr->lpDisplayName)
+ lpStatusPtr->lpDisplayName =
+ (LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
- lpStatusPtr++;
+ lpStatusPtr++;
+ }
}
-
- if (dwError != ERROR_SUCCESS)
+ else
{
- DPRINT1("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError);
+ ERR("REnumServicesStatusExW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- DPRINT("EnumServicesStatusExW() done\n");
+ TRACE("EnumServicesStatusExW() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("GetServiceDisplayNameA() called\n");
+ TRACE("GetServiceDisplayNameA() called\n");
+
+ if (!lpDisplayName)
+ *lpcchBuffer = 0;
+
+ _SEH_TRY
+ {
+ dwError = RGetServiceDisplayNameA((SC_RPC_HANDLE)hSCManager,
+ (LPSTR)lpServiceName,
+ lpDisplayName,
+ lpcchBuffer);
+ }
+ _SEH_HANDLE
+ {
+ /* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+
- HandleBind();
+ _SEH_END;
- dwError = ScmrGetServiceDisplayNameA(BindingHandle,
- (unsigned int)hSCManager,
- (LPSTR)lpServiceName,
- lpDisplayName,
- lpcchBuffer);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrGetServiceDisplayNameA() failed (Error %lu)\n", dwError);
+ ERR("RGetServiceDisplayNameA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- (*lpcchBuffer)--;
-
return TRUE;
}
{
DWORD dwError;
- DPRINT("GetServiceDisplayNameW() called\n");
+ TRACE("GetServiceDisplayNameW() called\n");
+
+ if (!lpDisplayName)
+ *lpcchBuffer = 0;
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = RGetServiceDisplayNameW((SC_RPC_HANDLE)hSCManager,
+ (LPWSTR)lpServiceName,
+ lpDisplayName,
+ lpcchBuffer);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrGetServiceDisplayNameW(BindingHandle,
- (unsigned int)hSCManager,
- (LPWSTR)lpServiceName,
- lpDisplayName,
- lpcchBuffer);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
+ ERR("RGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- (*lpcchBuffer)--;
-
return TRUE;
}
{
DWORD dwError;
- DPRINT("GetServiceKeyNameA() called\n");
+ TRACE("GetServiceKeyNameA() called\n");
+
+ if (!lpServiceName)
+ *lpcchBuffer = 0;
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = RGetServiceKeyNameA((SC_RPC_HANDLE)hSCManager,
+ (LPSTR)lpDisplayName,
+ lpServiceName,
+ lpcchBuffer);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrGetServiceKeyNameA(BindingHandle,
- (unsigned int)hSCManager,
- (LPSTR)lpDisplayName,
- lpServiceName,
- lpcchBuffer);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrGetServiceKeyNameA() failed (Error %lu)\n", dwError);
+ ERR("RGetServiceKeyNameA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- (*lpcchBuffer)--;
-
return TRUE;
}
{
DWORD dwError;
- DPRINT("GetServiceKeyNameW() called\n");
+ TRACE("GetServiceKeyNameW() called\n");
+
+ if (!lpDisplayName)
+ *lpcchBuffer = 0;
- HandleBind();
+ _SEH_TRY
+ {
+ dwError = RGetServiceKeyNameW((SC_RPC_HANDLE)hSCManager,
+ (LPWSTR)lpDisplayName,
+ lpServiceName,
+ lpcchBuffer);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- dwError = ScmrGetServiceKeyNameW(BindingHandle,
- (unsigned int)hSCManager,
- (LPWSTR)lpDisplayName,
- lpServiceName,
- lpcchBuffer);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrGetServiceKeyNameW() failed (Error %lu)\n", dwError);
+ ERR("RGetServiceKeyNameW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
- (*lpcchBuffer)--;
-
return TRUE;
}
SC_LOCK hLock;
DWORD dwError;
- DPRINT("LockServiceDatabase(%x)\n", hSCManager);
+ TRACE("LockServiceDatabase(%x)\n", hSCManager);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RLockServiceDatabase((SC_RPC_HANDLE)hSCManager,
+ (SC_RPC_LOCK *)&hLock);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrLockServiceDatabase(BindingHandle,
- (unsigned int)hSCManager,
- (unsigned int *)&hLock);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError);
+ ERR("RLockServiceDatabase() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
- DPRINT("hLock = %p\n", hLock);
+ TRACE("hLock = %p\n", hLock);
return hLock;
}
{
HANDLE hEvent;
- DPRINT("WaitForSCManager() called\n");
+ TRACE("WaitForSCManager() called\n");
/* Try to open the existing event */
hEvent = OpenEventW(SYNCHRONIZE,
FALSE,
- L"SvcctrlStartEvent_A3725DX");
+ L"SvcctrlStartEvent_A3752DX");
if (hEvent == NULL)
{
if (GetLastError() != ERROR_FILE_NOT_FOUND)
hEvent = CreateEventW(NULL,
TRUE,
FALSE,
- L"SvcctrlStartEvent_A3725DX");
+ L"SvcctrlStartEvent_A3752DX");
if (hEvent == NULL)
{
/* Try to open the existing event again */
hEvent = OpenEventW(SYNCHRONIZE,
FALSE,
- L"SvcctrlStartEvent_A3725DX");
+ L"SvcctrlStartEvent_A3752DX");
if (hEvent == NULL)
return;
}
WaitForSingleObject(hEvent, 180000);
CloseHandle(hEvent);
- DPRINT("ScmWaitForSCManager() done\n");
+ TRACE("ScmWaitForSCManager() done\n");
}
SC_HANDLE hScm = NULL;
DWORD dwError;
- DPRINT("OpenSCManagerA(%s, %s, %lx)\n",
+ TRACE("OpenSCManagerA(%s, %s, %lx)\n",
lpMachineName, lpDatabaseName, dwDesiredAccess);
WaitForSCManager();
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = ROpenSCManagerA((LPSTR)lpMachineName,
+ (LPSTR)lpDatabaseName,
+ dwDesiredAccess,
+ (SC_RPC_HANDLE *)&hScm);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrOpenSCManagerA(BindingHandle,
- (LPSTR)lpMachineName,
- (LPSTR)lpDatabaseName,
- dwDesiredAccess,
- (unsigned int*)&hScm);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError);
+ ERR("ROpenSCManagerA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
- DPRINT("hScm = %p\n", hScm);
+ TRACE("hScm = %p\n", hScm);
return hScm;
}
SC_HANDLE hScm = NULL;
DWORD dwError;
- DPRINT("OpenSCManagerW(%S, %S, %lx)\n",
+ TRACE("OpenSCManagerW(%S, %S, %lx)\n",
lpMachineName, lpDatabaseName, dwDesiredAccess);
WaitForSCManager();
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = ROpenSCManagerW((LPWSTR)lpMachineName,
+ (LPWSTR)lpDatabaseName,
+ dwDesiredAccess,
+ (SC_RPC_HANDLE *)&hScm);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrOpenSCManagerW(BindingHandle,
- (LPWSTR)lpMachineName,
- (LPWSTR)lpDatabaseName,
- dwDesiredAccess,
- (unsigned int*)&hScm);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError);
+ ERR("ROpenSCManagerW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
- DPRINT("hScm = %p\n", hScm);
+ TRACE("hScm = %p\n", hScm);
return hScm;
}
SC_HANDLE hService = NULL;
DWORD dwError;
- DPRINT("OpenServiceA(%p, %s, %lx)\n",
+ TRACE("OpenServiceA(%p, %s, %lx)\n",
hSCManager, lpServiceName, dwDesiredAccess);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = ROpenServiceA((SC_RPC_HANDLE)hSCManager,
+ (LPSTR)lpServiceName,
+ dwDesiredAccess,
+ (SC_RPC_HANDLE *)&hService);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrOpenServiceA(BindingHandle,
- (unsigned int)hSCManager,
- (LPSTR)lpServiceName,
- dwDesiredAccess,
- (unsigned int*)&hService);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrOpenServiceA() failed (Error %lu)\n", dwError);
+ ERR("ROpenServiceA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
- DPRINT("hService = %p\n", hService);
+ TRACE("hService = %p\n", hService);
return hService;
}
SC_HANDLE hService = NULL;
DWORD dwError;
- DPRINT("OpenServiceW(%p, %S, %lx)\n",
+ TRACE("OpenServiceW(%p, %S, %lx)\n",
hSCManager, lpServiceName, dwDesiredAccess);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = ROpenServiceW((SC_RPC_HANDLE)hSCManager,
+ (LPWSTR)lpServiceName,
+ dwDesiredAccess,
+ (SC_RPC_HANDLE *)&hService);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrOpenServiceW(BindingHandle,
- (unsigned int)hSCManager,
- (LPWSTR)lpServiceName,
- dwDesiredAccess,
- (unsigned int*)&hService);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrOpenServiceW() failed (Error %lu)\n", dwError);
+ if (dwError == ERROR_SERVICE_DOES_NOT_EXIST)
+ WARN("ROpenServiceW() failed (Error %lu)\n", dwError);
+ else
+ ERR("ROpenServiceW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return NULL;
}
- DPRINT("hService = %p\n", hService);
+ TRACE("hService = %p\n", hService);
return hService;
}
{
DWORD dwError;
- DPRINT("QueryServiceConfigA(%p, %p, %lu, %p)\n",
+ TRACE("QueryServiceConfigA(%p, %p, %lu, %p)\n",
hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceConfigA((SC_RPC_HANDLE)hService,
+ (LPBYTE)lpServiceConfig,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceConfigA(BindingHandle,
- (unsigned int)hService,
- (unsigned char *)lpServiceConfig,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceConfigA() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceConfigA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
(LPSTR)((ULONG_PTR)lpServiceConfig +
(ULONG_PTR)lpServiceConfig->lpDisplayName);
- DPRINT("QueryServiceConfigA() done\n");
+ TRACE("QueryServiceConfigA() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceConfigW(%p, %p, %lu, %p)\n",
+ TRACE("QueryServiceConfigW(%p, %p, %lu, %p)\n",
hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceConfigW((SC_RPC_HANDLE)hService,
+ (LPBYTE)lpServiceConfig,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceConfigW(BindingHandle,
- (unsigned int)hService,
- (unsigned char *)lpServiceConfig,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceConfigW() failed (Error %lu)\n", dwError);
+ if (dwError == ERROR_INSUFFICIENT_BUFFER)
+ WARN("RQueryServiceConfigW() failed (Error %lu)\n", dwError);
+ else
+ ERR("RQueryServiceConfigW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
(LPWSTR)((ULONG_PTR)lpServiceConfig +
(ULONG_PTR)lpServiceConfig->lpDisplayName);
- DPRINT("QueryServiceConfigW() done\n");
+ TRACE("QueryServiceConfigW() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
+ TRACE("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
hService, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
- HandleBind();
+ if (dwInfoLevel != SERVICE_CONFIG_DESCRIPTION &&
+ dwInfoLevel != SERVICE_CONFIG_FAILURE_ACTIONS)
+ {
+ SetLastError(ERROR_INVALID_LEVEL);
+ return FALSE;
+ }
+
+ if ((lpBuffer == NULL && cbBufSize != 0) ||
+ pcbBytesNeeded == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceConfig2A((SC_RPC_HANDLE)hService,
+ dwInfoLevel,
+ lpBuffer,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceConfig2A(BindingHandle,
- (unsigned int)hService,
- dwInfoLevel,
- (unsigned char *)lpBuffer,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceConfig2A() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceConfig2A() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
break;
default:
- DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel);
+ ERR("Unknown info level 0x%lx\n", dwInfoLevel);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- DPRINT("QueryServiceConfig2A() done\n");
+ TRACE("QueryServiceConfig2A() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
+ TRACE("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
hService, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
- HandleBind();
+ if (dwInfoLevel != SERVICE_CONFIG_DESCRIPTION &&
+ dwInfoLevel != SERVICE_CONFIG_FAILURE_ACTIONS)
+ {
+ SetLastError(ERROR_INVALID_LEVEL);
+ return FALSE;
+ }
+
+ if ((lpBuffer == NULL && cbBufSize != 0) ||
+ pcbBytesNeeded == NULL)
+ {
+ SetLastError(ERROR_INVALID_ADDRESS);
+ return FALSE;
+ }
+
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceConfig2W((SC_RPC_HANDLE)hService,
+ dwInfoLevel,
+ lpBuffer,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceConfig2W(BindingHandle,
- (unsigned int)hService,
- dwInfoLevel,
- (unsigned char *)lpBuffer,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceConfig2W() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceConfig2W() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
break;
default:
- DPRINT1("Unknown info level 0x%lx\n", dwInfoLevel);
+ WARN("Unknown info level 0x%lx\n", dwInfoLevel);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- DPRINT("QueryServiceConfig2W() done\n");
+ TRACE("QueryServiceConfig2W() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceLockStatusA() called\n");
+ TRACE("QueryServiceLockStatusA() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceLockStatusA((SC_RPC_HANDLE)hSCManager,
+ lpLockStatus,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceLockStatusA(BindingHandle,
- (unsigned int)hSCManager,
- (unsigned char *)lpLockStatus,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceLockStatusA() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceLockStatusA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
(LPSTR)((UINT_PTR)lpLockStatus + (UINT_PTR)lpLockStatus->lpLockOwner);
}
- DPRINT("QueryServiceLockStatusA() done\n");
+ TRACE("QueryServiceLockStatusA() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceLockStatusW() called\n");
+ TRACE("QueryServiceLockStatusW() called\n");
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceLockStatusW((SC_RPC_HANDLE)hSCManager,
+ lpLockStatus,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceLockStatusW(BindingHandle,
- (unsigned int)hSCManager,
- (unsigned char *)lpLockStatus,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceLockStatusW() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceLockStatusW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
(LPWSTR)((UINT_PTR)lpLockStatus + (UINT_PTR)lpLockStatus->lpLockOwner);
}
- DPRINT("QueryServiceLockStatusW() done\n");
+ TRACE("QueryServiceLockStatusW() done\n");
return TRUE;
}
{
DWORD dwError;
- DPRINT("QueryServiceObjectSecurity(%p, %lu, %p)\n",
+ TRACE("QueryServiceObjectSecurity(%p, %lu, %p)\n",
hService, dwSecurityInformation, lpSecurityDescriptor);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceObjectSecurity((SC_RPC_HANDLE)hService,
+ dwSecurityInformation,
+ (LPBYTE)lpSecurityDescriptor,
+ cbBufSize,
+ pcbBytesNeeded);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceObjectSecurity(BindingHandle,
- (unsigned int)hService,
- dwSecurityInformation,
- (unsigned char *)lpSecurityDescriptor,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
+ ERR("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
-
/**********************************************************************
- * QueryServiceStatus
+ * SetServiceObjectSecurity
*
* @implemented
*/
BOOL STDCALL
-QueryServiceStatus(SC_HANDLE hService,
- LPSERVICE_STATUS lpServiceStatus)
+SetServiceObjectSecurity(SC_HANDLE hService,
+ SECURITY_INFORMATION dwSecurityInformation,
+ PSECURITY_DESCRIPTOR lpSecurityDescriptor)
{
+ PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
+ ULONG Length;
+ NTSTATUS Status;
DWORD dwError;
- DPRINT("QueryServiceStatus(%p, %p)\n",
- hService, lpServiceStatus);
+ Length = 0;
+ Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
+ SelfRelativeSD,
+ &Length);
+ if (Status != STATUS_BUFFER_TOO_SMALL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
+ if (SelfRelativeSD == NULL)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
+ SelfRelativeSD,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RSetServiceObjectSecurity((SC_RPC_HANDLE)hService,
+ dwSecurityInformation,
+ (LPBYTE)SelfRelativeSD,
+ Length);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- HandleBind();
+ HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceStatus(BindingHandle,
- (unsigned int)hService,
- lpServiceStatus);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError);
+ ERR("RServiceObjectSecurity() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
/**********************************************************************
- * QueryServiceStatusEx
+ * QueryServiceStatus
*
* @implemented
*/
BOOL STDCALL
-QueryServiceStatusEx(SC_HANDLE hService,
- SC_STATUS_TYPE InfoLevel,
- LPBYTE lpBuffer,
- DWORD cbBufSize,
- LPDWORD pcbBytesNeeded)
+QueryServiceStatus(SC_HANDLE hService,
+ LPSERVICE_STATUS lpServiceStatus)
{
DWORD dwError;
- DPRINT("QueryServiceStatusEx() called\n");
+ TRACE("QueryServiceStatus(%p, %p)\n",
+ hService, lpServiceStatus);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceStatus((SC_RPC_HANDLE)hService,
+ lpServiceStatus);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrQueryServiceStatusEx(BindingHandle,
- (unsigned int)hService,
- InfoLevel,
- lpBuffer,
- cbBufSize,
- pcbBytesNeeded);
if (dwError != ERROR_SUCCESS)
{
- DPRINT("ScmrQueryServiceStatusEx() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceStatus() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
/**********************************************************************
- * SetServiceObjectSecurity
+ * QueryServiceStatusEx
*
* @implemented
*/
BOOL STDCALL
-SetServiceObjectSecurity(SC_HANDLE hService,
- SECURITY_INFORMATION dwSecurityInformation,
- PSECURITY_DESCRIPTOR lpSecurityDescriptor)
+QueryServiceStatusEx(SC_HANDLE hService,
+ SC_STATUS_TYPE InfoLevel,
+ LPBYTE lpBuffer,
+ DWORD cbBufSize,
+ LPDWORD pcbBytesNeeded)
{
- PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
- ULONG Length;
- NTSTATUS Status;
DWORD dwError;
- Length = 0;
- Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
- SelfRelativeSD,
- &Length);
- if (Status != STATUS_BUFFER_TOO_SMALL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
+ TRACE("QueryServiceStatusEx() called\n");
- SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
- if (SelfRelativeSD == NULL)
+ _SEH_TRY
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
+ /* Call to services.exe using RPC */
+ dwError = RQueryServiceStatusEx((SC_RPC_HANDLE)hService,
+ InfoLevel,
+ lpBuffer,
+ cbBufSize,
+ pcbBytesNeeded);
}
-
- Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
- SelfRelativeSD,
- &Length);
- if (!NT_SUCCESS(Status))
+ _SEH_HANDLE
{
- HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
}
-
- HandleBind();
-
- /* Call to services.exe using RPC */
- dwError = ScmrSetServiceObjectSecurity(BindingHandle,
- (unsigned int)hService,
- dwSecurityInformation,
- (unsigned char *)SelfRelativeSD,
- Length);
-
- HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
+ _SEH_END;
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
+ ERR("RQueryServiceStatusEx() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DWORD dwNumServiceArgs,
LPCSTR *lpServiceArgVectors)
{
- LPSTR lpBuffer;
- LPSTR lpStr;
DWORD dwError;
- DWORD dwBufSize;
- DWORD i;
-
- dwBufSize = 0;
- for (i = 0; i < dwNumServiceArgs; i++)
- {
- dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
- }
- DPRINT1("dwBufSize: %lu\n", dwBufSize);
- lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
- if (lpBuffer == NULL)
+ _SEH_TRY
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
+ dwError = RStartServiceA((SC_RPC_HANDLE)hService,
+ dwNumServiceArgs,
+ (LPSTRING_PTRSA)lpServiceArgVectors);
}
-
- lpStr = lpBuffer;
- for (i = 0; i < dwNumServiceArgs; i++)
+ _SEH_HANDLE
{
- strcpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (strlen(lpServiceArgVectors[i]) + 1);
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
}
-
- dwError = ScmrStartServiceA(BindingHandle,
- (unsigned int)hService,
- dwNumServiceArgs,
- (unsigned char *)lpBuffer,
- dwBufSize);
-
- HeapFree(GetProcessHeap(), 0, lpBuffer);
+ _SEH_END;
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrStartServiceA() failed (Error %lu)\n", dwError);
+ ERR("RStartServiceA() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DWORD dwNumServiceArgs,
LPCWSTR *lpServiceArgVectors)
{
- LPWSTR lpBuffer;
- LPWSTR lpStr;
DWORD dwError;
- DWORD dwBufSize;
- DWORD i;
- dwBufSize = 0;
- for (i = 0; i < dwNumServiceArgs; i++)
+ _SEH_TRY
{
- dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
+ dwError = RStartServiceW((SC_RPC_HANDLE)hService,
+ dwNumServiceArgs,
+ (LPSTRING_PTRSW)lpServiceArgVectors);
}
- DPRINT1("dwBufSize: %lu\n", dwBufSize);
-
- lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
- if (lpBuffer == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- lpStr = lpBuffer;
- for (i = 0; i < dwNumServiceArgs; i++)
+ _SEH_HANDLE
{
- wcscpy(lpStr, lpServiceArgVectors[i]);
- lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
}
-
- dwError = ScmrStartServiceW(BindingHandle,
- (unsigned int)hService,
- dwNumServiceArgs,
- (unsigned char *)lpBuffer,
- dwBufSize);
-
- HeapFree(GetProcessHeap(), 0, lpBuffer);
+ _SEH_END;
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrStartServiceW() failed (Error %lu)\n", dwError);
+ ERR("RStartServiceW() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
{
DWORD dwError;
- DPRINT("UnlockServiceDatabase(%x)\n", ScLock);
+ TRACE("UnlockServiceDatabase(%x)\n", ScLock);
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RUnlockServiceDatabase((LPSC_RPC_LOCK)&ScLock);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrUnlockServiceDatabase(BindingHandle,
- (unsigned int)ScLock);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError);
+ ERR("RUnlockServiceDatabase() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
{
DWORD dwError;
- DPRINT1("NotifyBootConfigStatus()\n");
+ TRACE("NotifyBootConfigStatus()\n");
- HandleBind();
+ _SEH_TRY
+ {
+ /* Call to services.exe using RPC */
+ dwError = RNotifyBootConfigStatus(NULL,
+ BootAcceptable);
+ }
+ _SEH_HANDLE
+ {
+ dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+ }
+ _SEH_END;
- /* Call to services.exe using RPC */
- dwError = ScmrNotifyBootConfigStatus(BindingHandle,
- BootAcceptable);
if (dwError != ERROR_SUCCESS)
{
- DPRINT1("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
+ ERR("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
-
-void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
-{
- return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
-}
-
-
-void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
-{
- HeapFree(GetProcessHeap(), 0, ptr);
-}
-
/* EOF */