[NTDLL/LDR]

LdrpInitializeProcess:
Don't use NtLdrEntry to initialize LdrpImageEntry.
It is overwritten afterwards to initialize the real NtLdrEntry.


svn path=/trunk/; revision=66505
This commit is contained in:
Sylvain Petreolle 2015-02-28 21:23:07 +00:00
parent b3777ffecc
commit 1d174e03c2

View file

@ -1846,24 +1846,24 @@ LdrpInitializeProcess(IN PCONTEXT Context,
PebLdr.Initialized = TRUE; PebLdr.Initialized = TRUE;
/* Allocate a data entry for the Image */ /* Allocate a data entry for the Image */
LdrpImageEntry = NtLdrEntry = LdrpAllocateDataTableEntry(Peb->ImageBaseAddress); LdrpImageEntry = LdrpAllocateDataTableEntry(Peb->ImageBaseAddress);
/* Set it up */ /* Set it up */
NtLdrEntry->EntryPoint = LdrpFetchAddressOfEntryPoint(NtLdrEntry->DllBase); LdrpImageEntry->EntryPoint = LdrpFetchAddressOfEntryPoint(LdrpImageEntry->DllBase);
NtLdrEntry->LoadCount = -1; LdrpImageEntry->LoadCount = -1;
NtLdrEntry->EntryPointActivationContext = 0; LdrpImageEntry->EntryPointActivationContext = 0;
NtLdrEntry->FullDllName = ImageFileName; LdrpImageEntry->FullDllName = ImageFileName;
if (IsDotNetImage) if (IsDotNetImage)
NtLdrEntry->Flags = LDRP_COR_IMAGE; LdrpImageEntry->Flags = LDRP_COR_IMAGE;
else else
NtLdrEntry->Flags = 0; LdrpImageEntry->Flags = 0;
/* Check if the name is empty */ /* Check if the name is empty */
if (!ImageFileName.Buffer[0]) if (!ImageFileName.Buffer[0])
{ {
/* Use the same Base name */ /* Use the same Base name */
NtLdrEntry->BaseDllName = NtLdrEntry->FullDllName; LdrpImageEntry->BaseDllName = LdrpImageEntry->FullDllName;
} }
else else
{ {
@ -1882,21 +1882,21 @@ LdrpInitializeProcess(IN PCONTEXT Context,
if (!NtDllName) if (!NtDllName)
{ {
/* Use the same Base name */ /* Use the same Base name */
NtLdrEntry->BaseDllName = NtLdrEntry->FullDllName; LdrpImageEntry->BaseDllName = LdrpImageEntry->FullDllName;
} }
else else
{ {
/* Setup the name */ /* Setup the name */
NtLdrEntry->BaseDllName.Length = (USHORT)((ULONG_PTR)ImageFileName.Buffer + ImageFileName.Length - (ULONG_PTR)NtDllName); LdrpImageEntry->BaseDllName.Length = (USHORT)((ULONG_PTR)ImageFileName.Buffer + ImageFileName.Length - (ULONG_PTR)NtDllName);
NtLdrEntry->BaseDllName.MaximumLength = NtLdrEntry->BaseDllName.Length + sizeof(WCHAR); LdrpImageEntry->BaseDllName.MaximumLength = LdrpImageEntry->BaseDllName.Length + sizeof(WCHAR);
NtLdrEntry->BaseDllName.Buffer = (PWSTR)((ULONG_PTR)ImageFileName.Buffer + LdrpImageEntry->BaseDllName.Buffer = (PWSTR)((ULONG_PTR)ImageFileName.Buffer +
(ImageFileName.Length - NtLdrEntry->BaseDllName.Length)); (ImageFileName.Length - LdrpImageEntry->BaseDllName.Length));
} }
} }
/* Processing done, insert it */ /* Processing done, insert it */
LdrpInsertMemoryTableEntry(NtLdrEntry); LdrpInsertMemoryTableEntry(LdrpImageEntry);
NtLdrEntry->Flags |= LDRP_ENTRY_PROCESSED; LdrpImageEntry->Flags |= LDRP_ENTRY_PROCESSED;
/* Now add an entry for NTDLL */ /* Now add an entry for NTDLL */
NtLdrEntry = LdrpAllocateDataTableEntry(SystemArgument1); NtLdrEntry = LdrpAllocateDataTableEntry(SystemArgument1);