ntdll: Make the heap structure more compatible with the NT layout.

This commit is contained in:
Alexandre Julliard 2007-10-01 15:32:14 +02:00
parent 80a6bb1d8b
commit e599584a68
1 changed files with 10 additions and 7 deletions

View File

@ -44,10 +44,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(heap); WINE_DEFAULT_DEBUG_CHANNEL(heap);
/* Note: the heap data structures are based on what Pietrek describes in his /* Note: the heap data structures are losely based on what Pietrek describes in his
* book 'Windows 95 System Programming Secrets'. The layout is not exactly * book 'Windows 95 System Programming Secrets', with some adaptations for
* the same, but could be easily adapted if it turns out some programs * better compatibility with NT.
* require it.
*/ */
/* FIXME: use SIZE_T for 'size' structure members, but we need to make sure /* FIXME: use SIZE_T for 'size' structure members, but we need to make sure
@ -108,9 +107,9 @@ typedef struct tagSUBHEAP
void *base; /* Base address of the sub-heap memory block */ void *base; /* Base address of the sub-heap memory block */
SIZE_T size; /* Size of the whole sub-heap */ SIZE_T size; /* Size of the whole sub-heap */
SIZE_T commitSize; /* Committed size of the sub-heap */ SIZE_T commitSize; /* Committed size of the sub-heap */
DWORD headerSize; /* Size of the heap header */
struct list entry; /* Entry in sub-heap list */ struct list entry; /* Entry in sub-heap list */
struct tagHEAP *heap; /* Main heap structure */ struct tagHEAP *heap; /* Main heap structure */
DWORD headerSize; /* Size of the heap header */
DWORD magic; /* Magic number */ DWORD magic; /* Magic number */
} SUBHEAP; } SUBHEAP;
@ -118,13 +117,15 @@ typedef struct tagSUBHEAP
typedef struct tagHEAP typedef struct tagHEAP
{ {
DWORD unknown[3];
DWORD flags; /* Heap flags */
DWORD force_flags; /* Forced heap flags for debugging */
SUBHEAP subheap; /* First sub-heap */ SUBHEAP subheap; /* First sub-heap */
struct list entry; /* Entry in process heap list */ struct list entry; /* Entry in process heap list */
struct list subheap_list; /* Sub-heap list */ struct list subheap_list; /* Sub-heap list */
DWORD magic; /* Magic number */
RTL_CRITICAL_SECTION critSection; /* Critical section for serialization */ RTL_CRITICAL_SECTION critSection; /* Critical section for serialization */
FREE_LIST_ENTRY freeList[HEAP_NB_FREE_LISTS]; /* Free lists */ FREE_LIST_ENTRY freeList[HEAP_NB_FREE_LISTS]; /* Free lists */
DWORD flags; /* Heap flags */
DWORD magic; /* Magic number */
} HEAP; } HEAP;
#define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24))) #define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24)))
@ -1097,6 +1098,8 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
{ {
processHeap = subheap->heap; /* assume the first heap we create is the process main heap */ processHeap = subheap->heap; /* assume the first heap we create is the process main heap */
list_init( &processHeap->entry ); list_init( &processHeap->entry );
/* make sure structure alignment is correct */
assert( (ULONG_PTR)&processHeap->freeList % ALIGNMENT == 0 );
} }
return (HANDLE)subheap->heap; return (HANDLE)subheap->heap;