ntdll: Set the heap debug flags based on the GlobalFlag value.

This commit is contained in:
Alexandre Julliard 2010-01-22 12:33:03 +01:00
parent e7810c8bc6
commit 9055e9e3dd
3 changed files with 35 additions and 0 deletions

View File

@ -155,6 +155,12 @@ typedef struct tagHEAP
#define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */
#define COMMIT_MASK 0xffff /* bitmask for commit/decommit granularity */
/* some undocumented flags (names are made up) */
#define HEAP_PAGE_ALLOCS 0x01000000
#define HEAP_VALIDATE 0x10000000
#define HEAP_VALIDATE_ALL 0x20000000
#define HEAP_VALIDATE_PARAMS 0x40000000
static HEAP *processHeap; /* main process heap */
static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL quiet );
@ -1232,6 +1238,32 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */
}
/***********************************************************************
* heap_set_debug_flags
*/
void heap_set_debug_flags( HANDLE handle )
{
HEAP *heap = HEAP_GetPtr( handle );
ULONG global_flags = RtlGetNtGlobalFlags();
ULONG flags = 0;
if (global_flags & FLG_HEAP_ENABLE_TAIL_CHECK) flags |= HEAP_TAIL_CHECKING_ENABLED;
if (global_flags & FLG_HEAP_ENABLE_FREE_CHECK) flags |= HEAP_FREE_CHECKING_ENABLED;
if (global_flags & FLG_HEAP_DISABLE_COALESCING) flags |= HEAP_DISABLE_COALESCE_ON_FREE;
if (global_flags & FLG_HEAP_PAGE_ALLOCS) flags |= HEAP_PAGE_ALLOCS | HEAP_GROWABLE;
if (global_flags & FLG_HEAP_VALIDATE_PARAMETERS)
flags |= HEAP_VALIDATE | HEAP_VALIDATE_PARAMS |
HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED;
if (global_flags & FLG_HEAP_VALIDATE_ALL)
flags |= HEAP_VALIDATE | HEAP_VALIDATE_ALL |
HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED;
heap->flags |= flags;
heap->force_flags |= flags & ~(HEAP_VALIDATE | HEAP_DISABLE_COALESCE_ON_FREE);
}
/***********************************************************************
* RtlCreateHeap (NTDLL.@)
*
@ -1278,6 +1310,7 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
list_init( &processHeap->entry );
}
heap_set_debug_flags( subheap->heap );
return subheap->heap;
}

View File

@ -2656,6 +2656,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
if ((status = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error;
if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto error;
if ((status = alloc_thread_tls()) != STATUS_SUCCESS) goto error;
heap_set_debug_flags( GetProcessHeap() );
status = wine_call_on_stack( attach_process_dlls, wm, NtCurrentTeb()->Tib.StackBase );
if (status != STATUS_SUCCESS) goto error;

View File

@ -70,6 +70,7 @@ extern void actctx_init(void);
extern void virtual_init(void);
extern void virtual_init_threading(void);
extern void fill_cpu_info(void);
extern void heap_set_debug_flags( HANDLE handle );
/* server support */
extern timeout_t server_start_time;