[CSRSRV]
[reactos.git] / subsystems / win32 / csrsrv / procsup.c
index 97dd0cb..fe96ddb 100644 (file)
@@ -268,8 +268,8 @@ CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
     {
         /* Call the generic cleanup code */
         DPRINT1("Should kill process: %p\n", CsrProcess);
-        CsrProcessRefcountZero(CsrProcess);
         CsrAcquireProcessLock();
+        CsrProcessRefcountZero(CsrProcess);
     }
 }
 
@@ -305,7 +305,7 @@ CsrAllocateProcess(VOID)
     if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5;
 
     /* Increase the reference count */
-    CsrProcess->ReferenceCount++;
+    CsrLockedReferenceProcess(CsrProcess);
 
     /* Initialize the Thread List */
     InitializeListHead(&CsrProcess->ThreadList);
@@ -451,11 +451,8 @@ CsrRemoveProcess(IN PCSR_PROCESS CsrProcess)
  * The CsrInsertProcess routine inserts a CSR Process into the Process List
  * and notifies Server DLLs of the creation of a new CSR Process.
  *
- * @param Parent
- *        Optional pointer to the CSR Process creating this CSR Process.
- *
- * @param CurrentProcess
- *        Optional pointer to the current CSR Process.
+ * @param ParentProcess
+ *        Optional pointer to the Parent Process creating this CSR Process.
  *
  * @param CsrProcess
  *        Pointer to the CSR Process which is to be inserted.
@@ -467,17 +464,13 @@ CsrRemoveProcess(IN PCSR_PROCESS CsrProcess)
  *--*/
 VOID
 NTAPI
-CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,   // ParentProcess
-                 IN PCSR_PROCESS CurrentProcess OPTIONAL,   // CallingProcess
-                 IN PCSR_PROCESS CsrProcess)    // Process
+CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
+                 IN PCSR_PROCESS CsrProcess)
 {
     PCSR_SERVER_DLL ServerDll;
     ULONG i;
     ASSERT(ProcessStructureListLocked());
 
-    /* Set the parent */
-    CsrProcess->Parent = Parent;
-
     /* Insert it into the Root List */
     InsertTailList(&CsrRootProcess->ListLink, &CsrProcess->ListLink);
 
@@ -490,7 +483,7 @@ CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,   // ParentProcess
         /* Make sure it's valid and that it has callback */
         if (ServerDll && ServerDll->NewProcessCallback)
         {
-            ServerDll->NewProcessCallback(CurrentProcess, CsrProcess);
+            ServerDll->NewProcessCallback(ParentProcess, CsrProcess);
         }
     }
 }
@@ -706,7 +699,7 @@ CsrCreateProcess(IN HANDLE hProcess,
     CsrSetBackgroundPriority(CsrProcess);
 
     /* Insert the Process */
-    CsrInsertProcess(NULL, CurrentProcess, CsrProcess);
+    CsrInsertProcess(CurrentProcess, CsrProcess);
 
     /* Release lock and return */
     CsrReleaseProcessLock();
@@ -1007,7 +1000,7 @@ CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL,
  * @param CsrThread
  *        Pointer to the CSR Thread to impersonate.
  *
- * @return TRUE if impersionation suceeded, false otherwise.
+ * @return TRUE if impersonation succeeded, false otherwise.
  *
  * @remarks Impersonation can be recursive.
  *
@@ -1079,7 +1072,7 @@ CsrLockProcessByClientId(IN HANDLE Pid,
 {
     PLIST_ENTRY NextEntry;
     PCSR_PROCESS CurrentProcess = NULL;
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_UNSUCCESSFUL;
 
     /* Acquire the lock */
     CsrAcquireProcessLock();
@@ -1300,7 +1293,7 @@ CsrShutdownProcesses(IN PLUID CallerLuid,
         if (!CsrProcess) break;
 
         /* Increase reference to process */
-        CsrProcess->ReferenceCount++;
+        CsrLockedReferenceProcess(CsrProcess);
 
         FirstTry = TRUE;
         while (TRUE)