mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 08:30:21 +00:00
[dll/ntdll]
- LdrFixupImports: Unload modules import modules on LdrFixupImports failure to. -LdrpLoadModule: Free resources and memory on LdrFixupImports failure. Patch by Alexander Yastrebov. See #4954 svn path=/trunk/; revision=44453
This commit is contained in:
parent
2ddde07951
commit
e7ff40f1e3
1 changed files with 30 additions and 4 deletions
|
@ -61,6 +61,7 @@ static NTSTATUS LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
|||
OUT PVOID *BaseAddress OPTIONAL);
|
||||
static NTSTATUS LdrpAttachProcess(VOID);
|
||||
static VOID LdrpDetachProcess(BOOLEAN UnloadAll);
|
||||
static NTSTATUS LdrpUnloadModule(PLDR_DATA_TABLE_ENTRY Module, BOOLEAN Unload);
|
||||
|
||||
NTSTATUS find_actctx_dll( LPCWSTR libname, WCHAR *fulldosname );
|
||||
NTSTATUS create_module_activation_context( LDR_DATA_TABLE_ENTRY *module );
|
||||
|
@ -1836,7 +1837,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
|||
PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent;
|
||||
PIMAGE_TLS_DIRECTORY TlsDirectory;
|
||||
ULONG TlsSize = 0;
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PLDR_DATA_TABLE_ENTRY ImportedModule;
|
||||
PCHAR ImportedName;
|
||||
PWSTR ModulePath;
|
||||
|
@ -2043,7 +2044,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("failed to load %s\n", ImportedName);
|
||||
return Status;
|
||||
break;
|
||||
}
|
||||
Success:
|
||||
if (Module == ImportedModule)
|
||||
|
@ -2057,10 +2058,28 @@ Success:
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("failed to import %s\n", ImportedName);
|
||||
return Status;
|
||||
break;
|
||||
}
|
||||
ImportModuleDirectoryCurrent++;
|
||||
}
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
NTSTATUS errorStatus = Status;
|
||||
|
||||
while(ImportModuleDirectoryCurrent-- >= ImportModuleDirectory)
|
||||
{
|
||||
ImportedName = (PCHAR)Module->DllBase + ImportModuleDirectoryCurrent->Name;
|
||||
|
||||
Status = LdrpGetOrLoadModule(NULL, ImportedName, &ImportedModule, FALSE);
|
||||
if(NT_SUCCESS(Status) && Module != ImportedModule)
|
||||
{
|
||||
Status = LdrpUnloadModule(ImportedModule, FALSE);
|
||||
if (!NT_SUCCESS(Status)) DPRINT1("unable to unload %s\n", ImportedName);
|
||||
}
|
||||
}
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (TlsDirectory && TlsSize > 0)
|
||||
|
@ -2357,6 +2376,13 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("LdrFixupImports failed for %wZ, status=%x\n", &(*Module)->BaseDllName, Status);
|
||||
NtUnmapViewOfSection (NtCurrentProcess (), ImageBase);
|
||||
NtClose (SectionHandle);
|
||||
RtlFreeUnicodeString (&FullDosName);
|
||||
RtlFreeUnicodeString (&(*Module)->FullDllName);
|
||||
RtlFreeUnicodeString (&(*Module)->BaseDllName);
|
||||
RemoveEntryList (&(*Module)->InLoadOrderLinks);
|
||||
RtlFreeHeap (RtlGetProcessHeap (), 0, Module);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2377,7 +2403,7 @@ LdrpUnloadModule(PLDR_DATA_TABLE_ENTRY Module,
|
|||
PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundImportDescriptorCurrent;
|
||||
PCHAR ImportedName;
|
||||
PLDR_DATA_TABLE_ENTRY ImportedModule;
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = 0;
|
||||
LONG LoadCount;
|
||||
ULONG Size;
|
||||
|
||||
|
|
Loading…
Reference in a new issue