Alexandre Julliard : ntdll: Set the heap debug flags based on the GlobalFlag value.
Alexandre Julliard
julliard at winehq.org
Fri Jan 22 08:26:53 CST 2010
Module: wine
Branch: master
Commit: 9055e9e3dd41504431af5e6fcb6be49ef1a7cbc8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9055e9e3dd41504431af5e6fcb6be49ef1a7cbc8
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Jan 22 12:33:03 2010 +0100
ntdll: Set the heap debug flags based on the GlobalFlag value.
---
dlls/ntdll/heap.c | 33 +++++++++++++++++++++++++++++++++
dlls/ntdll/loader.c | 1 +
dlls/ntdll/ntdll_misc.h | 1 +
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index adaf693..a1fc764 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -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 );
@@ -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.@)
*
* Create a new Heap.
@@ -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;
}
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 1172a86..7bbcf95 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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;
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 586250d..c7b721a 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -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;
More information about the wine-cvs
mailing list