ULONG Count, ProtectSize, OldProtect, OldProtect2;
PVOID Page, ProtectPage, ProtectPage2;
PUSHORT TypeOffset;
- ULONG_PTR Delta;
+ LONG_PTR Delta;
NTSTATUS Status;
if (NTHeaders->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED)
if (!NT_SUCCESS(Status))
{
ULONG ErrorResponse;
- ULONG_PTR ErrorParameter = (ULONG_PTR)&DllName;
+ ULONG_PTR ErrorParameter = (ULONG_PTR)&AnsiDllName;
DPRINT1("failed to load %wZ\n", &DllName);
IATSize++;
}
+ /* No need to fixup anything if IAT is empty */
+ if (IATSize == 0) return STATUS_SUCCESS;
+
/* Unprotect the region we are about to write into. */
IATBase = (PVOID)ImportAddressList;
IATSize *= sizeof(PVOID*);
}
ImportModuleDirectoryCurrent++;
}
- if(!NT_SUCCESS(Status))
+
+ if (!NT_SUCCESS(Status))
{
NTSTATUS errorStatus = Status;
- while(ImportModuleDirectoryCurrent-- >= ImportModuleDirectory)
+ while (ImportModuleDirectoryCurrent >= ImportModuleDirectory)
{
ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectoryCurrent->Name;
Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE);
- if(NT_SUCCESS(Status) && Module != ImportedModule)
+ if (NT_SUCCESS(Status) && Module != ImportedModule)
{
Status = LdrpUnloadModule(ImportedModule, FALSE);
if (!NT_SUCCESS(Status)) DPRINT1("unable to unload %s\n", ImportedName);
}
+ ImportModuleDirectoryCurrent--;
}
return errorStatus;
}
-
}
if (TlsDirectory && TlsSize > 0)
/* Map the dll into the process */
ViewSize = 0;
ImageBase = 0;
- ArbitraryUserPointer = NtCurrentTeb()->Tib.ArbitraryUserPointer;
- NtCurrentTeb()->Tib.ArbitraryUserPointer = FullDosName.Buffer;
+ ArbitraryUserPointer = NtCurrentTeb()->NtTib.ArbitraryUserPointer;
+ NtCurrentTeb()->NtTib.ArbitraryUserPointer = FullDosName.Buffer;
Status = NtMapViewOfSection(SectionHandle,
NtCurrentProcess(),
&ImageBase,
ViewShare,
0,
PAGE_READONLY);
- NtCurrentTeb()->Tib.ArbitraryUserPointer = ArbitraryUserPointer;
+ NtCurrentTeb()->NtTib.ArbitraryUserPointer = ArbitraryUserPointer;
if (!NT_SUCCESS(Status))
{
DPRINT1("map view of section failed (Status 0x%08lx)\n", Status);