- Read a services optional display name from the registry.
- Fix return size bugs in GetServiceDisplayNameW and GetServiceKeyNameW.
Modified: trunk/reactos/lib/advapi32/service/scm.c
Modified: trunk/reactos/subsys/system/services/database.c
Modified: trunk/reactos/subsys/system/services/rpcserver.c

Modified: trunk/reactos/lib/advapi32/service/scm.c
--- trunk/reactos/lib/advapi32/service/scm.c	2005-11-06 17:58:08 UTC (rev 19029)
+++ trunk/reactos/lib/advapi32/service/scm.c	2005-11-06 18:21:00 UTC (rev 19030)
@@ -592,6 +592,8 @@
         return FALSE;
     }
 
+    (*lpcchBuffer)--;
+
     return TRUE;
 }
 
@@ -644,6 +646,8 @@
         return FALSE;
     }
 
+    (*lpcchBuffer)--;
+
     return TRUE;
 }
 

Modified: trunk/reactos/subsys/system/services/database.c
--- trunk/reactos/subsys/system/services/database.c	2005-11-06 17:58:08 UTC (rev 19029)
+++ trunk/reactos/subsys/system/services/database.c	2005-11-06 18:21:00 UTC (rev 19030)
@@ -123,7 +123,7 @@
 {
     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 @@
                        HKEY hServiceKey)
 {
     PSERVICE lpService = NULL;
+    LPWSTR lpDisplayName = NULL;
     LPWSTR lpGroup = NULL;
     DWORD dwSize;
     DWORD dwError;
@@ -326,6 +327,14 @@
 
     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 @@
         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 @@
     if (lpGroup != NULL)
         HeapFree(GetProcessHeap(), 0, lpGroup);
 
+    if (lpDisplayName != NULL)
+        HeapFree(GetProcessHeap(), 0, lpDisplayName);
+
     return dwError;
 }
 
@@ -456,6 +474,8 @@
 
     RegCloseKey(hServicesKey);
 
+    /* FIXME: Delete services that are marked for delete */
+
     DPRINT("ScmCreateServiceDatabase() done\n");
 
     return ERROR_SUCCESS;

Modified: trunk/reactos/subsys/system/services/rpcserver.c
--- trunk/reactos/subsys/system/services/rpcserver.c	2005-11-06 17:58:08 UTC (rev 19029)
+++ trunk/reactos/subsys/system/services/rpcserver.c	2005-11-06 18:21:00 UTC (rev 19030)
@@ -969,10 +969,10 @@
         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 @@
         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);
     }