Index: reactos/dll/ntdll/include/ntdllp.h =================================================================== --- reactos/dll/ntdll/include/ntdllp.h (revision 75201) +++ reactos/dll/ntdll/include/ntdllp.h (working copy) @@ -82,7 +82,8 @@ NTSTATUS NTAPI LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL, - IN PLDR_DATA_TABLE_ENTRY LdrEntry); + IN PLDR_DATA_TABLE_ENTRY LdrEntry, + IN BOOLEAN KnownDllsOnly); /* ldrutils.c */ @@ -138,7 +139,8 @@ IN PULONG DllCharacteristics, IN BOOLEAN Static, IN BOOLEAN Redirect, - OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry); + OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry, + IN BOOLEAN KnownDllsOnly); PVOID NTAPI LdrpFetchAddressOfEntryPoint(PVOID ImageBase); @@ -175,8 +177,9 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL, IN LPSTR ImportName, OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry, - OUT PBOOLEAN Existing); - + OUT PBOOLEAN Existing, + IN BOOLEAN KnownDllsOnly); + VOID NTAPI LdrpFinalizeAndDeallocateDataTableEntry(IN PLDR_DATA_TABLE_ENTRY Entry); Index: reactos/dll/ntdll/ldr/ldrinit.c =================================================================== --- reactos/dll/ntdll/ldr/ldrinit.c (revision 75201) +++ reactos/dll/ntdll/ldr/ldrinit.c (working copy) @@ -1979,7 +1979,7 @@ } /* Walk the IAT and load all the DLLs */ - ImportStatus = LdrpWalkImportDescriptor(LdrpDefaultPath.Buffer, LdrpImageEntry); + ImportStatus = LdrpWalkImportDescriptor(LdrpDefaultPath.Buffer, LdrpImageEntry, TRUE); /* Check if relocation is needed */ if (Peb->ImageBaseAddress != (PVOID)NtHeader->OptionalHeader.ImageBase) Index: reactos/dll/ntdll/ldr/ldrpe.c =================================================================== --- reactos/dll/ntdll/ldr/ldrpe.c (revision 75201) +++ reactos/dll/ntdll/ldr/ldrpe.c (working copy) @@ -270,7 +270,8 @@ LdrpHandleOneNewFormatImportDescriptor(IN LPWSTR DllPath OPTIONAL, IN PLDR_DATA_TABLE_ENTRY LdrEntry, IN PIMAGE_BOUND_IMPORT_DESCRIPTOR *BoundEntryPtr, - IN PIMAGE_BOUND_IMPORT_DESCRIPTOR FirstEntry) + IN PIMAGE_BOUND_IMPORT_DESCRIPTOR FirstEntry, + IN BOOLEAN KnownDllsOnly) { LPSTR ImportName = NULL, BoundImportName, ForwarderName; NTSTATUS Status; @@ -298,7 +299,8 @@ Status = LdrpLoadImportModule(DllPath, BoundImportName, &DllLdrEntry, - &AlreadyLoaded); + &AlreadyLoaded, + KnownDllsOnly); if (!NT_SUCCESS(Status)) { /* Show debug message */ @@ -311,6 +313,10 @@ } goto Quickie; } + else if (KnownDllsOnly && !DllLdrEntry) + { + goto Quickie; + } /* Check if it wasn't already loaded */ if (!AlreadyLoaded) @@ -371,7 +377,8 @@ Status = LdrpLoadImportModule(DllPath, ForwarderName, &ForwarderLdrEntry, - &AlreadyLoaded); + &AlreadyLoaded, + FALSE); if (NT_SUCCESS(Status)) { /* Loaded it, was it already loaded? */ @@ -502,7 +509,8 @@ NTAPI LdrpHandleNewFormatImportDescriptors(IN LPWSTR DllPath OPTIONAL, IN PLDR_DATA_TABLE_ENTRY LdrEntry, - IN PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundEntry) + IN PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundEntry, + IN BOOLEAN KnownDllsOnly) { PIMAGE_BOUND_IMPORT_DESCRIPTOR FirstEntry = BoundEntry; NTSTATUS Status; @@ -514,7 +522,8 @@ Status = LdrpHandleOneNewFormatImportDescriptor(DllPath, LdrEntry, &BoundEntry, - FirstEntry); + FirstEntry, + KnownDllsOnly); if (!NT_SUCCESS(Status)) return Status; } @@ -526,7 +535,8 @@ NTAPI LdrpHandleOneOldFormatImportDescriptor(IN LPWSTR DllPath OPTIONAL, IN PLDR_DATA_TABLE_ENTRY LdrEntry, - IN PIMAGE_IMPORT_DESCRIPTOR *ImportEntry) + IN PIMAGE_IMPORT_DESCRIPTOR *ImportEntry, + IN BOOLEAN KnownDllsOnly) { LPSTR ImportName; NTSTATUS Status; @@ -557,7 +567,8 @@ Status = LdrpLoadImportModule(DllPath, ImportName, &DllLdrEntry, - &AlreadyLoaded); + &AlreadyLoaded, + KnownDllsOnly); if (!NT_SUCCESS(Status)) { /* Fail */ @@ -572,6 +583,10 @@ /* Return */ return Status; } + else if (KnownDllsOnly && !DllLdrEntry) + { + goto SkipEntry; + } /* Show debug message */ if (ShowSnaps) @@ -616,7 +631,8 @@ NTAPI LdrpHandleOldFormatImportDescriptors(IN LPWSTR DllPath OPTIONAL, IN PLDR_DATA_TABLE_ENTRY LdrEntry, - IN PIMAGE_IMPORT_DESCRIPTOR ImportEntry) + IN PIMAGE_IMPORT_DESCRIPTOR ImportEntry, + IN BOOLEAN KnownDllsOnly) { NTSTATUS Status; @@ -626,7 +642,8 @@ /* Parse this descriptor */ Status = LdrpHandleOneOldFormatImportDescriptor(DllPath, LdrEntry, - &ImportEntry); + &ImportEntry, + KnownDllsOnly); if (!NT_SUCCESS(Status)) return Status; } @@ -679,7 +696,8 @@ NTSTATUS NTAPI LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL, - IN PLDR_DATA_TABLE_ENTRY LdrEntry) + IN PLDR_DATA_TABLE_ENTRY LdrEntry, + IN BOOLEAN KnownDllsOnly) { RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED ActCtx; PPEB Peb = NtCurrentPeb(); @@ -767,7 +785,15 @@ /* Handle the descriptor */ Status = LdrpHandleNewFormatImportDescriptors(DllPath, LdrEntry, - BoundEntry); + BoundEntry, + KnownDllsOnly); + if (NT_SUCCESS(Status) && KnownDllsOnly) + { + Status = LdrpHandleNewFormatImportDescriptors(DllPath, + LdrEntry, + BoundEntry, + FALSE); + } } else { @@ -774,7 +800,15 @@ /* Handle the descriptor */ Status = LdrpHandleOldFormatImportDescriptors(DllPath, LdrEntry, - ImportEntry); + ImportEntry, + KnownDllsOnly); + if (NT_SUCCESS(Status) && KnownDllsOnly) + { + Status = LdrpHandleOldFormatImportDescriptors(DllPath, + LdrEntry, + ImportEntry, + FALSE); + } } /* Check the status of the handlers */ @@ -821,7 +855,8 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL, IN LPSTR ImportName, OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry, - OUT PBOOLEAN Existing) + OUT PBOOLEAN Existing, + IN BOOLEAN KnownDllsOnly) { ANSI_STRING AnsiString; PUNICODE_STRING ImpDescName; @@ -833,6 +868,7 @@ PTEB Teb = NtCurrentTeb(); DPRINT("LdrpLoadImportModule('%S' '%s' %p %p)\n", DllPath, ImportName, DataTableEntry, Existing); + *DataTableEntry = NULL; /* Convert import descriptor name to unicode string */ ImpDescName = &Teb->StaticUnicodeString; @@ -950,13 +986,17 @@ NULL, TRUE, FALSE, - DataTableEntry); + DataTableEntry, + KnownDllsOnly); if (!NT_SUCCESS(Status)) return Status; + if (KnownDllsOnly && !*DataTableEntry) return Status; + /* Walk its import descriptor table */ Status = LdrpWalkImportDescriptor(DllPath, - *DataTableEntry); + *DataTableEntry, + FALSE); if (!NT_SUCCESS(Status)) { /* Add it to the in-init-order list in case of failure */ Index: reactos/dll/ntdll/ldr/ldrutils.c =================================================================== --- reactos/dll/ntdll/ldr/ldrutils.c (revision 75201) +++ reactos/dll/ntdll/ldr/ldrutils.c (working copy) @@ -999,7 +999,8 @@ IN PULONG DllCharacteristics, IN BOOLEAN Static, IN BOOLEAN Redirect, - OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry) + OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry, + IN BOOLEAN KnownDllsOnly) { PTEB Teb = NtCurrentTeb(); PPEB Peb = NtCurrentPeb(); @@ -1069,6 +1070,11 @@ return Status; } + if (NT_SUCCESS(Status) && KnownDllsOnly && !SectionHandle) + { + *DataTableEntry = NULL; + return Status; + } } SkipCheck: @@ -2488,7 +2494,8 @@ DllCharacteristics, FALSE, Redirected, - &LdrEntry); + &LdrEntry, + FALSE); if (!NT_SUCCESS(Status)) goto Quickie; /* FIXME: Need to mark the DLL range for the stack DB */ @@ -2510,7 +2517,7 @@ if (!(LdrEntry->Flags & LDRP_COR_IMAGE)) { /* Walk the Import Descriptor */ - Status = LdrpWalkImportDescriptor(DllPath, LdrEntry); + Status = LdrpWalkImportDescriptor(DllPath, LdrEntry, FALSE); } /* Update load count, unless it's locked */