Do only for process handles detach/attach the process. Some handles
authorHartmut Birr <osexpert@googlemail.com>
Wed, 27 Nov 2002 20:52:29 +0000 (20:52 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Wed, 27 Nov 2002 20:52:29 +0000 (20:52 +0000)
needs the correct process on close/delete. Only for process handles
is it possible that ObCloseAllHandles is called recursively.

svn path=/trunk/; revision=3800

reactos/ntoskrnl/ob/handle.c

index 10d4df1..a8a8338 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: handle.c,v 1.41 2002/10/01 19:27:25 chorns Exp $
+/* $Id: handle.c,v 1.42 2002/11/27 20:52:29 hbirr Exp $
  *
  * COPYRIGHT:          See COPYING in the top level directory
  * PROJECT:            ReactOS kernel
@@ -278,6 +278,7 @@ VOID ObCloseAllHandles(PEPROCESS Process)
    PHANDLE_BLOCK current;
    ULONG i;
    PVOID ObjectBody;
+   BOOLEAN IsProcessHandle;
    
    DPRINT("ObCloseAllHandles(Process %x)\n", Process);
    
@@ -313,8 +314,16 @@ VOID ObCloseAllHandles(PEPROCESS Process)
                  current->handles[i].ObjectBody = NULL;
                  
                  KeReleaseSpinLock(&HandleTable->ListLock, oldIrql);
-                 KeDetachProcess();
                  
+                 if (Header->ObjectType == PsProcessType)
+                 {
+                    IsProcessHandle = TRUE;
+                    KeDetachProcess();
+                 }
+                 else
+                 {
+                    IsProcessHandle = FALSE;
+                 }
                  if ((Header->ObjectType != NULL) &&
                      (Header->ObjectType->Close != NULL))
                    {
@@ -323,7 +332,10 @@ VOID ObCloseAllHandles(PEPROCESS Process)
                    }
                  
                  ObDereferenceObject(ObjectBody);
-                 KeAttachProcess(Process);
+                 if (IsProcessHandle)
+                 {
+                    KeAttachProcess(Process);
+                 }
                  KeAcquireSpinLock(&HandleTable->ListLock, &oldIrql);
                  current_entry = &HandleTable->ListHead;
                  break;