https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1e0f359fa7b5ff8cc535b…
commit 1e0f359fa7b5ff8cc535b6c0b5b75fa6bdb7c76d
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Apr 12 16:24:28 2020 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Fri Apr 17 17:47:24 2020 +0200
[LDR] Add initial LOAD_CONFIG support
---
dll/ntdll/ldr/ldrinit.c | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c
index 955c9a23b8c..cdf51c64b38 100644
--- a/dll/ntdll/ldr/ldrinit.c
+++ b/dll/ntdll/ldr/ldrinit.c
@@ -1872,11 +1872,40 @@ LdrpInitializeProcess(IN PCONTEXT Context,
HeapParameters.Length = sizeof(HeapParameters);
/* Check if we have Configuration Data */
- if ((LoadConfig) && (ConfigSize == sizeof(IMAGE_LOAD_CONFIG_DIRECTORY)))
+#define VALID_CONFIG_FIELD(Name) (ConfigSize >=
(FIELD_OFFSET(IMAGE_LOAD_CONFIG_DIRECTORY, Name) + sizeof(LoadConfig->Name)))
+ /* The 'original' load config ends after SecurityCookie */
+ if ((LoadConfig) && ConfigSize && (VALID_CONFIG_FIELD(SecurityCookie)
|| ConfigSize == LoadConfig->Size))
{
- /* FIXME: Custom heap settings and misc. */
- DPRINT1("We don't support LOAD_CONFIG data yet\n");
+ if (ConfigSize != sizeof(IMAGE_LOAD_CONFIG_DIRECTORY))
+ DPRINT1("WARN: Accepting different LOAD_CONFIG size!\n");
+ else
+ DPRINT1("Applying LOAD_CONFIG\n");
+
+ if (VALID_CONFIG_FIELD(GlobalFlagsSet) && LoadConfig->GlobalFlagsSet)
+ Peb->NtGlobalFlag |= LoadConfig->GlobalFlagsSet;
+
+ if (VALID_CONFIG_FIELD(GlobalFlagsClear) &&
LoadConfig->GlobalFlagsClear)
+ Peb->NtGlobalFlag &= ~LoadConfig->GlobalFlagsClear;
+
+ if (VALID_CONFIG_FIELD(CriticalSectionDefaultTimeout) &&
LoadConfig->CriticalSectionDefaultTimeout)
+ RtlpTimeout.QuadPart =
Int32x32To64(LoadConfig->CriticalSectionDefaultTimeout, -10000000);
+
+ if (VALID_CONFIG_FIELD(DeCommitFreeBlockThreshold) &&
LoadConfig->DeCommitFreeBlockThreshold)
+ HeapParameters.DeCommitFreeBlockThreshold =
LoadConfig->DeCommitFreeBlockThreshold;
+
+ if (VALID_CONFIG_FIELD(DeCommitTotalFreeThreshold) &&
LoadConfig->DeCommitTotalFreeThreshold)
+ HeapParameters.DeCommitTotalFreeThreshold =
LoadConfig->DeCommitTotalFreeThreshold;
+
+ if (VALID_CONFIG_FIELD(MaximumAllocationSize) &&
LoadConfig->MaximumAllocationSize)
+ HeapParameters.MaximumAllocationSize = LoadConfig->MaximumAllocationSize;
+
+ if (VALID_CONFIG_FIELD(VirtualMemoryThreshold) &&
LoadConfig->VirtualMemoryThreshold)
+ HeapParameters.VirtualMemoryThreshold =
LoadConfig->VirtualMemoryThreshold;
+
+ if (VALID_CONFIG_FIELD(ProcessHeapFlags) &&
LoadConfig->ProcessHeapFlags)
+ HeapFlags = LoadConfig->ProcessHeapFlags;
}
+#undef VALID_CONFIG_FIELD
/* Check for custom affinity mask */
if (Peb->ImageProcessAffinityMask)