mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 16:53:33 +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
|
@ -2415,28 +2415,28 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
||||||
{
|
{
|
||||||
PPEB Peb = NtCurrentPeb();
|
PPEB Peb = NtCurrentPeb();
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PWCHAR p1, p2, p1min;
|
const WCHAR *p;
|
||||||
|
BOOLEAN GotExtension;
|
||||||
WCHAR c;
|
WCHAR c;
|
||||||
WCHAR NameBuffer[MAX_PATH+6];
|
WCHAR NameBuffer[MAX_PATH + 6];
|
||||||
LPWSTR RawDllName;
|
UNICODE_STRING RawDllName;
|
||||||
UNICODE_STRING RawDllNameString;
|
|
||||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||||
BOOLEAN InInit = LdrpInLdrInit;
|
BOOLEAN InInit = LdrpInLdrInit;
|
||||||
|
|
||||||
/* Save the Raw DLL Name */
|
/* Save the Raw DLL Name */
|
||||||
RawDllName = NameBuffer;
|
|
||||||
if (DllName->Length >= sizeof(NameBuffer)) return STATUS_NAME_TOO_LONG;
|
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 */
|
/* Find the extension, if present */
|
||||||
p1 = DllName->Buffer + DllName->Length / sizeof(WCHAR) - 1;
|
p = DllName->Buffer + DllName->Length / sizeof(WCHAR) - 1;
|
||||||
p2 = NULL;
|
GotExtension = FALSE;
|
||||||
for (p1min = DllName->Buffer; p1 >= p1min; p1--)
|
while (p >= DllName->Buffer)
|
||||||
{
|
{
|
||||||
c = *p1;
|
c = *p--;
|
||||||
if (c == L'.')
|
if (c == L'.')
|
||||||
{
|
{
|
||||||
p2 = p1;
|
GotExtension = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (c == L'\\')
|
else if (c == L'\\')
|
||||||
|
@ -2445,8 +2445,8 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if no extension was found */
|
/* If no extension was found, add the default extension */
|
||||||
if (!p2)
|
if (!GotExtension)
|
||||||
{
|
{
|
||||||
/* Check that we have space to add one */
|
/* Check that we have space to add one */
|
||||||
if ((DllName->Length + LdrApiDefaultExtension.Length + sizeof(UNICODE_NULL)) >=
|
if ((DllName->Length + LdrApiDefaultExtension.Length + sizeof(UNICODE_NULL)) >=
|
||||||
|
@ -2466,30 +2466,10 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
||||||
return STATUS_NAME_TOO_LONG;
|
return STATUS_NAME_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: CLEAN THIS UP WITH Rtl String Functions */
|
/* Add it. Needs to be null terminated, thus the length check above */
|
||||||
/* Add it */
|
(VOID)RtlAppendUnicodeStringToString(&RawDllName,
|
||||||
RtlMoveMemory((PVOID)((ULONG_PTR)RawDllName + DllName->Length),
|
&LdrApiDefaultExtension);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
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 */
|
/* Check for init flag and acquire lock */
|
||||||
if (!InInit) RtlEnterCriticalSection(&LdrpLoaderLock);
|
if (!InInit) RtlEnterCriticalSection(&LdrpLoaderLock);
|
||||||
|
@ -2497,14 +2477,14 @@ LdrpLoadDll(IN BOOLEAN Redirected,
|
||||||
/* Show debug message */
|
/* Show debug message */
|
||||||
if (ShowSnaps)
|
if (ShowSnaps)
|
||||||
{
|
{
|
||||||
DPRINT1("LDR: LdrLoadDll, loading %ws from %ws\n",
|
DPRINT1("LDR: LdrLoadDll, loading %wZ from %ws\n",
|
||||||
RawDllName,
|
&RawDllName,
|
||||||
DllPath ? DllPath : L"");
|
DllPath ? DllPath : L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the DLL is already loaded */
|
/* Check if the DLL is already loaded */
|
||||||
if (!LdrpCheckForLoadedDll(DllPath,
|
if (!LdrpCheckForLoadedDll(DllPath,
|
||||||
&RawDllNameString,
|
&RawDllName,
|
||||||
FALSE,
|
FALSE,
|
||||||
Redirected,
|
Redirected,
|
||||||
&LdrEntry))
|
&LdrEntry))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue