[ros-dev] heap.c

Oriol oripipa at yahoo.es
Sun Jan 13 16:11:28 CET 2008


here's the implementation and some corrections of some unimplemented
functions at lib/rtl/heap.c

NTSTATUS NTAPI
RtlEnumProcessHeaps(PHEAP_ENUMERATION_ROUTINE HeapEnumerationRoutine,
                    PVOID lParam)
{

#if 1
   NTSTATUS Status = STATUS_SUCCESS;

   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
}


/*
 * @implemented
 */
ULONG NTAPI
RtlGetProcessHeaps(ULONG count,
                   HANDLE *heaps )
{
    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;
        i++;
        LIST_FOR_EACH( ptr, &processHeap->entry )
        {
            if(i>=count)
            {
                break;
            }
            i++;
            *(heaps++) = LIST_ENTRY( ptr, HEAP, entry );

        }
    }
    RtlLeaveHeapLock( &processHeap->critSection );
    return i;
}


/*
 * @implemented
 */
BOOLEAN NTAPI
RtlValidateProcessHeaps(VOID)
{

#if 1
   BOOLEAN Result = TRUE;
   HEAP ** pptr;


   RtlEnterHeapLock( &processHeap->critSection );

   for (pptr = (HEAP**)&NtCurrentPeb()->ProcessHeaps; *pptr; pptr++)
   {
      if (!RtlValidateHeap(*pptr, 0, NULL))
      {
         Result = FALSE;
         break;
      }
   }


    RtlLeaveHeapLock( &processHeap->critSection );
   return Result;
#endif
}

is it correct?


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com


More information about the Ros-dev mailing list