- Read a services optional display name from the registry.

- Fix return size bugs in GetServiceDisplayNameW and GetServiceKeyNameW.

svn path=/trunk/; revision=19030
This commit is contained in:
Eric Kohl 2005-11-06 18:21:00 +00:00
parent 316bd9523e
commit a7bb0605ae
3 changed files with 29 additions and 5 deletions

View file

@ -592,6 +592,8 @@ GetServiceDisplayNameW(SC_HANDLE hSCManager,
return FALSE;
}
(*lpcchBuffer)--;
return TRUE;
}
@ -644,6 +646,8 @@ GetServiceKeyNameW(SC_HANDLE hSCManager,
return FALSE;
}
(*lpcchBuffer)--;
return TRUE;
}

View file

@ -123,7 +123,7 @@ CreateGroupOrderListRoutine(PWSTR ValueName,
{
PSERVICE_GROUP Group;
DPRINT("IopGetGroupOrderList(%S, %x, %x, %x, %x, %x)\n",
DPRINT("CreateGroupOrderListRoutine(%S, %x, %x, %x, %x, %x)\n",
ValueName, ValueType, ValueData, ValueLength, Context, EntryContext);
if (ValueType == REG_BINARY &&
@ -253,6 +253,7 @@ CreateServiceListEntry(LPWSTR lpServiceName,
HKEY hServiceKey)
{
PSERVICE lpService = NULL;
LPWSTR lpDisplayName = NULL;
LPWSTR lpGroup = NULL;
DWORD dwSize;
DWORD dwError;
@ -326,6 +327,14 @@ CreateServiceListEntry(LPWSTR lpServiceName,
DPRINT("Group: %S\n", lpGroup);
dwError = ScmReadString(hServiceKey,
L"DisplayName",
&lpDisplayName);
if (dwError != ERROR_SUCCESS)
lpDisplayName = NULL;
DPRINT("Display name: %S\n", lpDisplayName);
dwError = ScmCreateNewServiceRecord(lpServiceName,
&lpService);
if (dwError != ERROR_SUCCESS)
@ -342,6 +351,12 @@ CreateServiceListEntry(LPWSTR lpServiceName,
lpGroup = NULL;
}
if (lpDisplayName != NULL)
{
lpService->lpDisplayName = lpDisplayName;
lpDisplayName = NULL;
}
DPRINT("ServiceName: '%S'\n", lpService->lpServiceName);
DPRINT("Group: '%S'\n", lpService->lpServiceGroup);
DPRINT("Start %lx Type %lx Tag %lx ErrorControl %lx\n",
@ -357,6 +372,9 @@ done:;
if (lpGroup != NULL)
HeapFree(GetProcessHeap(), 0, lpGroup);
if (lpDisplayName != NULL)
HeapFree(GetProcessHeap(), 0, lpDisplayName);
return dwError;
}
@ -456,6 +474,8 @@ ScmCreateServiceDatabase(VOID)
RegCloseKey(hServicesKey);
/* FIXME: Delete services that are marked for delete */
DPRINT("ScmCreateServiceDatabase() done\n");
return ERROR_SUCCESS;

View file

@ -969,10 +969,10 @@ ScmrGetServiceDisplayNameW(handle_t BindingHandle,
return ERROR_SERVICE_DOES_NOT_EXIST;
}
dwLength = wcslen(lpService->lpDisplayName);
dwLength = wcslen(lpService->lpDisplayName) + 1;
if (lpDisplayName != NULL &&
*lpcchBuffer > dwLength)
*lpcchBuffer >= dwLength)
{
wcscpy(lpDisplayName, lpService->lpDisplayName);
}
@ -1019,10 +1019,10 @@ ScmrGetServiceKeyNameW(handle_t BindingHandle,
return ERROR_SERVICE_DOES_NOT_EXIST;
}
dwLength = wcslen(lpService->lpServiceName);
dwLength = wcslen(lpService->lpServiceName) + 1;
if (lpServiceName != NULL &&
*lpcchBuffer > dwLength)
*lpcchBuffer >= dwLength)
{
wcscpy(lpServiceName, lpService->lpServiceName);
}