2005-04-15 22:02:37 +00:00
|
|
|
/*
|
1999-05-19 16:43:30 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/advapi32/service/scm.c
|
|
|
|
* PURPOSE: Service control manager functions
|
|
|
|
* PROGRAMMER: Emanuele Aliberti
|
2005-04-15 22:02:37 +00:00
|
|
|
* Eric Kohl
|
1999-05-19 16:43:30 +00:00
|
|
|
* UPDATE HISTORY:
|
2002-12-27 14:40:03 +00:00
|
|
|
* 19990413 EA created
|
|
|
|
* 19990515 EA
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2000-03-26 22:00:10 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2005-08-05 10:31:28 +00:00
|
|
|
#include <advapi32.h>
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
|
|
|
|
2002-12-27 14:40:03 +00:00
|
|
|
|
2000-03-26 22:00:10 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
1999-05-19 16:43:30 +00:00
|
|
|
|
2005-04-15 22:02:37 +00:00
|
|
|
handle_t BindingHandle = NULL;
|
|
|
|
|
2007-09-11 12:59:38 +00:00
|
|
|
VOID
|
2005-04-15 22:02:37 +00:00
|
|
|
HandleBind(VOID)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
LPWSTR pszStringBinding;
|
|
|
|
RPC_STATUS status;
|
|
|
|
|
|
|
|
if (BindingHandle != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
status = RpcStringBindingComposeW(NULL,
|
|
|
|
L"ncacn_np",
|
|
|
|
NULL,
|
|
|
|
L"\\pipe\\ntsvcs",
|
|
|
|
NULL,
|
|
|
|
&pszStringBinding);
|
|
|
|
if (status)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("RpcStringBindingCompose returned 0x%x\n", status);
|
2005-11-01 13:47:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the binding handle that will be used to bind to the server. */
|
|
|
|
status = RpcBindingFromStringBindingW(pszStringBinding,
|
|
|
|
&BindingHandle);
|
|
|
|
if (status)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
|
2005-11-01 13:47:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status = RpcStringFreeW(&pszStringBinding);
|
|
|
|
if (status)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("RpcStringFree returned 0x%x\n", status);
|
2005-11-01 13:47:40 +00:00
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static VOID
|
|
|
|
HandleUnbind(VOID)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
RPC_STATUS status;
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
if (BindingHandle == NULL)
|
|
|
|
return;
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
status = RpcBindingFree(&BindingHandle);
|
|
|
|
if (status)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("RpcBindingFree returned 0x%x\n", status);
|
2005-11-01 13:47:40 +00:00
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-01-01 10:31:35 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* ChangeServiceConfig2A
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
ChangeServiceConfig2A(SC_HANDLE hService,
|
|
|
|
DWORD dwInfoLevel,
|
|
|
|
LPVOID lpInfo)
|
|
|
|
{
|
|
|
|
DWORD lpInfoSize;
|
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ChangeServiceConfig2A() called\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
/* Determine the length of the lpInfo parameter */
|
|
|
|
switch (dwInfoLevel)
|
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
|
|
|
lpInfoSize = sizeof(SERVICE_DESCRIPTIONA);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SERVICE_CONFIG_FAILURE_ACTIONS:
|
|
|
|
lpInfoSize = sizeof(SERVICE_FAILURE_ACTIONSA);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-08 17:04:39 +00:00
|
|
|
WARN("Unknown info level 0x%lx\n", dwInfoLevel);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpInfo == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrChangeServiceConfig2A(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwInfoLevel,
|
|
|
|
lpInfo,
|
|
|
|
lpInfoSize);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrChangeServiceConfig2A() failed (Error %lu)\n", dwError);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-30 10:29:07 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* ChangeServiceConfig2W
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
ChangeServiceConfig2W(SC_HANDLE hService,
|
|
|
|
DWORD dwInfoLevel,
|
|
|
|
LPVOID lpInfo)
|
|
|
|
{
|
2007-09-07 10:52:43 +00:00
|
|
|
LPBYTE lpSendData = NULL;
|
|
|
|
DWORD dwInfoSize;
|
2005-12-30 10:29:07 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ChangeServiceConfig2W() called\n");
|
2005-12-30 10:29:07 +00:00
|
|
|
|
|
|
|
switch (dwInfoLevel)
|
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
2007-09-07 10:52:43 +00:00
|
|
|
{
|
|
|
|
LPSERVICE_DESCRIPTIONW lpServiceDescription = lpInfo;
|
|
|
|
DWORD dwStringSize;
|
|
|
|
|
|
|
|
dwInfoSize = sizeof(SERVICE_DESCRIPTIONW);
|
|
|
|
dwStringSize = (wcslen(lpServiceDescription->lpDescription) + 1) * sizeof(WCHAR);
|
|
|
|
dwInfoSize += dwStringSize;
|
|
|
|
|
|
|
|
lpSendData = HeapAlloc(GetProcessHeap(), 0, dwInfoSize);
|
|
|
|
if (lpSendData)
|
|
|
|
{
|
|
|
|
LPBYTE pt = lpSendData;
|
|
|
|
|
|
|
|
CopyMemory(pt, lpInfo, sizeof(SERVICE_DESCRIPTIONW));
|
|
|
|
pt += sizeof(SERVICE_DESCRIPTIONW);
|
|
|
|
CopyMemory(pt, lpServiceDescription->lpDescription, dwStringSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-12-31 10:11:58 +00:00
|
|
|
break;
|
2007-09-07 10:52:43 +00:00
|
|
|
}
|
2006-01-01 10:31:35 +00:00
|
|
|
|
2005-12-30 10:29:07 +00:00
|
|
|
case SERVICE_CONFIG_FAILURE_ACTIONS:
|
2007-09-07 10:52:43 +00:00
|
|
|
dwInfoSize = sizeof(SERVICE_FAILURE_ACTIONSW);
|
2005-12-31 10:11:58 +00:00
|
|
|
break;
|
2006-01-01 10:31:35 +00:00
|
|
|
|
2005-12-30 10:29:07 +00:00
|
|
|
default:
|
2008-02-08 17:04:39 +00:00
|
|
|
WARN("Unknown info level 0x%lx\n", dwInfoLevel);
|
2005-12-30 10:29:07 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpInfo == NULL)
|
2007-09-07 10:52:43 +00:00
|
|
|
goto done;
|
2005-12-30 10:29:07 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrChangeServiceConfig2W(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwInfoLevel,
|
2007-09-07 10:52:43 +00:00
|
|
|
lpSendData,
|
|
|
|
dwInfoSize);
|
2005-12-30 10:29:07 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrChangeServiceConfig2W() failed (Error %lu)\n", dwError);
|
2005-12-30 10:29:07 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-12-31 10:11:58 +00:00
|
|
|
|
2007-09-07 10:52:43 +00:00
|
|
|
done:
|
|
|
|
if (lpSendData != NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpSendData);
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ChangeServiceConfig2W() done\n");
|
2007-09-07 10:52:43 +00:00
|
|
|
|
2005-12-31 10:11:58 +00:00
|
|
|
return TRUE;
|
2005-12-30 10:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* ChangeServiceConfigA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
ChangeServiceConfigA(SC_HANDLE hService,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCSTR lpBinaryPathName,
|
|
|
|
LPCSTR lpLoadOrderGroup,
|
|
|
|
LPDWORD lpdwTagId,
|
|
|
|
LPCSTR lpDependencies,
|
|
|
|
LPCSTR lpServiceStartName,
|
|
|
|
LPCSTR lpPassword,
|
|
|
|
LPCSTR lpDisplayName)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwError;
|
|
|
|
DWORD dwDependenciesLength = 0;
|
|
|
|
DWORD dwLength;
|
|
|
|
LPSTR lpStr;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ChangeServiceConfigA() called\n");
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
/* Calculate the Dependencies length*/
|
|
|
|
if (lpDependencies != NULL)
|
|
|
|
{
|
|
|
|
lpStr = (LPSTR)lpDependencies;
|
|
|
|
while (*lpStr)
|
|
|
|
{
|
|
|
|
dwLength = strlen(lpStr) + 1;
|
|
|
|
dwDependenciesLength += dwLength;
|
|
|
|
lpStr = lpStr + dwLength;
|
|
|
|
}
|
|
|
|
dwDependenciesLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Encrypt the password */
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrChangeServiceConfigA() failed (Error %lu)\n", dwError);
|
2005-12-25 14:45:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* ChangeServiceConfigW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-10-23 19:50:05 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-10-23 19:50:05 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
ChangeServiceConfigW(SC_HANDLE hService,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCWSTR lpBinaryPathName,
|
|
|
|
LPCWSTR lpLoadOrderGroup,
|
|
|
|
LPDWORD lpdwTagId,
|
|
|
|
LPCWSTR lpDependencies,
|
|
|
|
LPCWSTR lpServiceStartName,
|
|
|
|
LPCWSTR lpPassword,
|
|
|
|
LPCWSTR lpDisplayName)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-10-23 19:50:05 +00:00
|
|
|
DWORD dwError;
|
|
|
|
DWORD dwDependenciesLength = 0;
|
|
|
|
DWORD dwLength;
|
|
|
|
LPWSTR lpStr;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ChangeServiceConfigW() called\n");
|
2005-10-23 19:50:05 +00:00
|
|
|
|
|
|
|
/* Calculate the Dependencies length*/
|
|
|
|
if (lpDependencies != NULL)
|
|
|
|
{
|
|
|
|
lpStr = (LPWSTR)lpDependencies;
|
|
|
|
while (*lpStr)
|
|
|
|
{
|
|
|
|
dwLength = wcslen(lpStr) + 1;
|
|
|
|
dwDependenciesLength += dwLength;
|
|
|
|
lpStr = lpStr + dwLength;
|
|
|
|
}
|
|
|
|
dwDependenciesLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Encrypt the password */
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrChangeServiceConfigW() failed (Error %lu)\n", dwError);
|
2005-10-23 19:50:05 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* CloseServiceHandle
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-15 22:02:37 +00:00
|
|
|
BOOL STDCALL
|
2002-12-26 17:23:27 +00:00
|
|
|
CloseServiceHandle(SC_HANDLE hSCObject)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
DWORD dwError;
|
2002-12-27 14:40:03 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("CloseServiceHandle() called\n");
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrCloseServiceHandle(BindingHandle,
|
|
|
|
(unsigned int)hSCObject);
|
|
|
|
if (dwError)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("CloseServiceHandle() done\n");
|
2005-04-17 19:56:50 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* ControlService
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-18 19:50:53 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-15 22:02:37 +00:00
|
|
|
BOOL STDCALL
|
2005-11-01 13:47:40 +00:00
|
|
|
ControlService(SC_HANDLE hService,
|
|
|
|
DWORD dwControl,
|
2002-12-27 14:40:03 +00:00
|
|
|
LPSERVICE_STATUS lpServiceStatus)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ControlService(%x, %x, %p)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
hService, dwControl, lpServiceStatus);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrControlService(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwControl,
|
|
|
|
lpServiceStatus);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrControlService() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ControlService() done\n");
|
2005-04-17 11:01:00 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-25 22:06:31 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* ControlServiceEx
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
ControlServiceEx(IN SC_HANDLE hService,
|
|
|
|
IN DWORD dwControl,
|
|
|
|
IN DWORD dwInfoLevel,
|
|
|
|
IN OUT PVOID pControlParams)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
FIXME("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
|
2005-08-25 22:06:31 +00:00
|
|
|
hService, dwControl, dwInfoLevel, pControlParams);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* CreateServiceA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-11-17 13:23:37 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 12:00:13 +00:00
|
|
|
SC_HANDLE STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
CreateServiceA(SC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpServiceName,
|
|
|
|
LPCSTR lpDisplayName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCSTR lpBinaryPathName,
|
|
|
|
LPCSTR lpLoadOrderGroup,
|
|
|
|
LPDWORD lpdwTagId,
|
|
|
|
LPCSTR lpDependencies,
|
|
|
|
LPCSTR lpServiceStartName,
|
|
|
|
LPCSTR lpPassword)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-17 13:23:37 +00:00
|
|
|
SC_HANDLE RetVal = NULL;
|
|
|
|
LPWSTR lpServiceNameW = NULL;
|
|
|
|
LPWSTR lpDisplayNameW = NULL;
|
|
|
|
LPWSTR lpBinaryPathNameW = NULL;
|
|
|
|
LPWSTR lpLoadOrderGroupW = NULL;
|
|
|
|
LPWSTR lpDependenciesW = NULL;
|
|
|
|
LPWSTR lpServiceStartNameW = NULL;
|
|
|
|
LPWSTR lpPasswordW = NULL;
|
2005-11-17 13:45:02 +00:00
|
|
|
DWORD dwDependenciesLength = 0;
|
|
|
|
DWORD dwLength;
|
2006-06-30 17:38:12 +00:00
|
|
|
int len;
|
2005-11-17 13:45:02 +00:00
|
|
|
LPSTR lpStr;
|
2005-11-17 13:23:37 +00:00
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpServiceName)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, NULL, 0);
|
|
|
|
lpServiceNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpServiceNameW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpServiceName, -1, lpServiceNameW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpDisplayName)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, NULL, 0);
|
|
|
|
lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpDisplayNameW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpDisplayName, -1, lpDisplayNameW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpBinaryPathName)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, NULL, 0);
|
|
|
|
lpBinaryPathNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpBinaryPathNameW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
2008-01-13 13:33:28 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpLoadOrderGroup)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, NULL, 0);
|
|
|
|
lpLoadOrderGroupW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpLoadOrderGroupW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpLoadOrderGroup, -1, lpLoadOrderGroupW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpDependencies)
|
2005-11-17 13:45:02 +00:00
|
|
|
{
|
|
|
|
lpStr = (LPSTR)lpDependencies;
|
|
|
|
while (*lpStr)
|
|
|
|
{
|
|
|
|
dwLength = strlen(lpStr) + 1;
|
|
|
|
dwDependenciesLength += dwLength;
|
|
|
|
lpStr = lpStr + dwLength;
|
|
|
|
}
|
|
|
|
dwDependenciesLength++;
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength * sizeof(WCHAR));
|
|
|
|
if (!lpDependenciesW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW, dwDependenciesLength);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpServiceStartName)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, NULL, 0);
|
|
|
|
lpServiceStartName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpServiceStartNameW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpServiceStartName, -1, lpServiceStartNameW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 17:38:12 +00:00
|
|
|
if (lpPassword)
|
2005-11-17 13:23:37 +00:00
|
|
|
{
|
2006-06-30 17:38:12 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, NULL, 0);
|
|
|
|
lpPasswordW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!lpPasswordW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2006-08-30 10:53:37 +00:00
|
|
|
goto cleanup;
|
2006-06-30 17:38:12 +00:00
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
|
2005-11-17 13:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RetVal = CreateServiceW(hSCManager,
|
2005-12-18 19:50:53 +00:00
|
|
|
lpServiceNameW,
|
|
|
|
lpDisplayNameW,
|
|
|
|
dwDesiredAccess,
|
|
|
|
dwServiceType,
|
|
|
|
dwStartType,
|
|
|
|
dwErrorControl,
|
|
|
|
lpBinaryPathNameW,
|
|
|
|
lpLoadOrderGroupW,
|
|
|
|
lpdwTagId,
|
|
|
|
lpDependenciesW,
|
|
|
|
lpServiceStartNameW,
|
|
|
|
lpPasswordW);
|
2005-11-17 13:23:37 +00:00
|
|
|
|
2006-06-30 22:26:19 +00:00
|
|
|
cleanup:
|
2006-08-30 10:53:37 +00:00
|
|
|
if (lpServiceNameW !=NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpServiceNameW);
|
|
|
|
|
2006-06-30 22:26:19 +00:00
|
|
|
if (lpDisplayNameW != NULL)
|
2006-08-30 10:53:37 +00:00
|
|
|
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);
|
2005-11-17 13:23:37 +00:00
|
|
|
|
|
|
|
return RetVal;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* CreateServiceW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-10-23 19:50:05 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-10-09 20:24:00 +00:00
|
|
|
SC_HANDLE STDCALL
|
|
|
|
CreateServiceW(SC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
LPCWSTR lpDisplayName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCWSTR lpBinaryPathName,
|
|
|
|
LPCWSTR lpLoadOrderGroup,
|
|
|
|
LPDWORD lpdwTagId,
|
|
|
|
LPCWSTR lpDependencies,
|
|
|
|
LPCWSTR lpServiceStartName,
|
|
|
|
LPCWSTR lpPassword)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-10-09 20:24:00 +00:00
|
|
|
SC_HANDLE hService = NULL;
|
2005-10-15 19:34:53 +00:00
|
|
|
DWORD dwDependenciesLength = 0;
|
2006-01-01 12:00:13 +00:00
|
|
|
DWORD dwError;
|
2005-10-15 19:34:53 +00:00
|
|
|
DWORD dwLength;
|
|
|
|
LPWSTR lpStr;
|
2005-10-09 20:24:00 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("CreateServiceW() called\n");
|
2005-10-09 20:24:00 +00:00
|
|
|
|
2005-10-15 19:34:53 +00:00
|
|
|
/* Calculate the Dependencies length*/
|
|
|
|
if (lpDependencies != NULL)
|
|
|
|
{
|
|
|
|
lpStr = (LPWSTR)lpDependencies;
|
|
|
|
while (*lpStr)
|
|
|
|
{
|
|
|
|
dwLength = wcslen(lpStr) + 1;
|
|
|
|
dwDependenciesLength += dwLength;
|
|
|
|
lpStr = lpStr + dwLength;
|
|
|
|
}
|
|
|
|
dwDependenciesLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Encrypt the password */
|
|
|
|
|
2005-10-09 20:24:00 +00:00
|
|
|
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,
|
2005-10-23 19:50:05 +00:00
|
|
|
(LPWSTR)lpDependencies,
|
2005-10-15 19:34:53 +00:00
|
|
|
dwDependenciesLength,
|
2005-10-09 20:24:00 +00:00
|
|
|
(LPWSTR)lpServiceStartName,
|
|
|
|
NULL, /* FIXME: lpPassword */
|
|
|
|
0, /* FIXME: dwPasswordLength */
|
2007-12-04 17:21:46 +00:00
|
|
|
(unsigned long *)&hService);
|
2005-10-09 20:24:00 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrCreateServiceW() failed (Error %lu)\n", dwError);
|
2005-10-09 20:24:00 +00:00
|
|
|
SetLastError(dwError);
|
2005-11-25 09:30:09 +00:00
|
|
|
return NULL;
|
2005-10-09 20:24:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return hService;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* DeleteService
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-16 12:50:33 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-15 22:02:37 +00:00
|
|
|
BOOL STDCALL
|
2002-12-26 17:23:27 +00:00
|
|
|
DeleteService(SC_HANDLE hService)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
DWORD dwError;
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("DeleteService(%x)\n", hService);
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrDeleteService(BindingHandle,
|
|
|
|
(unsigned int)hService);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrDeleteService() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumDependentServicesA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 12:00:13 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 12:00:13 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EnumDependentServicesA(SC_HANDLE hService,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSA lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 12:00:13 +00:00
|
|
|
LPENUM_SERVICE_STATUSA lpStatusPtr;
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
DWORD dwCount;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusA() called\n");
|
2006-01-01 12:00:13 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumDependentServicesA(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned);
|
|
|
|
|
|
|
|
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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);
|
|
|
|
|
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumDependentServicesA() failed (Error %lu)\n", dwError);
|
2006-01-01 12:00:13 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumDependentServicesA() done\n");
|
2006-01-01 12:00:13 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumDependentServicesW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 12:00:13 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 12:00:13 +00:00
|
|
|
BOOL STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
EnumDependentServicesW(SC_HANDLE hService,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSW lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 12:00:13 +00:00
|
|
|
LPENUM_SERVICE_STATUSW lpStatusPtr;
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
DWORD dwCount;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusW() called\n");
|
2006-01-01 12:00:13 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumDependentServicesW(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned);
|
|
|
|
|
|
|
|
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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);
|
|
|
|
|
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumDependentServicesW() failed (Error %lu)\n", dwError);
|
2006-01-01 12:00:13 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumDependentServicesW() done\n");
|
2006-01-01 12:00:13 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumServiceGroupW
|
1999-07-22 21:36:37 +00:00
|
|
|
*
|
2003-07-10 15:05:55 +00:00
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
1999-07-26 20:46:40 +00:00
|
|
|
BOOL
|
1999-05-19 16:43:30 +00:00
|
|
|
STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
EnumServiceGroupW(
|
2005-12-25 14:45:30 +00:00
|
|
|
SC_HANDLE hSCManager,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
2006-01-01 12:00:13 +00:00
|
|
|
LPENUM_SERVICE_STATUSW lpServices,
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle,
|
|
|
|
LPCWSTR lpGroup)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
FIXME("EnumServiceGroupW is unimplemented\n");
|
2002-12-27 14:40:03 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumServicesStatusA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 10:31:35 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 10:31:35 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EnumServicesStatusA(SC_HANDLE hSCManager,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSA lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 10:31:35 +00:00
|
|
|
LPENUM_SERVICE_STATUSA lpStatusPtr;
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
DWORD dwCount;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusA() called\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumServicesStatusA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
dwServiceType,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned,
|
|
|
|
lpResumeHandle);
|
|
|
|
|
|
|
|
lpStatusPtr = (LPENUM_SERVICE_STATUSA)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);
|
|
|
|
|
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumServicesStatusA() failed (Error %lu)\n", dwError);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusA() done\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-18 19:50:53 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* EnumServicesStatusW
|
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
2005-12-18 19:50:53 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
EnumServicesStatusW(SC_HANDLE hSCManager,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSW lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle)
|
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
LPENUM_SERVICE_STATUSW lpStatusPtr;
|
2005-12-18 19:50:53 +00:00
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwCount;
|
2005-12-18 19:50:53 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusW() called\n");
|
2005-12-18 19:50:53 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumServicesStatusW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
dwServiceType,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned,
|
|
|
|
lpResumeHandle);
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
lpStatusPtr = (LPENUM_SERVICE_STATUSW)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);
|
|
|
|
|
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
|
|
|
|
2005-12-18 19:50:53 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumServicesStatusW() failed (Error %lu)\n", dwError);
|
2005-12-18 19:50:53 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusW() done\n");
|
2005-12-18 19:50:53 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumServicesStatusExA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 10:31:35 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 10:31:35 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EnumServicesStatusExA(SC_HANDLE hSCManager,
|
|
|
|
SC_ENUM_TYPE InfoLevel,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPBYTE lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle,
|
|
|
|
LPCSTR pszGroupName)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 10:31:35 +00:00
|
|
|
LPENUM_SERVICE_STATUS_PROCESSA lpStatusPtr;
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
DWORD dwCount;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusExA() called\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumServicesStatusExA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(unsigned long)InfoLevel,
|
|
|
|
dwServiceType,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned,
|
|
|
|
lpResumeHandle,
|
|
|
|
(char *)pszGroupName);
|
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
if (dwError == ERROR_MORE_DATA)
|
2006-01-01 10:31:35 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
WARN("Required buffer size %ul\n", *pcbBytesNeeded);
|
2007-07-06 13:53:29 +00:00
|
|
|
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);
|
2006-01-01 10:31:35 +00:00
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
if (lpStatusPtr->lpDisplayName)
|
|
|
|
lpStatusPtr->lpDisplayName =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
|
2006-01-01 10:31:35 +00:00
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
2006-01-01 10:31:35 +00:00
|
|
|
}
|
2007-07-06 13:53:29 +00:00
|
|
|
else
|
2006-01-01 10:31:35 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumServicesStatusExA() failed (Error %lu)\n", dwError);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusExA() done\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* EnumServicesStatusExW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-26 15:06:46 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-26 15:06:46 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
EnumServicesStatusExW(SC_HANDLE hSCManager,
|
|
|
|
SC_ENUM_TYPE InfoLevel,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPBYTE lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle,
|
|
|
|
LPCWSTR pszGroupName)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-26 15:06:46 +00:00
|
|
|
LPENUM_SERVICE_STATUS_PROCESSW lpStatusPtr;
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
DWORD dwCount;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusExW() called\n");
|
2005-12-26 15:06:46 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumServicesStatusExW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(unsigned long)InfoLevel,
|
|
|
|
dwServiceType,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned,
|
|
|
|
lpResumeHandle,
|
|
|
|
(wchar_t *)pszGroupName);
|
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
if (dwError == ERROR_MORE_DATA)
|
2005-12-26 15:06:46 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
WARN("Required buffer size %ul\n", *pcbBytesNeeded);
|
2007-07-06 13:53:29 +00:00
|
|
|
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);
|
2005-12-26 15:06:46 +00:00
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
if (lpStatusPtr->lpDisplayName)
|
|
|
|
lpStatusPtr->lpDisplayName =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServices + (ULONG_PTR)lpStatusPtr->lpDisplayName);
|
2005-12-26 15:06:46 +00:00
|
|
|
|
2007-07-06 13:53:29 +00:00
|
|
|
lpStatusPtr++;
|
|
|
|
}
|
2005-12-26 15:06:46 +00:00
|
|
|
}
|
2007-07-06 13:53:29 +00:00
|
|
|
else
|
2005-12-26 15:06:46 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrEnumServicesStatusExW() failed (Error %lu)\n", dwError);
|
2005-12-26 15:06:46 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("EnumServicesStatusExW() done\n");
|
2005-12-26 15:06:46 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* GetServiceDisplayNameA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
GetServiceDisplayNameA(SC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpServiceName,
|
|
|
|
LPSTR lpDisplayName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("GetServiceDisplayNameA() called\n");
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceDisplayNameA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPSTR)lpServiceName,
|
|
|
|
lpDisplayName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrGetServiceDisplayNameA() failed (Error %lu)\n", dwError);
|
2005-12-25 14:45:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*lpcchBuffer)--;
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* GetServiceDisplayNameW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-10-30 13:13:53 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-10-30 13:13:53 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
GetServiceDisplayNameW(SC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
LPWSTR lpDisplayName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-10-30 13:13:53 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("GetServiceDisplayNameW() called\n");
|
2005-10-30 13:13:53 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceDisplayNameW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpServiceName,
|
|
|
|
lpDisplayName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
|
2005-10-30 13:13:53 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-06 18:21:00 +00:00
|
|
|
(*lpcchBuffer)--;
|
|
|
|
|
2005-10-30 13:13:53 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* GetServiceKeyNameA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
GetServiceKeyNameA(SC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpDisplayName,
|
|
|
|
LPSTR lpServiceName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("GetServiceKeyNameA() called\n");
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceKeyNameA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPSTR)lpDisplayName,
|
|
|
|
lpServiceName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrGetServiceKeyNameA() failed (Error %lu)\n", dwError);
|
2005-12-25 14:45:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*lpcchBuffer)--;
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* GetServiceKeyNameW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-10-30 21:52:23 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-10-30 13:13:53 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
GetServiceKeyNameW(SC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpDisplayName,
|
|
|
|
LPWSTR lpServiceName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-10-30 13:13:53 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("GetServiceKeyNameW() called\n");
|
2005-10-30 13:13:53 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceKeyNameW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpDisplayName,
|
|
|
|
lpServiceName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrGetServiceKeyNameW() failed (Error %lu)\n", dwError);
|
2005-10-30 13:13:53 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-06 18:21:00 +00:00
|
|
|
(*lpcchBuffer)--;
|
|
|
|
|
2005-10-30 13:13:53 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
2005-04-15 22:02:37 +00:00
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* LockServiceDatabase
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-16 12:50:33 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-16 12:50:33 +00:00
|
|
|
SC_LOCK STDCALL
|
2005-04-15 22:02:37 +00:00
|
|
|
LockServiceDatabase(SC_HANDLE hSCManager)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
SC_LOCK hLock;
|
|
|
|
DWORD dwError;
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("LockServiceDatabase(%x)\n", hSCManager);
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrLockServiceDatabase(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(unsigned int *)&hLock);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("hLock = %p\n", hLock);
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return hLock;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 22:02:37 +00:00
|
|
|
static VOID
|
|
|
|
WaitForSCManager(VOID)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
HANDLE hEvent;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("WaitForSCManager() called\n");
|
2005-11-01 13:47:40 +00:00
|
|
|
|
|
|
|
/* Try to open the existing event */
|
|
|
|
hEvent = OpenEventW(SYNCHRONIZE,
|
|
|
|
FALSE,
|
2007-07-16 17:48:57 +00:00
|
|
|
L"SvcctrlStartEvent_A3752DX");
|
2005-04-15 22:02:37 +00:00
|
|
|
if (hEvent == NULL)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Try to create a new event */
|
|
|
|
hEvent = CreateEventW(NULL,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
2007-07-16 17:48:57 +00:00
|
|
|
L"SvcctrlStartEvent_A3752DX");
|
2005-11-01 13:47:40 +00:00
|
|
|
if (hEvent == NULL)
|
|
|
|
{
|
|
|
|
/* Try to open the existing event again */
|
|
|
|
hEvent = OpenEventW(SYNCHRONIZE,
|
|
|
|
FALSE,
|
2007-07-16 17:48:57 +00:00
|
|
|
L"SvcctrlStartEvent_A3752DX");
|
2005-11-01 13:47:40 +00:00
|
|
|
if (hEvent == NULL)
|
|
|
|
return;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Wait for 3 minutes */
|
|
|
|
WaitForSingleObject(hEvent, 180000);
|
|
|
|
CloseHandle(hEvent);
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("ScmWaitForSCManager() done\n");
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-07 08:03:28 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* OpenSCManagerA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-15 22:02:37 +00:00
|
|
|
* @implemented
|
1999-11-07 08:03:28 +00:00
|
|
|
*/
|
2002-07-20 13:31:34 +00:00
|
|
|
SC_HANDLE STDCALL
|
|
|
|
OpenSCManagerA(LPCSTR lpMachineName,
|
2005-04-15 22:02:37 +00:00
|
|
|
LPCSTR lpDatabaseName,
|
|
|
|
DWORD dwDesiredAccess)
|
2000-03-26 22:00:10 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
SC_HANDLE hScm = NULL;
|
|
|
|
DWORD dwError;
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("OpenSCManagerA(%s, %s, %lx)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
lpMachineName, lpDatabaseName, dwDesiredAccess);
|
2002-07-20 13:31:34 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
WaitForSCManager();
|
2002-12-27 14:40:03 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2002-07-20 13:31:34 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrOpenSCManagerA(BindingHandle,
|
|
|
|
(LPSTR)lpMachineName,
|
|
|
|
(LPSTR)lpDatabaseName,
|
|
|
|
dwDesiredAccess,
|
2007-12-04 17:21:46 +00:00
|
|
|
(unsigned long*)&hScm);
|
2005-11-01 13:47:40 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-07-20 13:31:34 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("hScm = %p\n", hScm);
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return hScm;
|
1999-11-07 08:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* OpenSCManagerW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-16 12:50:33 +00:00
|
|
|
* @implemented
|
1999-11-07 08:03:28 +00:00
|
|
|
*/
|
2005-04-15 22:02:37 +00:00
|
|
|
SC_HANDLE STDCALL
|
|
|
|
OpenSCManagerW(LPCWSTR lpMachineName,
|
|
|
|
LPCWSTR lpDatabaseName,
|
|
|
|
DWORD dwDesiredAccess)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
SC_HANDLE hScm = NULL;
|
|
|
|
DWORD dwError;
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("OpenSCManagerW(%S, %S, %lx)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
lpMachineName, lpDatabaseName, dwDesiredAccess);
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
WaitForSCManager();
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrOpenSCManagerW(BindingHandle,
|
|
|
|
(LPWSTR)lpMachineName,
|
|
|
|
(LPWSTR)lpDatabaseName,
|
|
|
|
dwDesiredAccess,
|
2007-12-04 17:21:46 +00:00
|
|
|
(unsigned long*)&hScm);
|
2005-11-01 13:47:40 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-08-07 04:03:25 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("hScm = %p\n", hScm);
|
2002-12-27 14:40:03 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return hScm;
|
1999-11-07 08:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* OpenServiceA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-15 22:02:37 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2004-04-12 17:20:47 +00:00
|
|
|
SC_HANDLE STDCALL
|
|
|
|
OpenServiceA(SC_HANDLE hSCManager,
|
2005-04-16 12:50:33 +00:00
|
|
|
LPCSTR lpServiceName,
|
|
|
|
DWORD dwDesiredAccess)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
SC_HANDLE hService = NULL;
|
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("OpenServiceA(%p, %s, %lx)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
hSCManager, lpServiceName, dwDesiredAccess);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrOpenServiceA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPSTR)lpServiceName,
|
|
|
|
dwDesiredAccess,
|
2007-12-04 17:21:46 +00:00
|
|
|
(unsigned long*)&hService);
|
2005-11-01 13:47:40 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrOpenServiceA() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("hService = %p\n", hService);
|
2005-11-01 13:47:40 +00:00
|
|
|
|
|
|
|
return hService;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* OpenServiceW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-15 22:02:37 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-15 22:02:37 +00:00
|
|
|
SC_HANDLE STDCALL
|
|
|
|
OpenServiceW(SC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
DWORD dwDesiredAccess)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
SC_HANDLE hService = NULL;
|
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("OpenServiceW(%p, %S, %lx)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
hSCManager, lpServiceName, dwDesiredAccess);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrOpenServiceW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpServiceName,
|
|
|
|
dwDesiredAccess,
|
2007-12-04 17:21:46 +00:00
|
|
|
(unsigned long*)&hService);
|
2005-11-01 13:47:40 +00:00
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrOpenServiceW() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("hService = %p\n", hService);
|
2005-11-01 13:47:40 +00:00
|
|
|
|
|
|
|
return hService;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceConfigA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceConfigA(SC_HANDLE hService,
|
|
|
|
LPQUERY_SERVICE_CONFIGA lpServiceConfig,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfigA(%p, %p, %lu, %p)\n",
|
2005-12-25 14:45:30 +00:00
|
|
|
hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceConfigA(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
(unsigned char *)lpServiceConfig,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceConfigA() failed (Error %lu)\n", dwError);
|
2005-12-25 14:45:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjust the pointers */
|
|
|
|
if (lpServiceConfig->lpBinaryPathName)
|
|
|
|
lpServiceConfig->lpBinaryPathName =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpBinaryPathName);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpLoadOrderGroup)
|
|
|
|
lpServiceConfig->lpLoadOrderGroup =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpLoadOrderGroup);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpDependencies)
|
|
|
|
lpServiceConfig->lpDependencies =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpDependencies);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpServiceStartName)
|
|
|
|
lpServiceConfig->lpServiceStartName =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpServiceStartName);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpDisplayName)
|
|
|
|
lpServiceConfig->lpDisplayName =
|
|
|
|
(LPSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpDisplayName);
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfigA() done\n");
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceConfigW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-18 19:50:53 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-23 15:56:51 +00:00
|
|
|
BOOL STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
QueryServiceConfigW(SC_HANDLE hService,
|
|
|
|
LPQUERY_SERVICE_CONFIGW lpServiceConfig,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-18 19:50:53 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfigW(%p, %p, %lu, %p)\n",
|
2005-12-18 19:50:53 +00:00
|
|
|
hService, lpServiceConfig, cbBufSize, pcbBytesNeeded);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceConfigW(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
(unsigned char *)lpServiceConfig,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
2005-11-07 10:04:41 +00:00
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceConfigW() failed (Error %lu)\n", dwError);
|
2005-12-18 19:50:53 +00:00
|
|
|
SetLastError(dwError);
|
2005-11-07 10:04:41 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-12-18 19:50:53 +00:00
|
|
|
|
|
|
|
/* Adjust the pointers */
|
|
|
|
if (lpServiceConfig->lpBinaryPathName)
|
|
|
|
lpServiceConfig->lpBinaryPathName =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpBinaryPathName);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpLoadOrderGroup)
|
|
|
|
lpServiceConfig->lpLoadOrderGroup =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpLoadOrderGroup);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpDependencies)
|
|
|
|
lpServiceConfig->lpDependencies =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpDependencies);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpServiceStartName)
|
|
|
|
lpServiceConfig->lpServiceStartName =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpServiceStartName);
|
|
|
|
|
|
|
|
if (lpServiceConfig->lpDisplayName)
|
|
|
|
lpServiceConfig->lpDisplayName =
|
|
|
|
(LPWSTR)((ULONG_PTR)lpServiceConfig +
|
|
|
|
(ULONG_PTR)lpServiceConfig->lpDisplayName);
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfigW() done\n");
|
2005-12-18 19:50:53 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 19:50:53 +00:00
|
|
|
|
2005-12-23 15:56:51 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* QueryServiceConfig2A
|
|
|
|
*
|
2006-01-01 10:31:35 +00:00
|
|
|
* @implemented
|
2005-12-23 15:56:51 +00:00
|
|
|
*/
|
2006-01-01 10:31:35 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceConfig2A(SC_HANDLE hService,
|
|
|
|
DWORD dwInfoLevel,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
2005-12-23 15:56:51 +00:00
|
|
|
{
|
2006-01-01 10:31:35 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfig2A(%p, %lu, %p, %lu, %p)\n",
|
2006-01-01 10:31:35 +00:00
|
|
|
hService, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceConfig2A(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwInfoLevel,
|
|
|
|
(unsigned char *)lpBuffer,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceConfig2A() failed (Error %lu)\n", dwError);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dwInfoLevel)
|
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
|
|
|
{
|
|
|
|
LPSERVICE_DESCRIPTIONA lpPtr = (LPSERVICE_DESCRIPTIONA)lpBuffer;
|
|
|
|
|
|
|
|
if (lpPtr->lpDescription != NULL)
|
|
|
|
lpPtr->lpDescription =
|
|
|
|
(LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpDescription);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SERVICE_CONFIG_FAILURE_ACTIONS:
|
|
|
|
{
|
|
|
|
LPSERVICE_FAILURE_ACTIONSA lpPtr = (LPSERVICE_FAILURE_ACTIONSA)lpBuffer;
|
|
|
|
|
|
|
|
if (lpPtr->lpRebootMsg != NULL)
|
|
|
|
lpPtr->lpRebootMsg =
|
|
|
|
(LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpRebootMsg);
|
|
|
|
|
|
|
|
if (lpPtr->lpCommand != NULL)
|
|
|
|
lpPtr->lpCommand =
|
|
|
|
(LPSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpCommand);
|
|
|
|
|
|
|
|
if (lpPtr->lpsaActions != NULL)
|
|
|
|
lpPtr->lpsaActions =
|
|
|
|
(SC_ACTION*)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpsaActions);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("Unknown info level 0x%lx\n", dwInfoLevel);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfig2A() done\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2005-12-23 15:56:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-10 15:40:52 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* QueryServiceConfig2W
|
|
|
|
*
|
2006-01-01 10:31:35 +00:00
|
|
|
* @implemented
|
2005-12-10 15:40:52 +00:00
|
|
|
*/
|
2006-01-01 10:31:35 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceConfig2W(SC_HANDLE hService,
|
|
|
|
DWORD dwInfoLevel,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
2005-12-10 15:40:52 +00:00
|
|
|
{
|
2006-01-01 10:31:35 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfig2W(%p, %lu, %p, %lu, %p)\n",
|
2006-01-01 10:31:35 +00:00
|
|
|
hService, dwInfoLevel, lpBuffer, cbBufSize, pcbBytesNeeded);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceConfig2W(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwInfoLevel,
|
|
|
|
(unsigned char *)lpBuffer,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceConfig2W() failed (Error %lu)\n", dwError);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dwInfoLevel)
|
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
|
|
|
{
|
|
|
|
LPSERVICE_DESCRIPTIONW lpPtr = (LPSERVICE_DESCRIPTIONW)lpBuffer;
|
|
|
|
|
|
|
|
if (lpPtr->lpDescription != NULL)
|
|
|
|
lpPtr->lpDescription =
|
|
|
|
(LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpDescription);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SERVICE_CONFIG_FAILURE_ACTIONS:
|
|
|
|
{
|
|
|
|
LPSERVICE_FAILURE_ACTIONSW lpPtr = (LPSERVICE_FAILURE_ACTIONSW)lpBuffer;
|
|
|
|
|
|
|
|
if (lpPtr->lpRebootMsg != NULL)
|
|
|
|
lpPtr->lpRebootMsg =
|
|
|
|
(LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpRebootMsg);
|
|
|
|
|
|
|
|
if (lpPtr->lpCommand != NULL)
|
|
|
|
lpPtr->lpCommand =
|
|
|
|
(LPWSTR)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpCommand);
|
|
|
|
|
|
|
|
if (lpPtr->lpsaActions != NULL)
|
|
|
|
lpPtr->lpsaActions =
|
|
|
|
(SC_ACTION*)((UINT_PTR)lpPtr + (UINT_PTR)lpPtr->lpsaActions);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-08 17:04:39 +00:00
|
|
|
WARN("Unknown info level 0x%lx\n", dwInfoLevel);
|
2006-01-01 10:31:35 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceConfig2W() done\n");
|
2006-01-01 10:31:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2005-12-10 15:40:52 +00:00
|
|
|
}
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceLockStatusA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 14:26:25 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 14:26:25 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceLockStatusA(SC_HANDLE hSCManager,
|
|
|
|
LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 14:26:25 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceLockStatusA() called\n");
|
2006-01-01 14:26:25 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceLockStatusA(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(unsigned char *)lpLockStatus,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceLockStatusA() failed (Error %lu)\n", dwError);
|
2006-01-01 14:26:25 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpLockStatus->lpLockOwner != NULL)
|
|
|
|
{
|
|
|
|
lpLockStatus->lpLockOwner =
|
|
|
|
(LPSTR)((UINT_PTR)lpLockStatus + (UINT_PTR)lpLockStatus->lpLockOwner);
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceLockStatusA() done\n");
|
2006-01-01 14:26:25 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceLockStatusW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2006-01-01 14:26:25 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2006-01-01 14:26:25 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceLockStatusW(SC_HANDLE hSCManager,
|
|
|
|
LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2006-01-01 14:26:25 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceLockStatusW() called\n");
|
2006-01-01 14:26:25 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceLockStatusW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(unsigned char *)lpLockStatus,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceLockStatusW() failed (Error %lu)\n", dwError);
|
2006-01-01 14:26:25 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpLockStatus->lpLockOwner != NULL)
|
|
|
|
{
|
|
|
|
lpLockStatus->lpLockOwner =
|
|
|
|
(LPWSTR)((UINT_PTR)lpLockStatus + (UINT_PTR)lpLockStatus->lpLockOwner);
|
|
|
|
}
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceLockStatusW() done\n");
|
2006-01-01 14:26:25 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceObjectSecurity
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-23 15:56:51 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-23 15:56:51 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceObjectSecurity(SC_HANDLE hService,
|
|
|
|
SECURITY_INFORMATION dwSecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR lpSecurityDescriptor,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-23 15:56:51 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceObjectSecurity(%p, %lu, %p)\n",
|
2005-12-23 15:56:51 +00:00
|
|
|
hService, dwSecurityInformation, lpSecurityDescriptor);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceObjectSecurity(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwSecurityInformation,
|
|
|
|
(unsigned char *)lpSecurityDescriptor,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
|
2005-12-23 15:56:51 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
2007-07-10 14:54:30 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* SetServiceObjectSecurity
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
SetServiceObjectSecurity(SC_HANDLE hService,
|
|
|
|
SECURITY_INFORMATION dwSecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR lpSecurityDescriptor)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrSetServiceObjectSecurity(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwSecurityInformation,
|
|
|
|
(unsigned char *)SelfRelativeSD,
|
|
|
|
Length);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
|
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
|
2007-07-10 14:54:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceStatus
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-23 00:01:37 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-23 00:01:37 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceStatus(SC_HANDLE hService,
|
|
|
|
LPSERVICE_STATUS lpServiceStatus)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
DWORD dwError;
|
2005-04-23 00:01:37 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceStatus(%p, %p)\n",
|
2005-11-01 13:47:40 +00:00
|
|
|
hService, lpServiceStatus);
|
2005-04-23 00:01:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-23 00:01:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceStatus(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
lpServiceStatus);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-23 00:01:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* QueryServiceStatusEx
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-25 14:45:30 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-25 14:45:30 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
QueryServiceStatusEx(SC_HANDLE hService,
|
|
|
|
SC_STATUS_TYPE InfoLevel,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-25 14:45:30 +00:00
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("QueryServiceStatusEx() called\n");
|
2005-12-25 14:45:30 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrQueryServiceStatusEx(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
InfoLevel,
|
|
|
|
lpBuffer,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrQueryServiceStatusEx() failed (Error %lu)\n", dwError);
|
2005-12-25 14:45:30 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 21:38:05 +00:00
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* StartServiceA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-31 11:33:46 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-31 11:33:46 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
StartServiceA(SC_HANDLE hService,
|
|
|
|
DWORD dwNumServiceArgs,
|
|
|
|
LPCSTR *lpServiceArgVectors)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2008-01-13 14:22:55 +00:00
|
|
|
LPSTR lpBuffer = NULL;
|
2006-08-07 22:13:26 +00:00
|
|
|
LPSTR lpStr;
|
2005-12-31 11:33:46 +00:00
|
|
|
DWORD dwError;
|
2008-01-13 14:22:55 +00:00
|
|
|
DWORD dwBufSize = 0;
|
2006-08-07 22:13:26 +00:00
|
|
|
DWORD i;
|
2005-12-31 11:33:46 +00:00
|
|
|
|
2008-01-13 14:22:55 +00:00
|
|
|
if (dwNumServiceArgs > 0)
|
2005-12-31 11:33:46 +00:00
|
|
|
{
|
2008-01-13 14:22:55 +00:00
|
|
|
for (i = 0; i < dwNumServiceArgs; i++)
|
|
|
|
{
|
|
|
|
dwBufSize += (strlen(lpServiceArgVectors[i]) + 1);
|
|
|
|
}
|
|
|
|
dwBufSize++;
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("dwBufSize: %lu\n", dwBufSize);
|
2005-12-31 11:33:46 +00:00
|
|
|
|
2008-01-13 14:22:55 +00:00
|
|
|
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
|
|
|
|
if (lpBuffer == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-12-31 11:33:46 +00:00
|
|
|
|
2008-01-13 14:22:55 +00:00
|
|
|
lpStr = lpBuffer;
|
|
|
|
for (i = 0; i < dwNumServiceArgs; i++)
|
|
|
|
{
|
|
|
|
strcpy(lpStr, lpServiceArgVectors[i]);
|
|
|
|
lpStr += (strlen(lpServiceArgVectors[i]) + 1);
|
|
|
|
}
|
|
|
|
*lpStr = 0;
|
2005-12-31 11:33:46 +00:00
|
|
|
}
|
|
|
|
|
2006-08-07 22:13:26 +00:00
|
|
|
dwError = ScmrStartServiceA(BindingHandle,
|
2005-12-31 11:33:46 +00:00
|
|
|
(unsigned int)hService,
|
|
|
|
dwNumServiceArgs,
|
|
|
|
(unsigned char *)lpBuffer,
|
|
|
|
dwBufSize);
|
|
|
|
|
2008-01-13 14:22:55 +00:00
|
|
|
if (lpBuffer != NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpBuffer);
|
2005-12-31 11:33:46 +00:00
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrStartServiceA() failed (Error %lu)\n", dwError);
|
2005-12-31 11:33:46 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* StartServiceW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-12-31 11:33:46 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-12-31 11:33:46 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
StartServiceW(SC_HANDLE hService,
|
|
|
|
DWORD dwNumServiceArgs,
|
|
|
|
LPCWSTR *lpServiceArgVectors)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-12-31 11:33:46 +00:00
|
|
|
LPWSTR lpBuffer;
|
|
|
|
LPWSTR lpStr;
|
|
|
|
DWORD dwError;
|
|
|
|
DWORD dwBufSize;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
dwBufSize = 0;
|
|
|
|
for (i = 0; i < dwNumServiceArgs; i++)
|
|
|
|
{
|
|
|
|
dwBufSize += ((wcslen(lpServiceArgVectors[i]) + 1) * sizeof(WCHAR));
|
|
|
|
}
|
2006-08-30 10:53:37 +00:00
|
|
|
dwBufSize += sizeof(WCHAR);
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("dwBufSize: %lu\n", dwBufSize);
|
2005-12-31 11:33:46 +00:00
|
|
|
|
|
|
|
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwBufSize);
|
|
|
|
if (lpBuffer == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpStr = lpBuffer;
|
|
|
|
for (i = 0; i < dwNumServiceArgs; i++)
|
|
|
|
{
|
|
|
|
wcscpy(lpStr, lpServiceArgVectors[i]);
|
|
|
|
lpStr += (wcslen(lpServiceArgVectors[i]) + 1);
|
|
|
|
}
|
2006-08-30 10:53:37 +00:00
|
|
|
*lpStr = 0;
|
2005-12-31 11:33:46 +00:00
|
|
|
|
|
|
|
dwError = ScmrStartServiceW(BindingHandle,
|
|
|
|
(unsigned int)hService,
|
|
|
|
dwNumServiceArgs,
|
|
|
|
(unsigned char *)lpBuffer,
|
|
|
|
dwBufSize);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpBuffer);
|
|
|
|
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrStartServiceW() failed (Error %lu)\n", dwError);
|
2005-12-31 11:33:46 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-17 12:49:37 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2002-12-27 14:40:03 +00:00
|
|
|
* UnlockServiceDatabase
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2005-04-16 12:50:33 +00:00
|
|
|
* @implemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
2005-04-16 12:50:33 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
UnlockServiceDatabase(SC_LOCK ScLock)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
DWORD dwError;
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("UnlockServiceDatabase(%x)\n", ScLock);
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
HandleBind();
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrUnlockServiceDatabase(BindingHandle,
|
|
|
|
(unsigned int)ScLock);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError);
|
2005-11-01 13:47:40 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
return TRUE;
|
1999-05-19 16:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-15 19:34:53 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* NotifyBootConfigStatus
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
NotifyBootConfigStatus(BOOL BootAcceptable)
|
|
|
|
{
|
|
|
|
DWORD dwError;
|
|
|
|
|
2008-02-08 17:04:39 +00:00
|
|
|
TRACE("NotifyBootConfigStatus()\n");
|
2005-10-15 19:34:53 +00:00
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrNotifyBootConfigStatus(BindingHandle,
|
|
|
|
BootAcceptable);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
2008-02-08 17:04:39 +00:00
|
|
|
ERR("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
|
2005-10-15 19:34:53 +00:00
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/* EOF */
|