https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6f89a48349c0b16ce5937…
commit 6f89a48349c0b16ce59378cbfa842823f38bbadf
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Nov 6 18:43:35 2021 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Sep 21 13:33:26 2023 +0200
[NTDLL:LDR] Fix process LoadConfig CS timeout conversion from ms to 100ns units
(#4089)
For more details, see
https://forums.codeguru.com/showthread.php?370731-EnterCriticalSection-lock…
---
dll/ntdll/ldr/ldrinit.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c
index ed9774fc0c2..d5a6b37d923 100644
--- a/dll/ntdll/ldr/ldrinit.c
+++ b/dll/ntdll/ldr/ldrinit.c
@@ -1839,7 +1839,7 @@ LdrpInitializeProcess(IN PCONTEXT Context,
/* ReactOS specific: do not clear it. (Windows starts doing the same in later
versions) */
//Peb->pShimData = NULL;
- /* Save the number of processors and CS Timeout */
+ /* Save the number of processors and CS timeout */
LdrpNumberOfProcessors = Peb->NumberOfProcessors;
RtlpTimeout = Peb->CriticalSectionTimeout;
@@ -1894,8 +1894,9 @@ LdrpInitializeProcess(IN PCONTEXT Context,
if (VALID_CONFIG_FIELD(GlobalFlagsClear) &&
LoadConfig->GlobalFlagsClear)
Peb->NtGlobalFlag &= ~LoadConfig->GlobalFlagsClear;
+ /* Convert the default CS timeout from milliseconds to 100ns units */
if (VALID_CONFIG_FIELD(CriticalSectionDefaultTimeout) &&
LoadConfig->CriticalSectionDefaultTimeout)
- RtlpTimeout.QuadPart =
Int32x32To64(LoadConfig->CriticalSectionDefaultTimeout, -10000000);
+ RtlpTimeout.QuadPart =
Int32x32To64(LoadConfig->CriticalSectionDefaultTimeout, -10000);
if (VALID_CONFIG_FIELD(DeCommitFreeBlockThreshold) &&
LoadConfig->DeCommitFreeBlockThreshold)
HeapParameters.DeCommitFreeBlockThreshold =
LoadConfig->DeCommitFreeBlockThreshold;
@@ -1935,12 +1936,9 @@ LdrpInitializeProcess(IN PCONTEXT Context,
&CommandLine);
}
- /* If the timeout is too long */
+ /* If the CS timeout is longer than 1 hour, disable it */
if (RtlpTimeout.QuadPart < Int32x32To64(3600, -10000000))
- {
- /* Then disable CS Timeout */
RtlpTimeoutDisable = TRUE;
- }
/* Initialize Critical Section Data */
RtlpInitDeferredCriticalSection();