[ros-diffs] [fireball] 33945: Oriol Pique <oripipa at yahoo.es> - Minor patch to HEAP_GetPtr to include magic value in debug output. - Fixing the parameters checking in HEAP_InitSubHeap (it is currently not used - put between #if 0 / #endif ). - Correcting HEAP_FindFreeBlock which was logging error message as warning (while still returning NULL to caller) by changing severity of logged message. - Implementing RtlEnumProcessHeaps (previously stubbed out). - Fixing sanity checks in and implementation of RtlGetProcessHeaps (previously the function was not checking for the counter value, and also was not assigning anything to the returned value; now this seems to be corrected. - Fixing RtlValidateProcessHeaps implementation (the function was stubbed out because (most probably, I wasn't able to find a bug mentioning this) it was previously using a global lock for all heaps (which probably could cause some problems in the kernel), now it only locks heaps belonging to the given process - and this is the correct behaviour. Aleksey Bragin <aleksey at reactos.org> - Fix typo in ntuser.c, and low severity of debug message. See issue #2964 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Jun 12 11:35:25 CEST 2008


Author: fireball
Date: Thu Jun 12 04:35:24 2008
New Revision: 33945

URL: http://svn.reactos.org/svn/reactos?rev=33945&view=rev
Log:
Oriol Pique <oripipa at yahoo.es>
- Minor patch to HEAP_GetPtr to include magic value in debug output.
- Fixing the parameters checking in HEAP_InitSubHeap (it is currently not used - put between #if 0 / #endif ).
- Correcting HEAP_FindFreeBlock which was logging error message as warning (while still returning NULL to caller) by changing severity of logged message.
- Implementing RtlEnumProcessHeaps (previously stubbed out).
- Fixing sanity checks in and implementation of RtlGetProcessHeaps (previously
the function was not checking for the counter value, and also was not assigning anything to the returned value; now this seems to be corrected.
- Fixing RtlValidateProcessHeaps implementation (the function was stubbed out because (most probably, I wasn't able to find a bug mentioning this) it was previously using a global lock for all heaps (which probably could cause some problems in the kernel), now it only locks heaps belonging to the given process - and this is the correct behaviour.

Aleksey Bragin <aleksey at reactos.org>
- Fix typo in ntuser.c, and low severity of debug message.
See issue #2964 for more details.

Modified:
    trunk/reactos/lib/rtl/heap.c
    trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c

Modified: trunk/reactos/lib/rtl/heap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=33945&r1=33944&r2=33945&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Thu Jun 12 04:35:24 2008
@@ -335,7 +335,8 @@
     HEAP *heapPtr = (HEAP *)heap;
     if (!heapPtr || (heapPtr->magic != HEAP_MAGIC))
     {
-        ERR("Invalid heap %p!\n", heap );
+        ERR("Invalid heap %p, magic:%4s!\n", heap,heapPtr->magic );
+        //KeDumpStackFrames(NULL);
         return NULL;
     }
     if (TRACE_ON(heap) && !HEAP_IsRealArena( heapPtr, 0, NULL, NOISY ))
@@ -595,8 +596,8 @@
     int i;
     NTSTATUS Status;
 
-#if 0
-    if (ZwAllocateVirtualMemory( NtCurrentProcess(), &address, 0,
+#if 1
+    if (address==NULL && ZwAllocateVirtualMemory( NtCurrentProcess(), &address, 0,
                                  &commitSize, MEM_COMMIT, PAGE_READWRITE ))
     {
         WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address );
@@ -775,7 +776,7 @@
 
     if (!(heap->flags & HEAP_GROWABLE))
     {
-        WARN("Not enough space in heap %p for %08lx bytes\n", heap, size );
+        ERR("Not enough space in heap %p for %08lx bytes\n", heap, size );
         return NULL;
     }
     /* make sure that we have a big enough size *committed* to fit another
@@ -1595,26 +1596,23 @@
 RtlEnumProcessHeaps(PHEAP_ENUMERATION_ROUTINE HeapEnumerationRoutine,
                     PVOID lParam)
 {
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DbgBreakPoint();
-    return STATUS_SUCCESS;
-#if 0
+
+#if 1
    NTSTATUS Status = STATUS_SUCCESS;
-   HEAP** pptr;
-
-   RtlEnterHeapLock(&RtlpProcessHeapsListLock);
-
-   for (pptr = (HEAP**)&NtCurrentPeb()->ProcessHeaps; *pptr; pptr = &(*pptr)->next)
-   {
-      Status = HeapEnumerationRoutine(*pptr,lParam);
-      if (!NT_SUCCESS(Status))
-         break;
-   }
-
-   RtlLeaveHeapLock(&RtlpProcessHeapsListLock);
+
+   struct list *ptr=NULL;
+   RtlEnterHeapLock(&processHeap->critSection);
+   Status=HeapEnumerationRoutine(processHeap,lParam);
+      LIST_FOR_EACH( ptr, &processHeap->entry )
+      {
+             if (!NT_SUCCESS(Status))
+                break;
+          Status = HeapEnumerationRoutine(ptr,lParam);
+
+      }
+
+
+   RtlLeaveHeapLock(&processHeap->critSection);
 
    return Status;
 #endif
@@ -1630,17 +1628,26 @@
 {
     ULONG total = 1;  /* main heap */
     struct list *ptr;
-
+    ULONG i=0;
     RtlEnterHeapLock( &processHeap->critSection );
     LIST_FOR_EACH( ptr, &processHeap->entry ) total++;
-    if (total <= count)
-    {
-        *heaps++ = processHeap;
+    //if (total <= count)
+    {
+        *(heaps++) = processHeap;
+        i++;
         LIST_FOR_EACH( ptr, &processHeap->entry )
-            *heaps++ = LIST_ENTRY( ptr, HEAP, entry );
+        {
+            if(i>=count)
+            {
+                break;
+            }
+            i++;
+            *(heaps++) = LIST_ENTRY( ptr, HEAP, entry );
+
+        }
     }
     RtlLeaveHeapLock( &processHeap->critSection );
-    return total;
+    return i;
 }
 
 
@@ -1650,19 +1657,15 @@
 BOOLEAN NTAPI
 RtlValidateProcessHeaps(VOID)
 {
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DPRINT1("UNIMPLEMENTED\n");
-    DbgBreakPoint();
-    return STATUS_SUCCESS;
-#if 0
+
+#if 1
    BOOLEAN Result = TRUE;
    HEAP ** pptr;
 
-   RtlEnterHeapLock(&RtlpProcessHeapsListLock);
-
-   for (pptr = (HEAP**)&NtCurrentPeb()->ProcessHeaps; *pptr; pptr = &(*pptr)->next)
+
+   RtlEnterHeapLock( &processHeap->critSection );
+
+   for (pptr = (HEAP**)&NtCurrentPeb()->ProcessHeaps; *pptr; pptr++)
    {
       if (!RtlValidateHeap(*pptr, 0, NULL))
       {
@@ -1671,8 +1674,8 @@
       }
    }
 
-   RtlLeaveHeapLock (&RtlpProcessHeapsListLock);
-
+
+    RtlLeaveHeapLock( &processHeap->critSection );
    return Result;
 #endif
 }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c?rev=33945&r1=33944&r2=33945&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] Thu Jun 12 04:35:24 2008
@@ -63,7 +63,7 @@
       if (gpsi)
       {
          RtlZeroMemory(gpsi, sizeof(SERVERINFO));
-         DPRINT1("Gloabal Server Data -> %x\n", gpsi);
+         DPRINT("Global Server Data -> %x\n", gpsi);
       }
    }
    return STATUS_SUCCESS;



More information about the Ros-diffs mailing list