[SERVICES]

ScmWriteDependencies:
- Fixed an off-by-one bug. This bug caused a wrong calculation of the 'DependOnGroup' value data length. Group dependencies were not written properly to the registry.

- Write 'DependOnService' and 'DependOnService' values to the registry only if the dependency strings are not empty. Delete a value if the corresponding dependency string is empty.

This fixes another winetest.

svn path=/trunk/; revision=51172
This commit is contained in:
Eric Kohl 2011-03-27 13:12:12 +00:00
parent 828d04705a
commit 4288ba6306

View file

@ -125,7 +125,7 @@ ScmWriteDependencies(HKEY hServiceKey,
lpDst = lpGroupDeps; lpDst = lpGroupDeps;
while (*lpSrc != 0) while (*lpSrc != 0)
{ {
dwLength = wcslen(lpSrc); dwLength = wcslen(lpSrc) + 1;
if (*lpSrc == SC_GROUP_IDENTIFIERW) if (*lpSrc == SC_GROUP_IDENTIFIERW)
{ {
lpSrc++; lpSrc++;
@ -157,14 +157,24 @@ ScmWriteDependencies(HKEY hServiceKey,
*lpDst = 0; *lpDst = 0;
dwServiceLength++; dwServiceLength++;
if (dwGroupLength > 1)
{
dwError = RegSetValueExW(hServiceKey, dwError = RegSetValueExW(hServiceKey,
L"DependOnGroup", L"DependOnGroup",
0, 0,
REG_MULTI_SZ, REG_MULTI_SZ,
(LPBYTE)lpGroupDeps, (LPBYTE)lpGroupDeps,
dwGroupLength * sizeof(WCHAR)); dwGroupLength * sizeof(WCHAR));
}
else
{
RegDeleteValueW(hServiceKey,
L"DependOnGroup");
}
if (dwError == ERROR_SUCCESS) if (dwError == ERROR_SUCCESS)
{
if (dwServiceLength > 1)
{ {
dwError = RegSetValueExW(hServiceKey, dwError = RegSetValueExW(hServiceKey,
L"DependOnService", L"DependOnService",
@ -173,6 +183,12 @@ ScmWriteDependencies(HKEY hServiceKey,
(LPBYTE)lpServiceDeps, (LPBYTE)lpServiceDeps,
dwServiceLength * sizeof(WCHAR)); dwServiceLength * sizeof(WCHAR));
} }
else
{
RegDeleteValueW(hServiceKey,
L"DependOnService");
}
}
HeapFree(GetProcessHeap(), 0, lpGroupDeps); HeapFree(GetProcessHeap(), 0, lpGroupDeps);
} }