[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:
Thomas Faber 2011-11-10 22:56:22 +00:00
parent 6293041a3f
commit 3f5b04a9d5

View file

@ -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 if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
/* FIXME: set the new ImagePath value */ {
/* Set the image path */
lpImagePathW = lpBinaryPathName;
/* Set the image path */ if (lpService->Status.dwServiceType & SERVICE_DRIVER)
if (dwServiceType & SERVICE_WIN32)
{
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
{ {
dwError = RegSetValueExW(hServiceKey, dwError = ScmCanonDriverImagePath(lpService->dwStartType,
L"ImagePath", lpBinaryPathName,
0, &lpImagePathW);
REG_EXPAND_SZ,
(LPBYTE)lpBinaryPathName,
(wcslen(lpBinaryPathName) + 1) * sizeof(WCHAR));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
} }
dwError = RegSetValueExW(hServiceKey,
L"ImagePath",
0,
REG_EXPAND_SZ,
(LPBYTE)lpImagePathW,
(wcslen(lpImagePathW) + 1) * sizeof(WCHAR));
if (lpImagePathW != lpBinaryPathName)
HeapFree(GetProcessHeap(), 0, lpImagePathW);
if (dwError != ERROR_SUCCESS)
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 if (lpBinaryPathName != NULL && *lpBinaryPathName != 0)
/* FIXME: set the new ImagePath value */ {
/* Set the image path */
lpBinaryPathNameW = HeapAlloc(GetProcessHeap(),
0,
(strlen(lpBinaryPathName) + 1) * sizeof(WCHAR));
if (lpBinaryPathNameW == NULL)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
goto done;
}
/* Set the image path */ MultiByteToWideChar(CP_ACP,
if (dwServiceType & SERVICE_WIN32) 0,
{ lpBinaryPathName,
if (lpBinaryPathName != NULL && *lpBinaryPathName != 0) -1,
lpBinaryPathNameW,
strlen(lpBinaryPathName) + 1);
if (lpService->Status.dwServiceType & SERVICE_DRIVER)
{ {
lpBinaryPathNameW=HeapAlloc(GetProcessHeap(),0, (strlen(lpBinaryPathName)+1) * sizeof(WCHAR)); dwError = ScmCanonDriverImagePath(lpService->dwStartType,
MultiByteToWideChar(CP_ACP, 0, lpBinaryPathName, -1, lpBinaryPathNameW, strlen(lpBinaryPathName)+1); lpBinaryPathNameW,
dwError = RegSetValueExW(hServiceKey, &lpCanonicalImagePathW);
L"ImagePath",
0, HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
REG_EXPAND_SZ,
(LPBYTE)lpBinaryPathNameW,
(wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR));
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
lpBinaryPathNameW = lpCanonicalImagePathW;
} }
dwError = RegSetValueExW(hServiceKey,
L"ImagePath",
0,
REG_EXPAND_SZ,
(LPBYTE)lpBinaryPathNameW,
(wcslen(lpBinaryPathNameW) + 1) * sizeof(WCHAR));
HeapFree(GetProcessHeap(), 0, lpBinaryPathNameW);
if (dwError != ERROR_SUCCESS)
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)