[SERVICES]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 31 Jul 2011 10:29:41 +0000 (10:29 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 31 Jul 2011 10:29:41 +0000 (10:29 +0000)
- ScmCreateOrReferenceServiceImage: Link the SERVICE_IMAGE struct to the SERVICE struct in the create and the reference case. Otherwise only the first service started from an image gets a valid pImage pointer.
- Add some debug code.

svn path=/trunk/; revision=53004

reactos/base/system/services/database.c

index 51c8d2c..462cc25 100644 (file)
@@ -116,7 +116,7 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
     PLIST_ENTRY ImageEntry;
     PSERVICE_IMAGE CurrentImage;
 
-    DPRINT("ScmGetServiceImageByImagePath() called\n");
+    DPRINT("ScmGetServiceImageByImagePath(%S) called\n", lpImagePath);
 
     ImageEntry = ImageListHead.Flink;
     while (ImageEntry != &ImageListHead)
@@ -149,7 +149,7 @@ ScmCreateOrReferenceServiceImage(PSERVICE pService)
     NTSTATUS Status;
     DWORD dwError = ERROR_SUCCESS;
 
-    DPRINT("ScmCreateOrReferenceServiceImage()");
+    DPRINT("ScmCreateOrReferenceServiceImage(%p)\n", pService);
 
     RtlInitUnicodeString(&ImagePath, NULL);
 
@@ -211,18 +211,21 @@ ScmCreateOrReferenceServiceImage(PSERVICE pService)
         /* Append service record */
         InsertTailList(&ImageListHead,
                        &pServiceImage->ImageListEntry);
-
-        pService->lpImage = pServiceImage;
     }
     else
     {
-        /* Create a new service image */
-        pService->lpImage->dwImageRunCount++;
+        /* Increment the run counter */
+        pServiceImage->dwImageRunCount++;
     }
 
+    /* Link the service image to the service */
+    pService->lpImage = pServiceImage;
+
 done:;
     RtlFreeUnicodeString(&ImagePath);
 
+    DPRINT("ScmCreateOrReferenceServiceImage() done (Error: %lu)\n", dwError);
+
     return dwError;
 }
 
@@ -1076,6 +1079,8 @@ ScmStartUserModeService(PSERVICE Service,
     DWORD dwError = ERROR_SUCCESS;
     DWORD dwProcessId;
 
+    DPRINT("ScmStartUserModeService(%p)\n", Service);
+
     StartupInfo.cb = sizeof(StartupInfo);
     StartupInfo.lpReserved = NULL;
     StartupInfo.lpDesktop = NULL;