- Fix crashes in calls to ScmAssignNewTag.
authorEric Kohl <eric.kohl@reactos.org>
Sun, 1 Jan 2006 15:32:40 +0000 (15:32 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 1 Jan 2006 15:32:40 +0000 (15:32 +0000)
- ScmrCreateServiceW: Assign a group to the service.

svn path=/trunk/; revision=20516

reactos/subsys/system/services/rpcserver.c

index 396af8d..d8e2245 100644 (file)
@@ -220,12 +220,11 @@ ScmCheckAccess(SC_HANDLE Handle,
 
 
 DWORD
-ScmAssignNewTag(LPWSTR lpServiceGroup,
-                LPDWORD lpdwTagId)
+ScmAssignNewTag(PSERVICE lpService)
 {
     /* FIXME */
-    DPRINT("Assigning new tag in group %S\n", lpServiceGroup);
-    *lpdwTagId = 0;
+    DPRINT("Assigning new tag to service %S\n", lpService->lpServiceName);
+    lpService->dwTag = 0;
     return ERROR_SUCCESS;
 }
 
@@ -927,10 +926,10 @@ ScmrChangeServiceConfigW(handle_t BiningHandle,
 
     if (lpdwTagId != NULL)
     {
-        dwError = ScmAssignNewTag(lpService->lpGroup->lpGroupName,
-                                  &lpService->dwTag);
+        dwError = ScmAssignNewTag(lpService);
         if (dwError != ERROR_SUCCESS)
             goto done;
+
         dwError = RegSetValueExW(hServiceKey,
                                  L"Tag",
                                  0,
@@ -939,6 +938,7 @@ ScmrChangeServiceConfigW(handle_t BiningHandle,
                                  sizeof(DWORD));
         if (dwError != ERROR_SUCCESS)
             goto done;
+
         *lpdwTagId = lpService->dwTag;
     }
 
@@ -1073,6 +1073,23 @@ ScmrCreateServiceW(handle_t BindingHandle,
         wcscpy(lpService->lpDisplayName, lpDisplayName);
     }
 
+    /* Assign the service to a group */
+    if (lpLoadOrderGroup != NULL && *lpLoadOrderGroup != 0)
+    {
+        dwError = ScmSetServiceGroup(lpService,
+                                     lpLoadOrderGroup);
+        if (dwError != ERROR_SUCCESS)
+            goto done;
+    }
+
+    /* Assign a new tag */
+    if (lpdwTagId != NULL)
+    {
+        dwError = ScmAssignNewTag(lpService);
+        if (dwError != ERROR_SUCCESS)
+            goto done;
+    }
+
     /* Write service data to the registry */
     /* Create the service key */
     dwError = ScmCreateServiceKey(lpServiceName,
@@ -1161,10 +1178,6 @@ ScmrCreateServiceW(handle_t BindingHandle,
 
     if (lpdwTagId != NULL)
     {
-        dwError = ScmAssignNewTag(lpService->lpGroup->lpGroupName,
-                                  &lpService->dwTag);
-        if (dwError != ERROR_SUCCESS)
-            goto done;
         dwError = RegSetValueExW(hServiceKey,
                                  L"Tag",
                                  0,