Author: fireball
Date: Wed Oct 6 20:34:30 2010
New Revision: 49025
URL:
http://svn.reactos.org/svn/reactos?rev=49025&view=rev
Log:
[NTDLL]
- LoadImageFileExecutionOptions() improvements:
* Apply certain heap flags if the process is being debugged (only if NtGlobalFlags is not
overridden).
* Implement enabling page heap and reading image-specific configuration values.
- Add page heap configuration values to the Heap Manager.
Modified:
trunk/reactos/dll/ntdll/ldr/startup.c
trunk/reactos/lib/rtl/heap_rewrite.c
trunk/reactos/lib/rtl/heapdbg.c
Modified: trunk/reactos/dll/ntdll/ldr/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/startup.c?re…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/startup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/startup.c [iso-8859-1] Wed Oct 6 20:34:30 2010
@@ -74,6 +74,10 @@
UNICODE_STRING ImageName;
UNICODE_STRING ImagePathName;
ULONG ValueSize;
+ extern ULONG RtlpPageHeapGlobalFlags, RtlpPageHeapSizeRangeStart,
RtlpPageHeapSizeRangeEnd;
+ extern ULONG RtlpPageHeapDllRangeStart, RtlpPageHeapDllRangeEnd;
+ extern WCHAR RtlpPageHeapTargetDlls[512];
+ extern BOOLEAN RtlpPageHeapEnabled;
if (Peb->ProcessParameters &&
Peb->ProcessParameters->ImagePathName.Length > 0)
@@ -113,10 +117,75 @@
Peb->NtGlobalFlag = Value;
DPRINT("GlobalFlag: Value=0x%lx\n", Value);
}
- /*
- * FIXME:
- * read more options
- */
+ else
+ {
+ /* Add debugging flags if there is no GlobalFlags override */
+ if (Peb->BeingDebugged)
+ {
+ Peb->NtGlobalFlag |= FLG_HEAP_VALIDATE_PARAMETERS |
+ FLG_HEAP_ENABLE_FREE_CHECK |
+ FLG_HEAP_ENABLE_TAIL_CHECK;
+ }
+ }
+
+ /* Handle the case when page heap is enabled */
+ if (Peb->NtGlobalFlag & FLG_HEAP_PAGE_ALLOCS)
+ {
+ /* Disable all heap debugging flags so that no heap call goes via page heap
branch */
+ Peb->NtGlobalFlag &= ~(FLG_HEAP_VALIDATE_PARAMETERS |
+ FLG_HEAP_VALIDATE_ALL |
+ FLG_HEAP_ENABLE_FREE_CHECK |
+ FLG_HEAP_ENABLE_TAIL_CHECK |
+ FLG_USER_STACK_TRACE_DB |
+ FLG_HEAP_ENABLE_TAGGING |
+ FLG_HEAP_ENABLE_TAG_BY_DLL);
+ }
+
+ /* Get page heap flags without checking return value */
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapFlags",
+ REG_DWORD,
+ (PVOID)&RtlpPageHeapGlobalFlags,
+ sizeof(RtlpPageHeapGlobalFlags),
+ &ValueSize);
+
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapSizeRangeStart",
+ REG_DWORD,
+ (PVOID)&RtlpPageHeapSizeRangeStart,
+ sizeof(RtlpPageHeapSizeRangeStart),
+ &ValueSize);
+
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapSizeRangeEnd",
+ REG_DWORD,
+ (PVOID)&RtlpPageHeapSizeRangeEnd,
+ sizeof(RtlpPageHeapSizeRangeEnd),
+ &ValueSize);
+
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapDllRangeStart",
+ REG_DWORD,
+ (PVOID)&RtlpPageHeapDllRangeStart,
+ sizeof(RtlpPageHeapDllRangeStart),
+ &ValueSize);
+
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapDllRangeEnd",
+ REG_DWORD,
+ (PVOID)&RtlpPageHeapDllRangeEnd,
+ sizeof(RtlpPageHeapDllRangeEnd),
+ &ValueSize);
+
+ LdrQueryImageFileExecutionOptions(&ImageName,
+ L"PageHeapTargetDlls",
+ REG_SZ,
+ (PVOID)RtlpPageHeapTargetDlls,
+ sizeof(RtlpPageHeapTargetDlls),
+ &ValueSize);
+
+ /* Now when all parameters are read, enable page heap */
+ RtlpPageHeapEnabled = TRUE;
}
}
Modified: trunk/reactos/lib/rtl/heap_rewrite.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap_rewrite.c?rev…
==============================================================================
--- trunk/reactos/lib/rtl/heap_rewrite.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap_rewrite.c [iso-8859-1] Wed Oct 6 20:34:30 2010
@@ -269,7 +269,6 @@
PVOID Lock,
PRTL_HEAP_PARAMETERS Parameters) { return NULL; };
-BOOLEAN RtlpSpecialHeapEnabled = FALSE;
HEAP_LOCK RtlpProcessHeapsListLock;
PHEAP RtlpProcessHeaps[HEAP_MAX_PROCESS_HEAPS]; /* Usermode only */
@@ -1542,7 +1541,7 @@
BOOLEAN AllocateLock = FALSE;
/* Check for a special heap */
- if (RtlpSpecialHeapEnabled && !Addr && !Lock)
+ if (RtlpPageHeapEnabled && !Addr && !Lock)
{
Heap = RtlpSpecialHeapCreate(Flags, Addr, TotalSize, CommitSize, Lock,
Parameters);
if (Heap) return Heap;
Modified: trunk/reactos/lib/rtl/heapdbg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heapdbg.c?rev=4902…
==============================================================================
--- trunk/reactos/lib/rtl/heapdbg.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heapdbg.c [iso-8859-1] Wed Oct 6 20:34:30 2010
@@ -8,6 +8,17 @@
/* INCLUDES ******************************************************************/
+#include <rtl.h>
+
+#define NDEBUG
+#include <debug.h>
+
+BOOLEAN RtlpPageHeapEnabled = FALSE;
+ULONG RtlpPageHeapGlobalFlags;
+ULONG RtlpPageHeapSizeRangeStart, RtlpPageHeapSizeRangeEnd;
+ULONG RtlpPageHeapDllRangeStart, RtlpPageHeapDllRangeEnd;
+WCHAR RtlpPageHeapTargetDlls[512];
+
/* FUNCTIONS ******************************************************************/
/* EOF */