mirror of
https://github.com/reactos/reactos.git
synced 2025-06-26 22:29:44 +00:00
[SERVICES]
- Allow changing the image path with ChangeServiceConfig. Fixes timeout that shouldn't actually be a timeout in advapi32:service test. See issue #6646 for more details. svn path=/trunk/; revision=54348
This commit is contained in:
parent
6293041a3f
commit
3f5b04a9d5
1 changed files with 64 additions and 57 deletions
|
@ -1730,6 +1730,7 @@ DWORD RChangeServiceConfigW(
|
||||||
PSERVICE lpService = NULL;
|
PSERVICE lpService = NULL;
|
||||||
HKEY hServiceKey = NULL;
|
HKEY hServiceKey = NULL;
|
||||||
LPWSTR lpDisplayNameW = NULL;
|
LPWSTR lpDisplayNameW = NULL;
|
||||||
|
LPWSTR lpImagePathW = NULL;
|
||||||
|
|
||||||
DPRINT("RChangeServiceConfigW() called\n");
|
DPRINT("RChangeServiceConfigW() called\n");
|
||||||
DPRINT("dwServiceType = %lu\n", dwServiceType);
|
DPRINT("dwServiceType = %lu\n", dwServiceType);
|
||||||
|
@ -1852,39 +1853,34 @@ DWORD RChangeServiceConfigW(
|
||||||
lpService->dwErrorControl = dwErrorControl;
|
lpService->dwErrorControl = dwErrorControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* FIXME: set the new ImagePath value */
|
|
||||||
|
|
||||||
/* Set the image path */
|
|
||||||
if (dwServiceType & SERVICE_WIN32)
|
|
||||||
{
|
|
||||||
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
|
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
|
||||||
{
|
{
|
||||||
|
/* Set the image path */
|
||||||
|
lpImagePathW = lpBinaryPathName;
|
||||||
|
|
||||||
|
if (lpService->Status.dwServiceType & SERVICE_DRIVER)
|
||||||
|
{
|
||||||
|
dwError = ScmCanonDriverImagePath(lpService->dwStartType,
|
||||||
|
lpBinaryPathName,
|
||||||
|
&lpImagePathW);
|
||||||
|
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
dwError = RegSetValueExW(hServiceKey,
|
dwError = RegSetValueExW(hServiceKey,
|
||||||
L"ImagePath",
|
L"ImagePath",
|
||||||
0,
|
0,
|
||||||
REG_EXPAND_SZ,
|
REG_EXPAND_SZ,
|
||||||
(LPBYTE)lpBinaryPathName,
|
(LPBYTE)lpImagePathW,
|
||||||
(wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR));
|
(wcslen(lpImagePathW) + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (lpImagePathW != lpBinaryPathName)
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpImagePathW);
|
||||||
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (dwServiceType & SERVICE_DRIVER)
|
|
||||||
{
|
|
||||||
if (lpImagePath != NULL && *lpImagePath != 0)
|
|
||||||
{
|
|
||||||
dwError = RegSetValueExW(hServiceKey,
|
|
||||||
L"ImagePath",
|
|
||||||
0,
|
|
||||||
REG_EXPAND_SZ,
|
|
||||||
(LPBYTE)lpImagePath,
|
|
||||||
(wcslen(lpImagePath) + 1) *sizeof(WCHAR));
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set the group name */
|
/* Set the group name */
|
||||||
if (lpLoadOrderGroup != NULL && *lpLoadOrderGroup != 0)
|
if (lpLoadOrderGroup != NULL && *lpLoadOrderGroup != 0)
|
||||||
|
@ -3258,7 +3254,8 @@ DWORD RChangeServiceConfigA(
|
||||||
PSERVICE lpService = NULL;
|
PSERVICE lpService = NULL;
|
||||||
HKEY hServiceKey = NULL;
|
HKEY hServiceKey = NULL;
|
||||||
LPWSTR lpDisplayNameW = NULL;
|
LPWSTR lpDisplayNameW = NULL;
|
||||||
// LPWSTR lpBinaryPathNameW = NULL;
|
LPWSTR lpBinaryPathNameW = NULL;
|
||||||
|
LPWSTR lpCanonicalImagePathW = NULL;
|
||||||
LPWSTR lpLoadOrderGroupW = NULL;
|
LPWSTR lpLoadOrderGroupW = NULL;
|
||||||
LPWSTR lpDependenciesW = NULL;
|
LPWSTR lpDependenciesW = NULL;
|
||||||
// LPWSTR lpPasswordW = NULL;
|
// LPWSTR lpPasswordW = NULL;
|
||||||
|
@ -3392,41 +3389,51 @@ DWORD RChangeServiceConfigA(
|
||||||
lpService->dwErrorControl = dwErrorControl;
|
lpService->dwErrorControl = dwErrorControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* FIXME: set the new ImagePath value */
|
|
||||||
|
|
||||||
/* Set the image path */
|
|
||||||
if (dwServiceType & SERVICE_WIN32)
|
|
||||||
{
|
|
||||||
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
|
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
|
||||||
{
|
{
|
||||||
lpBinaryPathNameW=HeapAlloc(GetProcessHeap(),0, (strlen(lpBinaryPathName)+1) * sizeof(WCHAR));
|
/* Set the image path */
|
||||||
MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, strlen(lpBinaryPathName)+1);
|
lpBinaryPathNameW = HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
(strlen(lpBinaryPathName) + 1) * sizeof(WCHAR));
|
||||||
|
if (lpBinaryPathNameW == NULL)
|
||||||
|
{
|
||||||
|
dwError = ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_ACP,
|
||||||
|
0,
|
||||||
|
lpBinaryPathName,
|
||||||
|
-1,
|
||||||
|
lpBinaryPathNameW,
|
||||||
|
strlen(lpBinaryPathName) + 1);
|
||||||
|
|
||||||
|
if (lpService->Status.dwServiceType & SERVICE_DRIVER)
|
||||||
|
{
|
||||||
|
dwError = ScmCanonDriverImagePath(lpService->dwStartType,
|
||||||
|
lpBinaryPathNameW,
|
||||||
|
&lpCanonicalImagePathW);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
|
||||||
|
|
||||||
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
lpBinaryPathNameW = lpCanonicalImagePathW;
|
||||||
|
}
|
||||||
|
|
||||||
dwError = RegSetValueExW(hServiceKey,
|
dwError = RegSetValueExW(hServiceKey,
|
||||||
L"ImagePath",
|
L"ImagePath",
|
||||||
0,
|
0,
|
||||||
REG_EXPAND_SZ,
|
REG_EXPAND_SZ,
|
||||||
(LPBYTE)lpBinaryPathNameW,
|
(LPBYTE)lpBinaryPathNameW,
|
||||||
(wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR));
|
(wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
|
||||||
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (dwServiceType & SERVICE_DRIVER)
|
|
||||||
{
|
|
||||||
if (lpImagePath != NULL && *lpImagePath != 0)
|
|
||||||
{
|
|
||||||
dwError = RegSetValueExW(hServiceKey,
|
|
||||||
L"ImagePath",
|
|
||||||
0,
|
|
||||||
REG_EXPAND_SZ,
|
|
||||||
(LPBYTE)lpImagePath,
|
|
||||||
(wcslen(lpImagePath) + 1) *sizeof(WCHAR));
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set the group name */
|
/* Set the group name */
|
||||||
if (lpLoadOrderGroup != NULL && *lpLoadOrderGroup != 0)
|
if (lpLoadOrderGroup != NULL && *lpLoadOrderGroup != 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue