svn path=/trunk/; revision=38418
This commit is contained in:
Dmitry Gorbachev 2008-12-28 12:32:20 +00:00
parent 97d06533f8
commit 5ee921c371

View file

@ -27,6 +27,8 @@ static RTL_CRITICAL_SECTION PebLock;
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 @@ finish:
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 @@ LdrpInit(PCONTEXT Context,
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 @@ LdrpInit(PCONTEXT Context,
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 @@ LdrpInit(PCONTEXT Context,
/* 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);