mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 22:01:43 +00:00
[NTDLL:LDR]
- Code cleanup in LdrpLoadDll svn path=/trunk/; revision=57093
This commit is contained in:
parent
e812fee585
commit
8b45c713bf
1 changed files with 26 additions and 46 deletions
|
@ -1985,7 +1985,7 @@ LdrpCheckForLoadedDll(IN PWSTR DllPath,
|
|||
|
||||
/* FIXME: Warning, "Flag" is used as magic instead of "Static" */
|
||||
/* FIXME: Warning, code does not support redirection at all */
|
||||
|
||||
|
||||
/* Look in the hash table if flag was set */
|
||||
lookinhash:
|
||||
if (Flag)
|
||||
|
@ -2077,7 +2077,7 @@ lookinhash:
|
|||
Flag = TRUE;
|
||||
goto lookinhash;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: Warning, activation context missing */
|
||||
/* NOTE: From here on down, everything looks good */
|
||||
|
||||
|
@ -2192,7 +2192,7 @@ lookinhash:
|
|||
|
||||
/* Check if it's in the process of being unloaded */
|
||||
if (!CurEntry->InMemoryOrderModuleList.Flink) continue;
|
||||
|
||||
|
||||
/* The header is untrusted, use SEH */
|
||||
_SEH2_TRY
|
||||
{
|
||||
|
@ -2415,28 +2415,28 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
{
|
||||
PPEB Peb = NtCurrentPeb();
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PWCHAR p1, p2, p1min;
|
||||
const WCHAR *p;
|
||||
BOOLEAN GotExtension;
|
||||
WCHAR c;
|
||||
WCHAR NameBuffer[MAX_PATH+6];
|
||||
LPWSTR RawDllName;
|
||||
UNICODE_STRING RawDllNameString;
|
||||
WCHAR NameBuffer[MAX_PATH + 6];
|
||||
UNICODE_STRING RawDllName;
|
||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||
BOOLEAN InInit = LdrpInLdrInit;
|
||||
|
||||
/* Save the Raw DLL Name */
|
||||
RawDllName = NameBuffer;
|
||||
if (DllName->Length >= sizeof(NameBuffer)) return STATUS_NAME_TOO_LONG;
|
||||
RtlMoveMemory(RawDllName, DllName->Buffer, DllName->Length);
|
||||
RtlInitEmptyUnicodeString(&RawDllName, NameBuffer, sizeof(NameBuffer));
|
||||
RtlCopyUnicodeString(&RawDllName, DllName);
|
||||
|
||||
/* Find the name without the extension */
|
||||
p1 = DllName->Buffer + DllName->Length / sizeof(WCHAR) - 1;
|
||||
p2 = NULL;
|
||||
for (p1min = DllName->Buffer; p1 >= p1min; p1--)
|
||||
/* Find the extension, if present */
|
||||
p = DllName->Buffer + DllName->Length / sizeof(WCHAR) - 1;
|
||||
GotExtension = FALSE;
|
||||
while (p >= DllName->Buffer)
|
||||
{
|
||||
c = *p1;
|
||||
c = *p--;
|
||||
if (c == L'.')
|
||||
{
|
||||
p2 = p1;
|
||||
GotExtension = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (c == L'\\')
|
||||
|
@ -2445,8 +2445,8 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
}
|
||||
}
|
||||
|
||||
/* Check if no extension was found */
|
||||
if (!p2)
|
||||
/* If no extension was found, add the default extension */
|
||||
if (!GotExtension)
|
||||
{
|
||||
/* Check that we have space to add one */
|
||||
if ((DllName->Length + LdrApiDefaultExtension.Length + sizeof(UNICODE_NULL)) >=
|
||||
|
@ -2466,30 +2466,10 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
return STATUS_NAME_TOO_LONG;
|
||||
}
|
||||
|
||||
/* FIXME: CLEAN THIS UP WITH Rtl String Functions */
|
||||
/* Add it */
|
||||
RtlMoveMemory((PVOID)((ULONG_PTR)RawDllName + DllName->Length),
|
||||
LdrApiDefaultExtension.Buffer,
|
||||
LdrApiDefaultExtension.Length);
|
||||
|
||||
/* Save the length to a unicode string */
|
||||
RawDllNameString.Length = DllName->Length + LdrApiDefaultExtension.Length;
|
||||
|
||||
/* Null terminate it */
|
||||
RawDllName[RawDllNameString.Length / sizeof(WCHAR)] = 0;
|
||||
/* Add it. Needs to be null terminated, thus the length check above */
|
||||
(VOID)RtlAppendUnicodeStringToString(&RawDllName,
|
||||
&LdrApiDefaultExtension);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Null terminate it */
|
||||
RawDllName[DllName->Length / sizeof(WCHAR)] = 0;
|
||||
|
||||
/* Save the length to a unicode string */
|
||||
RawDllNameString.Length = DllName->Length;
|
||||
}
|
||||
|
||||
/* Now create a unicode string for the DLL's name */
|
||||
RawDllNameString.MaximumLength = sizeof(NameBuffer);
|
||||
RawDllNameString.Buffer = NameBuffer;
|
||||
|
||||
/* Check for init flag and acquire lock */
|
||||
if (!InInit) RtlEnterCriticalSection(&LdrpLoaderLock);
|
||||
|
@ -2497,14 +2477,14 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
/* Show debug message */
|
||||
if (ShowSnaps)
|
||||
{
|
||||
DPRINT1("LDR: LdrLoadDll, loading %ws from %ws\n",
|
||||
RawDllName,
|
||||
DPRINT1("LDR: LdrLoadDll, loading %wZ from %ws\n",
|
||||
&RawDllName,
|
||||
DllPath ? DllPath : L"");
|
||||
}
|
||||
|
||||
/* Check if the DLL is already loaded */
|
||||
if (!LdrpCheckForLoadedDll(DllPath,
|
||||
&RawDllNameString,
|
||||
&RawDllName,
|
||||
FALSE,
|
||||
Redirected,
|
||||
&LdrEntry))
|
||||
|
@ -2518,7 +2498,7 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
Redirected,
|
||||
&LdrEntry);
|
||||
if (!NT_SUCCESS(Status)) goto Quickie;
|
||||
|
||||
|
||||
/* FIXME: Need to mark the DLL range for the stack DB */
|
||||
//RtlpStkMarkDllRange(LdrEntry);
|
||||
|
||||
|
@ -2555,7 +2535,7 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
|
||||
/* Cancel the load */
|
||||
LdrpClearLoadInProgress();
|
||||
|
||||
|
||||
/* Unload the DLL */
|
||||
if (ShowSnaps)
|
||||
{
|
||||
|
@ -2590,7 +2570,7 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
|||
//ShimLoadCallback = RtlDecodeSystemPointer(g_pfnSE_DllLoaded);
|
||||
//ShimLoadCallback(LdrEntry);
|
||||
}
|
||||
|
||||
|
||||
/* Run the init routine */
|
||||
Status = LdrpRunInitializeRoutines(NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue