mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Implement ScmrChangeServiceConfigW stub.
- CreateServiceW calls ScmrCreateServiceW. svn path=/trunk/; revision=18723
This commit is contained in:
parent
1ad37b3ad9
commit
0adb2c35cf
5 changed files with 205 additions and 54 deletions
|
@ -106,26 +106,68 @@ ChangeServiceConfigA(
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* ChangeServiceConfigW
|
* ChangeServiceConfigW
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL STDCALL
|
||||||
STDCALL
|
ChangeServiceConfigW(SC_HANDLE hService,
|
||||||
ChangeServiceConfigW(
|
DWORD dwServiceType,
|
||||||
SC_HANDLE hService,
|
DWORD dwStartType,
|
||||||
DWORD dwServiceType,
|
DWORD dwErrorControl,
|
||||||
DWORD dwStartType,
|
LPCWSTR lpBinaryPathName,
|
||||||
DWORD dwErrorControl,
|
LPCWSTR lpLoadOrderGroup,
|
||||||
LPCWSTR lpBinaryPathName,
|
LPDWORD lpdwTagId,
|
||||||
LPCWSTR lpLoadOrderGroup,
|
LPCWSTR lpDependencies,
|
||||||
LPDWORD lpdwTagId,
|
LPCWSTR lpServiceStartName,
|
||||||
LPCWSTR lpDependencies,
|
LPCWSTR lpPassword,
|
||||||
LPCWSTR lpServiceStartName,
|
LPCWSTR lpDisplayName)
|
||||||
LPCWSTR lpPassword,
|
|
||||||
LPCWSTR lpDisplayName)
|
|
||||||
{
|
{
|
||||||
DPRINT1("ChangeServiceConfigW is unimplemented\n");
|
DWORD dwError;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
DWORD dwDependenciesLength = 0;
|
||||||
return FALSE;
|
DWORD dwLength;
|
||||||
|
LPWSTR lpStr;
|
||||||
|
|
||||||
|
DPRINT1("ChangeServiceConfigW() called\n");
|
||||||
|
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,7 +285,7 @@ CreateServiceA(
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CreateServiceW
|
* CreateServiceW
|
||||||
*
|
*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
SC_HANDLE STDCALL
|
SC_HANDLE STDCALL
|
||||||
CreateServiceW(SC_HANDLE hSCManager,
|
CreateServiceW(SC_HANDLE hSCManager,
|
||||||
|
@ -262,7 +304,6 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||||
{
|
{
|
||||||
SC_HANDLE hService = NULL;
|
SC_HANDLE hService = NULL;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
HKEY hEnumKey, hKey;
|
|
||||||
DWORD dwDependenciesLength = 0;
|
DWORD dwDependenciesLength = 0;
|
||||||
DWORD dwLength;
|
DWORD dwLength;
|
||||||
LPWSTR lpStr;
|
LPWSTR lpStr;
|
||||||
|
@ -284,7 +325,6 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||||
|
|
||||||
/* FIXME: Encrypt the password */
|
/* FIXME: Encrypt the password */
|
||||||
|
|
||||||
#if 0
|
|
||||||
HandleBind();
|
HandleBind();
|
||||||
|
|
||||||
/* Call to services.exe using RPC */
|
/* Call to services.exe using RPC */
|
||||||
|
@ -299,25 +339,12 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||||
(LPWSTR)lpBinaryPathName,
|
(LPWSTR)lpBinaryPathName,
|
||||||
(LPWSTR)lpLoadOrderGroup,
|
(LPWSTR)lpLoadOrderGroup,
|
||||||
lpdwTagId,
|
lpdwTagId,
|
||||||
lpDependencies,
|
(LPWSTR)lpDependencies,
|
||||||
dwDependenciesLength,
|
dwDependenciesLength,
|
||||||
(LPWSTR)lpServiceStartName,
|
(LPWSTR)lpServiceStartName,
|
||||||
NULL, /* FIXME: lpPassword */
|
NULL, /* FIXME: lpPassword */
|
||||||
0, /* FIXME: dwPasswordLength */
|
0, /* FIXME: dwPasswordLength */
|
||||||
(unsigned int *)&hService);
|
(unsigned int *)&hService);
|
||||||
#else
|
|
||||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services", 0, KEY_ENUMERATE_SUB_KEYS, &hEnumKey);
|
|
||||||
RegCreateKeyExW(hEnumKey, lpServiceName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL);
|
|
||||||
RegCloseKey(hEnumKey);
|
|
||||||
if (lpLoadOrderGroup)
|
|
||||||
RegSetValueExW(hKey, L"Group", 0, REG_SZ, (const BYTE*)lpLoadOrderGroup, (wcslen(lpLoadOrderGroup) + 1) * sizeof(WCHAR));
|
|
||||||
RegSetValueExW(hKey, L"ImagePath", 0, REG_EXPAND_SZ, (const BYTE*)lpBinaryPathName, (wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR));
|
|
||||||
RegSetValueExW(hKey, L"ErrorControl", 0, REG_DWORD, (const BYTE*)&dwErrorControl, sizeof(dwErrorControl));
|
|
||||||
RegSetValueExW(hKey, L"Start", 0, REG_DWORD, (const BYTE*)&dwStartType, sizeof(dwStartType));
|
|
||||||
RegSetValueExW(hKey, L"Type", 0, REG_DWORD, (const BYTE*)&dwStartType, sizeof(dwStartType));
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
hService = INVALID_HANDLE_VALUE; dwError = ERROR_SUCCESS;
|
|
||||||
#endif
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrCreateServiceW() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmrCreateServiceW() failed (Error %lu)\n", dwError);
|
||||||
|
|
103
reactos/subsys/system/services/config.c
Normal file
103
reactos/subsys/system/services/config.c
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* config.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include "services.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
ScmWriteDependencies(HKEY hServiceKey,
|
||||||
|
LPWSTR lpDependencies,
|
||||||
|
DWORD dwDependenciesLength)
|
||||||
|
{
|
||||||
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
|
DWORD dwGroupLength = 0;
|
||||||
|
DWORD dwServiceLength = 0;
|
||||||
|
DWORD dwLength;
|
||||||
|
LPWSTR lpGroupDeps;
|
||||||
|
LPWSTR lpServiceDeps;
|
||||||
|
LPWSTR lpSrc;
|
||||||
|
LPWSTR lpDst;
|
||||||
|
|
||||||
|
if (*lpDependencies == 0)
|
||||||
|
{
|
||||||
|
RegDeleteValue(hServiceKey,
|
||||||
|
L"DependOnService");
|
||||||
|
RegDeleteValue(hServiceKey,
|
||||||
|
L"DependOnGroup");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lpGroupDeps = HeapAlloc(GetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
(dwDependenciesLength + 2) * sizeof(WCHAR));
|
||||||
|
if (lpGroupDeps == NULL)
|
||||||
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
|
lpSrc = lpDependencies;
|
||||||
|
lpDst = lpGroupDeps;
|
||||||
|
while (*lpSrc != 0)
|
||||||
|
{
|
||||||
|
dwLength = wcslen(lpSrc);
|
||||||
|
if (*lpSrc == SC_GROUP_IDENTIFIERW)
|
||||||
|
{
|
||||||
|
lpSrc++;
|
||||||
|
dwGroupLength += dwLength;
|
||||||
|
wcscpy(lpDst, lpSrc);
|
||||||
|
lpDst = lpDst + dwLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpSrc = lpSrc + dwLength;
|
||||||
|
}
|
||||||
|
*lpDst = 0;
|
||||||
|
lpDst++;
|
||||||
|
dwGroupLength++;
|
||||||
|
|
||||||
|
lpSrc = lpDependencies;
|
||||||
|
lpServiceDeps = lpDst;
|
||||||
|
while (*lpSrc != 0)
|
||||||
|
{
|
||||||
|
dwLength = wcslen(lpSrc) + 1;
|
||||||
|
if (*lpSrc != SC_GROUP_IDENTIFIERW)
|
||||||
|
{
|
||||||
|
dwServiceLength += dwLength;
|
||||||
|
wcscpy(lpDst, lpSrc);
|
||||||
|
lpDst = lpDst + dwLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpSrc = lpSrc + dwLength;
|
||||||
|
}
|
||||||
|
*lpDst = 0;
|
||||||
|
dwServiceLength++;
|
||||||
|
|
||||||
|
dwError = RegSetValueExW(hServiceKey,
|
||||||
|
L"DependOnGroup",
|
||||||
|
0,
|
||||||
|
REG_MULTI_SZ,
|
||||||
|
(LPBYTE)lpGroupDeps,
|
||||||
|
dwGroupLength * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (dwError == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
dwError = RegSetValueExW(hServiceKey,
|
||||||
|
L"DependOnService",
|
||||||
|
0,
|
||||||
|
REG_MULTI_SZ,
|
||||||
|
(LPBYTE)lpServiceDeps,
|
||||||
|
dwServiceLength * sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpGroupDeps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dwError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -472,25 +472,32 @@ ScmrNotifyBootConfigStatus(handle_t BindingHandle,
|
||||||
|
|
||||||
|
|
||||||
/* Function 11 */
|
/* Function 11 */
|
||||||
#if 0
|
|
||||||
unsigned long
|
unsigned long
|
||||||
ScmrChangeServiceConfigW([in] handle_t BiningHandle,
|
ScmrChangeServiceConfigW(handle_t BiningHandle,
|
||||||
[in] SC_HANDLE hService,
|
unsigned int hService,
|
||||||
[in] DWORD dwServiceType,
|
unsigned long dwServiceType,
|
||||||
[in] DWORD dwStartType,
|
unsigned long dwStartType,
|
||||||
[in] DWORD dwErrorControl,
|
unsigned long dwErrorControl,
|
||||||
[in, string, unique] LPCWSTR lpBinaryPathName,
|
wchar_t *lpBinaryPathName,
|
||||||
[in, string, unique] LPCWSTR lpLoadOrderGroup,
|
wchar_t *lpLoadOrderGroup,
|
||||||
[in, out, unique] LPDWORD lpdwTagId,
|
unsigned long *lpdwTagId, /* in, out, unique */
|
||||||
[in, size_is(dwDependenciesLength), unique] LPCWSTR lpDependencies,
|
wchar_t *lpDependencies,
|
||||||
[in] DWORD dwDependenciesLength,
|
unsigned long dwDependenciesLength,
|
||||||
[in, string, unique] LPCWSTR lpServiceStartName,
|
wchar_t *lpServiceStartName,
|
||||||
[in, size_is(dwPasswordLength), unique] LPCWSTR lpPassword,
|
wchar_t *lpPassword,
|
||||||
[in] DWORD dwPasswordLength,
|
unsigned long dwPasswordLength,
|
||||||
[in, string, unique] LPCWSTR lpDisplayName)
|
wchar_t *lpDisplayName)
|
||||||
{
|
{
|
||||||
|
DPRINT1("ScmrChangeServiceConfigW() called\n");
|
||||||
|
DPRINT1("dwServiceType = %lu\n", dwServiceType);
|
||||||
|
DPRINT1("dwStartType = %lu\n", dwStartType);
|
||||||
|
DPRINT1("dwErrorControl = %lu\n", dwErrorControl);
|
||||||
|
DPRINT1("lpBinaryPathName = %S\n", lpBinaryPathName);
|
||||||
|
DPRINT1("lpLoadOrderGroup = %S\n", lpLoadOrderGroup);
|
||||||
|
DPRINT1("lpDisplayName = %S\n", lpDisplayName);
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static DWORD
|
static DWORD
|
||||||
|
@ -710,9 +717,14 @@ ScmrCreateServiceW(handle_t BindingHandle,
|
||||||
/* FIXME: Write tag */
|
/* FIXME: Write tag */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Write dependencies */
|
||||||
if (lpDependencies != NULL && *lpDependencies != 0)
|
if (lpDependencies != NULL && *lpDependencies != 0)
|
||||||
{
|
{
|
||||||
/* FIXME: Write dependencies */
|
dwError = ScmWriteDependencies(hServiceKey,
|
||||||
|
lpDependencies,
|
||||||
|
dwDependenciesLength);
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpPassword != NULL)
|
if (lpPassword != NULL)
|
||||||
|
|
|
@ -32,9 +32,11 @@ typedef struct _SERVICE
|
||||||
} SERVICE, *PSERVICE;
|
} SERVICE, *PSERVICE;
|
||||||
|
|
||||||
|
|
||||||
/* services.c */
|
/* config.c */
|
||||||
|
|
||||||
VOID PrintString(LPCSTR fmt, ...);
|
DWORD ScmWriteDependencies(HKEY hServiceKey,
|
||||||
|
LPWSTR lpDependencies,
|
||||||
|
DWORD dwDependenciesLength);
|
||||||
|
|
||||||
|
|
||||||
/* database.c */
|
/* database.c */
|
||||||
|
@ -54,5 +56,11 @@ DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
||||||
VOID ScmStartRpcServer(VOID);
|
VOID ScmStartRpcServer(VOID);
|
||||||
|
|
||||||
|
|
||||||
|
/* services.c */
|
||||||
|
|
||||||
|
VOID PrintString(LPCSTR fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>advapi32</library>
|
<library>advapi32</library>
|
||||||
<library>rpcrt4</library>
|
<library>rpcrt4</library>
|
||||||
|
<file>config.c</file>
|
||||||
<file>database.c</file>
|
<file>database.c</file>
|
||||||
<file>rpcserver.c</file>
|
<file>rpcserver.c</file>
|
||||||
<file>services.c</file>
|
<file>services.c</file>
|
||||||
|
|
Loading…
Reference in a new issue