[NTOS:EX]
authorDmitry Chapyshev <dmitry@reactos.org>
Wed, 31 Aug 2016 21:29:40 +0000 (21:29 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Wed, 31 Aug 2016 21:29:40 +0000 (21:29 +0000)
- Try to fix CORE-11906
See issue 11906 for more details.

svn path=/trunk/; revision=72528

reactos/ntoskrnl/ex/sysinfo.c

index 3f6d82c..274fc69 100644 (file)
@@ -1241,41 +1241,64 @@ QSI_DEF(SystemHandleInformation)
         /* Enter a critical region */
         KeEnterCriticalRegion();
 
-        /* Set the initial value and loop the entries */
-        Handle.Value = 0;
-        while ((HandleTableEntry = ExpLookupHandleTableEntry(Process->ObjectTable, Handle)))
+        _SEH2_TRY
         {
-            /* Validate the entry */
-            if ((HandleTableEntry->Object) &&
-                (HandleTableEntry->NextFreeTableEntry != -2))
+            /* Set the initial value and loop the entries */
+            Handle.Value = 0;
+            while ((HandleTableEntry = ExpLookupHandleTableEntry(Process->ObjectTable, Handle)))
             {
-                /* Lock the entry */
-                if (ExpLockHandleTableEntry(Process->ObjectTable, HandleTableEntry))
+                /* Validate the entry */
+                if ((HandleTableEntry->Object) &&
+                    (HandleTableEntry->NextFreeTableEntry != -2))
                 {
-                    POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
+                    /* Lock the entry */
+                    if (ExpLockHandleTableEntry(Process->ObjectTable, HandleTableEntry))
+                    {
+                        _SEH2_TRY
+                        {
+                            POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
+
+                            /* Filling handle information */
+                            HandleInformation->Handles[Index].UniqueProcessId =
+                                (USHORT)(ULONG_PTR) Process->UniqueProcessId;
+
+                            HandleInformation->Handles[Index].CreatorBackTraceIndex = 0;
+
+                            HandleInformation->Handles[Index].ObjectTypeIndex =
+                                (UCHAR) ObjectHeader->Type->Index;
+
+                            HandleInformation->Handles[Index].HandleAttributes =
+                                HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
+
+                            HandleInformation->Handles[Index].HandleValue =
+                                (USHORT)(ULONG_PTR) Handle.GenericHandleOverlay;
 
-                    /* Filling handle information */
-                    HandleInformation->Handles[Index].UniqueProcessId = (USHORT)(ULONG_PTR) Process->UniqueProcessId;
-                    HandleInformation->Handles[Index].CreatorBackTraceIndex = 0;
-                    HandleInformation->Handles[Index].ObjectTypeIndex = (UCHAR) ObjectHeader->Type->Index;
-                    HandleInformation->Handles[Index].HandleAttributes = HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
-                    HandleInformation->Handles[Index].HandleValue = (USHORT)(ULONG_PTR) Handle.GenericHandleOverlay;
-                    HandleInformation->Handles[Index].Object = &ObjectHeader->Body;
-                    HandleInformation->Handles[Index].GrantedAccess = HandleTableEntry->GrantedAccess;
+                            HandleInformation->Handles[Index].Object = &ObjectHeader->Body;
 
-                    /* Unlock it */
-                    ExUnlockHandleTableEntry(Process->ObjectTable, HandleTableEntry);
+                            HandleInformation->Handles[Index].GrantedAccess =
+                                HandleTableEntry->GrantedAccess;
 
-                    ++Index;
+                            ++Index;
+                        }
+                        _SEH2_FINALLY
+                        {
+                            /* Unlock it */
+                            ExUnlockHandleTableEntry(Process->ObjectTable, HandleTableEntry);
+                        }
+                        _SEH2_END;
+                    }
                 }
-            }
 
-            /* Go to the next entry */
-            Handle.Value += sizeof(HANDLE);
+                /* Go to the next entry */
+                Handle.Value += sizeof(HANDLE);
+            }
         }
-
-        /* Leave the critical region */
-        KeLeaveCriticalRegion();
+        _SEH2_FINALLY
+        {
+            /* Leave the critical region */
+            KeLeaveCriticalRegion();
+        }
+        _SEH2_END;
 
         Process = PsGetNextProcess(Process);
     }