[services] Set the given service start name or LocalSystem for a new service.
authorEric Kohl <eric.kohl@reactos.org>
Wed, 30 Dec 2009 17:17:58 +0000 (17:17 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 30 Dec 2009 17:17:58 +0000 (17:17 +0000)
svn path=/trunk/; revision=44816

reactos/base/system/services/rpcserver.c

index e11507a..d9dcfa3 100644 (file)
@@ -1733,6 +1733,7 @@ DWORD RCreateServiceW(
     SC_HANDLE hServiceHandle = NULL;
     LPWSTR lpImagePath = NULL;
     HKEY hServiceKey = NULL;
+    LPWSTR lpObjectName;
 
     DPRINT("RCreateServiceW() called\n");
     DPRINT("lpServiceName = %S\n", lpServiceName);
@@ -1973,16 +1974,16 @@ DWORD RCreateServiceW(
             goto done;
     }
 
-    /* FIXME: Handle lpServiceStartName propertly! */
-    /* If a non driver and NULL for lpServiceStartName, write ObjectName as LocalSystem */
-    if ((dwServiceType & SERVICE_WIN32) && (!lpServiceStartName))
+    /* Write service start name */
+    if (dwServiceType & SERVICE_WIN32)
     {
+        lpObjectName = (lpServiceStartName != NULL) ? (LPWSTR)lpServiceStartName : L"LocalSystem";
         dwError = RegSetValueExW(hServiceKey,
                                  L"ObjectName",
                                  0,
                                  REG_SZ,
-                                 (LPBYTE)L"LocalSystem",
-                                 24);
+                                 (LPBYTE)lpObjectName,
+                                 (wcslen(lpObjectName) + 1) * sizeof(WCHAR));
         if (dwError != ERROR_SUCCESS)
             goto done;
     }