mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
parent
97d06533f8
commit
5ee921c371
|
@ -27,6 +27,8 @@ static RTL_CRITICAL_SECTION PebLock;
|
||||||
static RTL_CRITICAL_SECTION LoaderLock;
|
static RTL_CRITICAL_SECTION LoaderLock;
|
||||||
static RTL_BITMAP TlsBitMap;
|
static RTL_BITMAP TlsBitMap;
|
||||||
static RTL_BITMAP TlsExpansionBitMap;
|
static RTL_BITMAP TlsExpansionBitMap;
|
||||||
|
static volatile BOOLEAN LdrpInitialized = FALSE;
|
||||||
|
static LONG LdrpInitLock = 0;
|
||||||
|
|
||||||
#define VALUE_BUFFER_SIZE 256
|
#define VALUE_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
@ -250,11 +252,11 @@ finish:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
LdrpInit2(PCONTEXT Context,
|
||||||
LdrpInit(PCONTEXT Context,
|
PVOID SystemArgument1,
|
||||||
PVOID SystemArgument1,
|
PVOID SystemArgument2)
|
||||||
PVOID SystemArgument2)
|
|
||||||
{
|
{
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
PEPFUNC EntryPoint;
|
PEPFUNC EntryPoint;
|
||||||
|
@ -273,8 +275,6 @@ LdrpInit(PCONTEXT Context,
|
||||||
ImageBase = Peb->ImageBaseAddress;
|
ImageBase = Peb->ImageBaseAddress;
|
||||||
DPRINT("ImageBase %p\n", ImageBase);
|
DPRINT("ImageBase %p\n", ImageBase);
|
||||||
|
|
||||||
if (NtCurrentPeb()->Ldr == NULL)
|
|
||||||
{
|
|
||||||
if (ImageBase <= (PVOID) 0x1000)
|
if (ImageBase <= (PVOID) 0x1000)
|
||||||
{
|
{
|
||||||
DPRINT("ImageBase is null\n");
|
DPRINT("ImageBase is null\n");
|
||||||
|
@ -432,10 +432,7 @@ LdrpInit(PCONTEXT Context,
|
||||||
LdrpLoadUserModuleSymbols(NtModule);
|
LdrpLoadUserModuleSymbols(NtModule);
|
||||||
|
|
||||||
#endif /* DBG || KDBG */
|
#endif /* DBG || KDBG */
|
||||||
}
|
|
||||||
|
|
||||||
if (NtCurrentPeb()->Ldr->Initialized == FALSE)
|
|
||||||
{
|
|
||||||
/* add entry for executable (becomes first list entry) */
|
/* add entry for executable (becomes first list entry) */
|
||||||
ExeModule = (PLDR_DATA_TABLE_ENTRY)
|
ExeModule = (PLDR_DATA_TABLE_ENTRY)
|
||||||
RtlAllocateHeap(Peb->ProcessHeap,
|
RtlAllocateHeap(Peb->ProcessHeap,
|
||||||
|
@ -500,7 +497,32 @@ LdrpInit(PCONTEXT Context,
|
||||||
/* Break into debugger */
|
/* Break into debugger */
|
||||||
if (Peb->BeingDebugged)
|
if (Peb->BeingDebugged)
|
||||||
DbgBreakPoint();
|
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 */
|
/* attach the thread */
|
||||||
RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);
|
RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);
|
||||||
|
|
Loading…
Reference in a new issue