mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 16:51:18 +00:00
[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. svn path=/trunk/; revision=49025
This commit is contained in:
parent
257ce7ee90
commit
3e76d8224e
3 changed files with 85 additions and 6 deletions
|
@ -74,6 +74,10 @@ LoadImageFileExecutionOptions(PPEB Peb)
|
|||
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 @@ LoadImageFileExecutionOptions(PPEB Peb)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,6 @@ RtlpSpecialHeapCreate(ULONG Flags,
|
|||
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 @@ RtlCreateHeap(ULONG Flags,
|
|||
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;
|
||||
|
|
|
@ -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 */
|
Loading…
Reference in a new issue