Author: tfaber
Date: Mon Feb 23 19:03:08 2015
New Revision: 66433
URL:
http://svn.reactos.org/svn/reactos?rev=66433&view=rev
Log:
[NTDLL:LDR]
- Apply OffsetModuleName to the first import entry, not the current one in
LdrpUpdateLoadCount3. Fixes missing reference updates on dependency-loaded DLLs.
CORE-5125 CORE-7127 #resolve
Modified:
trunk/reactos/dll/ntdll/ldr/ldrutils.c
Modified: trunk/reactos/dll/ntdll/ldr/ldrutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrutils.c?r…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] Mon Feb 23 19:03:08 2015
@@ -223,6 +223,7 @@
OUT PUNICODE_STRING UpdateString)
{
PIMAGE_BOUND_FORWARDER_REF NewImportForwarder;
+ PIMAGE_BOUND_IMPORT_DESCRIPTOR FirstEntry;
PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundEntry;
PIMAGE_IMPORT_DESCRIPTOR ImportEntry;
PIMAGE_THUNK_DATA FirstThunk;
@@ -256,12 +257,12 @@
ImportNameUnic = &NtCurrentTeb()->StaticUnicodeString;
/* Try to get the new import entry */
- BoundEntry =
(PIMAGE_BOUND_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(LdrEntry->DllBase,
- TRUE,
-
IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT,
-
&ImportSize);
-
- if (BoundEntry)
+ FirstEntry = RtlImageDirectoryEntryToData(LdrEntry->DllBase,
+ TRUE,
+ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT,
+ &ImportSize);
+
+ if (FirstEntry)
{
/* Set entry flags if refing/derefing */
if (Flags == LDRP_UPDATE_REFCOUNT)
@@ -269,10 +270,11 @@
else if (Flags == LDRP_UPDATE_DEREFCOUNT)
LdrEntry->Flags |= LDRP_UNLOAD_IN_PROGRESS;
+ BoundEntry = FirstEntry;
while (BoundEntry->OffsetModuleName)
{
/* Get pointer to the current import name */
- ImportName = (PCHAR)BoundEntry + BoundEntry->OffsetModuleName;
+ ImportName = (LPSTR)FirstEntry + BoundEntry->OffsetModuleName;
RtlInitAnsiString(&ImportNameAnsi, ImportName);
Status = RtlAnsiStringToUnicodeString(ImportNameUnic, &ImportNameAnsi,
FALSE);
@@ -315,9 +317,9 @@
/* Go through forwarders */
NewImportForwarder = (PIMAGE_BOUND_FORWARDER_REF)(BoundEntry + 1);
- for (i=0; i<BoundEntry->NumberOfModuleForwarderRefs; i++)
- {
- ImportName = (PCHAR)BoundEntry +
NewImportForwarder->OffsetModuleName;
+ for (i = 0; i < BoundEntry->NumberOfModuleForwarderRefs; i++)
+ {
+ ImportName = (LPSTR)FirstEntry +
NewImportForwarder->OffsetModuleName;
RtlInitAnsiString(&ImportNameAnsi, ImportName);
Status = RtlAnsiStringToUnicodeString(ImportNameUnic,
&ImportNameAnsi, FALSE);