mirror of
https://github.com/reactos/reactos.git
synced 2026-06-01 08:50:24 +08:00
[NTDLL] Unload DLLs on loader failure
This is crucial, because otherwise they linger in the loader, waiting to run their init routine, which can cause failures later.
This commit is contained in:
@@ -961,7 +961,7 @@ LdrpSnapThunk(IN PVOID ExportBase,
|
||||
UNICODE_STRING TempUString;
|
||||
ANSI_STRING ForwarderName;
|
||||
PANSI_STRING ForwardName;
|
||||
PVOID ForwarderHandle;
|
||||
PVOID ForwarderHandle = NULL;
|
||||
ULONG ForwardOrdinal;
|
||||
|
||||
/* Check if the snap is by ordinal */
|
||||
@@ -1012,6 +1012,13 @@ LdrpSnapThunk(IN PVOID ExportBase,
|
||||
if ((ULONG)Ordinal >= ExportDirectory->NumberOfFunctions)
|
||||
{
|
||||
FailurePath:
|
||||
/* Check if we loeaded a forwarder DLL */
|
||||
if (ForwarderHandle != NULL)
|
||||
{
|
||||
/* Unload the forwarder DLL */
|
||||
LdrUnloadDll(ForwarderHandle);
|
||||
}
|
||||
|
||||
/* Is this a static snap? */
|
||||
if (Static)
|
||||
{
|
||||
|
||||
@@ -2378,6 +2378,15 @@ LdrpGetProcedureAddress(
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
/* Check if it succeeded */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, unload the entry */
|
||||
DPRINT1("Initialization routine failed with 0x%08x\n", Status);
|
||||
LdrUnloadDll(LdrEntry->DllBase);
|
||||
LdrEntry = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user