From a7bb0605ae049e8f3416c2678fad0a457ad8d407 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 6 Nov 2005 18:21:00 +0000 Subject: [PATCH] - Read a services optional display name from the registry. - Fix return size bugs in GetServiceDisplayNameW and GetServiceKeyNameW. svn path=/trunk/; revision=19030 --- reactos/lib/advapi32/service/scm.c | 4 ++++ reactos/subsys/system/services/database.c | 22 +++++++++++++++++++++- reactos/subsys/system/services/rpcserver.c | 8 ++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/reactos/lib/advapi32/service/scm.c b/reactos/lib/advapi32/service/scm.c index dc6d020416d..6a4e7fa12cc 100644 --- a/reactos/lib/advapi32/service/scm.c +++ b/reactos/lib/advapi32/service/scm.c @@ -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; } diff --git a/reactos/subsys/system/services/database.c b/reactos/subsys/system/services/database.c index cfa46078ff4..48fba08989e 100644 --- a/reactos/subsys/system/services/database.c +++ b/reactos/subsys/system/services/database.c @@ -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; diff --git a/reactos/subsys/system/services/rpcserver.c b/reactos/subsys/system/services/rpcserver.c index 2e2d1911bad..73442fd467a 100644 --- a/reactos/subsys/system/services/rpcserver.c +++ b/reactos/subsys/system/services/rpcserver.c @@ -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); }