Author: dgorbachev
Date: Sun Dec 28 06:32:20 2008
New Revision: 38418
URL:
http://svn.reactos.org/svn/reactos?rev=38418&view=rev
Log:
Fix bug #3975.
Modified:
trunk/reactos/dll/ntdll/ldr/startup.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] Sun Dec 28 06:32:20 2008
@@ -27,6 +27,8 @@
static RTL_CRITICAL_SECTION LoaderLock;
static RTL_BITMAP TlsBitMap;
static RTL_BITMAP TlsExpansionBitMap;
+static volatile BOOLEAN LdrpInitialized = FALSE;
+static LONG LdrpInitLock = 0;
#define VALUE_BUFFER_SIZE 256
@@ -250,11 +252,11 @@
return FALSE;
}
+static
VOID
-NTAPI
-LdrpInit(PCONTEXT Context,
- PVOID SystemArgument1,
- PVOID SystemArgument2)
+LdrpInit2(PCONTEXT Context,
+ PVOID SystemArgument1,
+ PVOID SystemArgument2)
{
PIMAGE_NT_HEADERS NTHeaders;
PEPFUNC EntryPoint;
@@ -273,8 +275,6 @@
ImageBase = Peb->ImageBaseAddress;
DPRINT("ImageBase %p\n", ImageBase);
- if (NtCurrentPeb()->Ldr == NULL)
- {
if (ImageBase <= (PVOID) 0x1000)
{
DPRINT("ImageBase is null\n");
@@ -432,10 +432,7 @@
LdrpLoadUserModuleSymbols(NtModule);
#endif /* DBG || KDBG */
- }
-
- if (NtCurrentPeb()->Ldr->Initialized == FALSE)
- {
+
/* add entry for executable (becomes first list entry) */
ExeModule = (PLDR_DATA_TABLE_ENTRY)
RtlAllocateHeap(Peb->ProcessHeap,
@@ -500,7 +497,32 @@
/* Break into debugger */
if (Peb->BeingDebugged)
DbgBreakPoint();
- }
+}
+
+VOID
+NTAPI
+LdrpInit(PCONTEXT Context,
+ PVOID SystemArgument1,
+ PVOID SystemArgument2)
+{
+ if (!LdrpInitialized)
+ {
+ if (!_InterlockedExchange(&LdrpInitLock, 1))
+ {
+ LdrpInit2(Context, SystemArgument1, SystemArgument2);
+ LdrpInitialized = TRUE;
+ }
+ else
+ {
+ LARGE_INTEGER Interval = {{-200000, -1}};
+
+ do
+ {
+ NtDelayExecution(FALSE, &Interval);
+ }
+ while (!LdrpInitialized);
+ }
+ }
/* attach the thread */
RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);