[NTOSKRNL] Add a raw implementation of !irpfind in kdbg
[reactos.git] / ntoskrnl / ps / psnotify.c
index c7cd2f9..8c9c1a9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Kernel
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/ps/notify.c
+ * FILE:            ntoskrnl/ps/psnotify.c
  * PURPOSE:         Process Manager: Callbacks to Registered Clients (Drivers)
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
  *                  Thomas Weidenmueller (w3seek@reactos.org)
@@ -48,35 +48,32 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
             if (!CallBack) continue;
 
             /* Check it this is a matching block */
-            if (ExGetCallBackBlockRoutine(CallBack) != (PVOID)NotifyRoutine)
+            if (ExGetCallBackBlockRoutine(CallBack) == (PVOID)NotifyRoutine)
             {
-                /* It's not, try the next one */
-                continue;
-            }
+                /* Try removing it if it matches */
+                if (ExCompareExchangeCallBack(&PspProcessNotifyRoutine[i],
+                                              NULL,
+                                              CallBack))
+                {
+                    /* Decrement the number of routines */
+                    InterlockedDecrement((PLONG)&PspProcessNotifyRoutineCount);
 
-            /* It is, clear the current routine */
-            if (ExCompareExchangeCallBack(&PspProcessNotifyRoutine[i],
-                                          NULL,
-                                          CallBack))
-            {
-                /* Decrement the number of routines */
-                InterlockedDecrement((PLONG)&PspProcessNotifyRoutineCount);
+                    /* Dereference the block */
+                    ExDereferenceCallBackBlock(&PspProcessNotifyRoutine[i],
+                                               CallBack);
+
+                    /* Wait for active callbacks */
+                    ExWaitForCallBacks(CallBack);
+
+                    /* Free the callback and exit */
+                    ExFreeCallBack(CallBack);
+                    return STATUS_SUCCESS;
+                }
 
                 /* Dereference the block */
                 ExDereferenceCallBackBlock(&PspProcessNotifyRoutine[i],
                                            CallBack);
-
-                /* Wait for actice callbacks */
-                ExWaitForCallBacks(CallBack);
-
-                /* Free the callback and exit */
-                ExFreeCallBack (CallBack);
-                return STATUS_SUCCESS;
             }
-
-            /* Dereference the block */
-            ExDereferenceCallBackBlock(&PspProcessNotifyRoutine[i],
-                                       CallBack);
         }
 
         /* We didn't find any matching block */