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-17 11:01:00 +00:00
|
|
|
#include "svcctl_c.h"
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2004-09-26 20:28:22 +00:00
|
|
|
#define NDEBUG
|
2002-12-27 14:40:03 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
DPRINT1("RpcStringBindingCompose returned 0x%x\n", status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the binding handle that will be used to bind to the server. */
|
|
|
|
status = RpcBindingFromStringBindingW(pszStringBinding,
|
|
|
|
&BindingHandle);
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", status);
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RpcStringFreeW(&pszStringBinding);
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
DPRINT1("RpcStringFree returned 0x%x\n", status);
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
DPRINT1("RpcBindingFree returned 0x%x\n", status);
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
ChangeServiceConfigA(
|
2002-12-27 14:40:03 +00:00
|
|
|
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
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("ChangeServiceConfigA 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
|
|
|
* 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;
|
|
|
|
|
2005-11-17 12:49:37 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrChangeServiceConfigW() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrCloseServiceHandle() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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;
|
|
|
|
|
|
|
|
DPRINT("ControlService(%x, %x, %p)\n",
|
|
|
|
hService, dwControl, lpServiceStatus);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-04-15 22:02:37 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ControlServiceEx(0x%p, 0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n",
|
|
|
|
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
|
|
|
*/
|
|
|
|
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;
|
|
|
|
LPSTR lpStr;
|
2005-11-17 13:23:37 +00:00
|
|
|
|
|
|
|
int 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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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, lpDisplayName, -1, lpBinaryPathNameW, len);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2005-11-17 13:45:02 +00:00
|
|
|
if (lpDependencies != NULL)
|
|
|
|
{
|
|
|
|
lpStr = (LPSTR)lpDependencies;
|
|
|
|
while (*lpStr)
|
|
|
|
{
|
|
|
|
dwLength = strlen(lpStr) + 1;
|
|
|
|
dwDependenciesLength += dwLength;
|
|
|
|
lpStr = lpStr + dwLength;
|
|
|
|
}
|
|
|
|
dwDependenciesLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpDependenciesW = HeapAlloc(GetProcessHeap(), 0, dwDependenciesLength * sizeof(WCHAR));
|
2005-11-17 13:23:37 +00:00
|
|
|
if (!lpDependenciesW)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2005-11-17 13:46:07 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpDependencies, -1, lpDependenciesW, dwDependenciesLength);
|
2005-11-17 13:23:37 +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);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpPassword, -1, lpPasswordW, len);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
cleanup:
|
2005-11-17 13:45:02 +00:00
|
|
|
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);
|
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;
|
|
|
|
DWORD dwError;
|
2005-10-15 19:34:53 +00:00
|
|
|
DWORD dwDependenciesLength = 0;
|
|
|
|
DWORD dwLength;
|
|
|
|
LPWSTR lpStr;
|
2005-10-09 20:24:00 +00:00
|
|
|
|
|
|
|
DPRINT1("CreateServiceW() called\n");
|
|
|
|
|
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 */
|
|
|
|
(unsigned int *)&hService);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrCreateServiceW() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrDeleteService() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
EnumDependentServicesA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hService,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSA lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("EnumDependentServicesA 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
|
|
|
* EnumDependentServicesW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +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
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("EnumDependentServicesW 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
|
|
|
* 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(
|
2002-12-27 14:40:03 +00:00
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1,
|
|
|
|
DWORD Unknown2,
|
|
|
|
DWORD Unknown3,
|
|
|
|
DWORD Unknown4,
|
|
|
|
DWORD Unknown5,
|
|
|
|
DWORD Unknown6,
|
|
|
|
DWORD Unknown7,
|
|
|
|
DWORD Unknown8)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
2005-12-18 19:50:53 +00:00
|
|
|
EnumServicesStatusA(
|
2002-12-27 14:40:03 +00:00
|
|
|
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
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("EnumServicesStatusA 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-18 19:50:53 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* EnumServicesStatusW
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
EnumServicesStatusW(SC_HANDLE hSCManager,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwServiceState,
|
|
|
|
LPENUM_SERVICE_STATUSW lpServices,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded,
|
|
|
|
LPDWORD lpServicesReturned,
|
|
|
|
LPDWORD lpResumeHandle)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
DWORD dwError = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
DPRINT1("EnumServicesStatusW() called\n");
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrEnumServicesStatusW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
dwServiceType,
|
|
|
|
dwServiceState,
|
|
|
|
(unsigned char *)lpServices,
|
|
|
|
cbBufSize,
|
|
|
|
pcbBytesNeeded,
|
|
|
|
lpServicesReturned,
|
|
|
|
lpResumeHandle);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrEnumServicesStatusW() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DPRINT1("ScmrEnumServicesStatusW() done\n");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DPRINT1("EnumServicesStatusW is unimplemented\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
2002-12-26 17:23:27 +00:00
|
|
|
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
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("EnumServicesStatusExA 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
|
|
|
* EnumServicesStatusExW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
1999-07-22 21:36:37 +00:00
|
|
|
BOOL
|
1999-05-19 16:43:30 +00:00
|
|
|
STDCALL
|
2002-12-26 17:23:27 +00:00
|
|
|
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
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("EnumServicesStatusExW 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
|
|
|
* GetServiceDisplayNameA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
GetServiceDisplayNameA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpServiceName,
|
|
|
|
LPSTR lpDisplayName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("GetServiceDisplayNameA 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
|
|
|
* 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;
|
|
|
|
|
|
|
|
DPRINT("GetServiceDisplayNameW() called\n");
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceDisplayNameW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpServiceName,
|
|
|
|
lpDisplayName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrGetServiceDisplayNameW() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
GetServiceKeyNameA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpDisplayName,
|
|
|
|
LPSTR lpServiceName,
|
|
|
|
LPDWORD lpcchBuffer)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("GetServiceKeyNameA 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
|
|
|
* 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;
|
|
|
|
|
|
|
|
DPRINT("GetServiceKeyNameW() called\n");
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
dwError = ScmrGetServiceKeyNameW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpDisplayName,
|
|
|
|
lpServiceName,
|
|
|
|
lpcchBuffer);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrGetServiceKeyNameW() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrLockServiceDatabase() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-16 12:50:33 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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;
|
|
|
|
|
|
|
|
DPRINT("WaitForSCManager() called\n");
|
|
|
|
|
|
|
|
/* Try to open the existing event */
|
|
|
|
hEvent = OpenEventW(SYNCHRONIZE,
|
|
|
|
FALSE,
|
|
|
|
L"SvcctrlStartEvent_A3725DX");
|
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,
|
|
|
|
L"SvcctrlStartEvent_A3725DX");
|
|
|
|
if (hEvent == NULL)
|
|
|
|
{
|
|
|
|
/* Try to open the existing event again */
|
|
|
|
hEvent = OpenEventW(SYNCHRONIZE,
|
|
|
|
FALSE,
|
|
|
|
L"SvcctrlStartEvent_A3725DX");
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("OpenSCManagerA(%s, %s, %lx)\n",
|
|
|
|
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,
|
|
|
|
(unsigned int*)&hScm);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrOpenSCManagerA() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-07-20 13:31:34 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("OpenSCManagerW(%S, %S, %lx)\n",
|
|
|
|
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,
|
|
|
|
(unsigned int*)&hScm);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrOpenSCManagerW() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-08-07 04:03:25 +00:00
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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;
|
|
|
|
|
|
|
|
DPRINT("OpenServiceA(%p, %s, %lx)\n",
|
|
|
|
hSCManager, lpServiceName, dwDesiredAccess);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("hService = %p\n", hService);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
DPRINT("OpenServiceW(%p, %S, %lx)\n",
|
|
|
|
hSCManager, lpServiceName, dwDesiredAccess);
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrOpenServiceW(BindingHandle,
|
|
|
|
(unsigned int)hSCManager,
|
|
|
|
(LPWSTR)lpServiceName,
|
|
|
|
dwDesiredAccess,
|
|
|
|
(unsigned int*)&hService);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrOpenServiceW() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("hService = %p\n", hService);
|
|
|
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
QueryServiceConfigA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hService,
|
|
|
|
LPQUERY_SERVICE_CONFIGA lpServiceConfig,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("QueryServiceConfigA 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
|
|
|
* 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;
|
|
|
|
|
|
|
|
DPRINT("QueryServiceConfigW(%p, %p, %lu, %p)\n",
|
|
|
|
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
|
|
|
{
|
2005-12-18 19:50:53 +00:00
|
|
|
DPRINT("ScmrQueryServiceConfigW() failed (Error %lu)\n", dwError);
|
|
|
|
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);
|
|
|
|
|
|
|
|
DPRINT("QueryServiceConfigW() done\n");
|
|
|
|
|
|
|
|
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
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
QueryServiceConfig2A(
|
|
|
|
SC_HANDLE hService,
|
|
|
|
DWORD dwInfo,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
|
|
|
{
|
|
|
|
DPRINT1("QueryServiceConfig2A is unimplemented\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-10 15:40:52 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* QueryServiceConfig2W
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
2005-12-23 15:56:51 +00:00
|
|
|
QueryServiceConfig2W(
|
2005-12-10 15:40:52 +00:00
|
|
|
SC_HANDLE hService,
|
|
|
|
DWORD dwInfo,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
|
|
|
{
|
2005-12-23 15:56:51 +00:00
|
|
|
DPRINT1("QueryServiceConfig2W is unimplemented\n");
|
2005-12-10 15:40:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
QueryServiceLockStatusA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hSCManager,
|
|
|
|
LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("QueryServiceLockStatusA 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
|
|
|
* QueryServiceLockStatusW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
QueryServiceLockStatusW(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hSCManager,
|
|
|
|
LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("QueryServiceLockStatusW 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
|
|
|
* 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;
|
|
|
|
|
|
|
|
DPRINT("QueryServiceObjectSecurity(%p, %lu, %p)\n",
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
DPRINT1("QueryServiceObjectSecurity() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("QueryServiceStatus(%p, %p)\n",
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrQueryServiceStatus() failed (Error %lu)\n", dwError);
|
|
|
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
2002-12-26 17:23:27 +00:00
|
|
|
QueryServiceStatusEx(SC_HANDLE hService,
|
|
|
|
SC_STATUS_TYPE InfoLevel,
|
|
|
|
LPBYTE lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("QueryServiceStatusEx 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-18 21:38:05 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* SetServiceObjectSecurity
|
|
|
|
*
|
2005-12-23 15:56:51 +00:00
|
|
|
* @implemented
|
2005-12-18 21:38:05 +00:00
|
|
|
*/
|
|
|
|
BOOL STDCALL
|
|
|
|
SetServiceObjectSecurity(SC_HANDLE hService,
|
2005-12-23 15:56:51 +00:00
|
|
|
SECURITY_INFORMATION dwSecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR lpSecurityDescriptor)
|
2005-12-18 21:38:05 +00:00
|
|
|
{
|
2005-12-23 15:56:51 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
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
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
StartServiceA(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hService,
|
|
|
|
DWORD dwNumServiceArgs,
|
|
|
|
LPCSTR *lpServiceArgVectors)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2004-09-26 20:28:22 +00:00
|
|
|
DPRINT1("StartServiceA 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
|
|
|
* StartServiceW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
1999-05-19 16:43:30 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
StartServiceW(
|
2002-12-27 14:40:03 +00:00
|
|
|
SC_HANDLE hService,
|
|
|
|
DWORD dwNumServiceArgs,
|
|
|
|
LPCWSTR *lpServiceArgVectors)
|
1999-05-19 16:43:30 +00:00
|
|
|
{
|
2005-11-17 12:49:37 +00:00
|
|
|
DPRINT1("StartServiceW is unimplemented, but returns success...\n");
|
|
|
|
//SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
//return FALSE;
|
|
|
|
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
|
|
|
|
2005-11-01 13:47:40 +00:00
|
|
|
DPRINT("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)
|
|
|
|
{
|
|
|
|
DPRINT1("ScmrUnlockServiceDatabase() failed (Error %lu)\n", dwError);
|
|
|
|
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;
|
|
|
|
|
|
|
|
DPRINT1("NotifyBootConfigStatus()\n");
|
|
|
|
|
|
|
|
HandleBind();
|
|
|
|
|
|
|
|
/* Call to services.exe using RPC */
|
|
|
|
dwError = ScmrNotifyBootConfigStatus(BindingHandle,
|
|
|
|
BootAcceptable);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("NotifyBootConfigStatus() failed (Error %lu)\n", dwError);
|
|
|
|
SetLastError(dwError);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 22:02:37 +00:00
|
|
|
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
|
2005-10-15 19:34:53 +00:00
|
|
|
|
2005-04-15 22:02:37 +00:00
|
|
|
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
|
|
|
{
|
2005-11-01 13:47:40 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
2005-04-15 22:02:37 +00:00
|
|
|
}
|
|
|
|
|
1999-05-19 16:43:30 +00:00
|
|
|
/* EOF */
|