Commit 9055e9e3 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent e7810c8b
...@@ -155,6 +155,12 @@ typedef struct tagHEAP ...@@ -155,6 +155,12 @@ typedef struct tagHEAP
#define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */ #define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */
#define COMMIT_MASK 0xffff /* bitmask for commit/decommit granularity */ #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 HEAP *processHeap; /* main process heap */
static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL quiet ); static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL quiet );
...@@ -1233,6 +1239,32 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */ ...@@ -1233,6 +1239,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.@) * RtlCreateHeap (NTDLL.@)
* *
* Create a new Heap. * Create a new Heap.
...@@ -1278,6 +1310,7 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c ...@@ -1278,6 +1310,7 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
list_init( &processHeap->entry ); list_init( &processHeap->entry );
} }
heap_set_debug_flags( subheap->heap );
return subheap->heap; return subheap->heap;
} }
......
...@@ -2656,6 +2656,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2, ...@@ -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 = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error;
if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto error; if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto error;
if ((status = alloc_thread_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 ); status = wine_call_on_stack( attach_process_dlls, wm, NtCurrentTeb()->Tib.StackBase );
if (status != STATUS_SUCCESS) goto error; if (status != STATUS_SUCCESS) goto error;
......
...@@ -70,6 +70,7 @@ extern void actctx_init(void); ...@@ -70,6 +70,7 @@ extern void actctx_init(void);
extern void virtual_init(void); extern void virtual_init(void);
extern void virtual_init_threading(void); extern void virtual_init_threading(void);
extern void fill_cpu_info(void); extern void fill_cpu_info(void);
extern void heap_set_debug_flags( HANDLE handle );
/* server support */ /* server support */
extern timeout_t server_start_time; extern timeout_t server_start_time;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment