mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:25:39 +00:00
[NTDLL]
- In LdrpLoadImportModule, check for import module extension, and append it if not found. - Fix LdrpLoadImportModule prototype. CORE-11360 svn path=/trunk/; revision=71507
This commit is contained in:
parent
fe0b048d53
commit
0d6d9c18cc
2 changed files with 48 additions and 7 deletions
|
@ -155,7 +155,6 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
|
LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
|
||||||
IN LPSTR ImportName,
|
IN LPSTR ImportName,
|
||||||
IN PVOID DllBase,
|
|
||||||
OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
|
OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
|
||||||
OUT PBOOLEAN Existing);
|
OUT PBOOLEAN Existing);
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,6 @@ LdrpHandleOneNewFormatImportDescriptor(IN LPWSTR DllPath OPTIONAL,
|
||||||
/* Load the module for this entry */
|
/* Load the module for this entry */
|
||||||
Status = LdrpLoadImportModule(DllPath,
|
Status = LdrpLoadImportModule(DllPath,
|
||||||
BoundImportName,
|
BoundImportName,
|
||||||
LdrEntry->DllBase,
|
|
||||||
&DllLdrEntry,
|
&DllLdrEntry,
|
||||||
&AlreadyLoaded);
|
&AlreadyLoaded);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -371,7 +370,6 @@ LdrpHandleOneNewFormatImportDescriptor(IN LPWSTR DllPath OPTIONAL,
|
||||||
/* Load the module */
|
/* Load the module */
|
||||||
Status = LdrpLoadImportModule(DllPath,
|
Status = LdrpLoadImportModule(DllPath,
|
||||||
ForwarderName,
|
ForwarderName,
|
||||||
LdrEntry->DllBase,
|
|
||||||
&ForwarderLdrEntry,
|
&ForwarderLdrEntry,
|
||||||
&AlreadyLoaded);
|
&AlreadyLoaded);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
@ -558,7 +556,6 @@ LdrpHandleOneOldFormatImportDescriptor(IN LPWSTR DllPath OPTIONAL,
|
||||||
/* Load the module associated to it */
|
/* Load the module associated to it */
|
||||||
Status = LdrpLoadImportModule(DllPath,
|
Status = LdrpLoadImportModule(DllPath,
|
||||||
ImportName,
|
ImportName,
|
||||||
LdrEntry->DllBase,
|
|
||||||
&DllLdrEntry,
|
&DllLdrEntry,
|
||||||
&AlreadyLoaded);
|
&AlreadyLoaded);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -818,22 +815,24 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: This function is missing SxS support and has wrong prototype */
|
/* FIXME: This function is missing SxS support */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
|
LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
|
||||||
IN LPSTR ImportName,
|
IN LPSTR ImportName,
|
||||||
IN PVOID DllBase,
|
|
||||||
OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
|
OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
|
||||||
OUT PBOOLEAN Existing)
|
OUT PBOOLEAN Existing)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
PUNICODE_STRING ImpDescName;
|
PUNICODE_STRING ImpDescName;
|
||||||
|
const WCHAR *p;
|
||||||
|
BOOLEAN GotExtension;
|
||||||
|
WCHAR c;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PPEB Peb = RtlGetCurrentPeb();
|
PPEB Peb = RtlGetCurrentPeb();
|
||||||
PTEB Teb = NtCurrentTeb();
|
PTEB Teb = NtCurrentTeb();
|
||||||
|
|
||||||
DPRINT("LdrpLoadImportModule('%s' %p %p %p '%S')\n", ImportName, DllBase, DataTableEntry, Existing, DllPath);
|
DPRINT("LdrpLoadImportModule('%S' '%s' %p %p)\n", DllPath, ImportName, DataTableEntry, Existing);
|
||||||
|
|
||||||
/* Convert import descriptor name to unicode string */
|
/* Convert import descriptor name to unicode string */
|
||||||
ImpDescName = &Teb->StaticUnicodeString;
|
ImpDescName = &Teb->StaticUnicodeString;
|
||||||
|
@ -841,6 +840,49 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
|
||||||
Status = RtlAnsiStringToUnicodeString(ImpDescName, &AnsiString, FALSE);
|
Status = RtlAnsiStringToUnicodeString(ImpDescName, &AnsiString, FALSE);
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
||||||
|
/* Find the extension, if present */
|
||||||
|
p = ImpDescName->Buffer + ImpDescName->Length / sizeof(WCHAR) - 1;
|
||||||
|
GotExtension = FALSE;
|
||||||
|
while (p >= ImpDescName->Buffer)
|
||||||
|
{
|
||||||
|
c = *p--;
|
||||||
|
if (c == L'.')
|
||||||
|
{
|
||||||
|
GotExtension = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (c == L'\\')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If no extension was found, add the default extension */
|
||||||
|
if (!GotExtension)
|
||||||
|
{
|
||||||
|
/* Check that we have space to add one */
|
||||||
|
if ((ImpDescName->Length + LdrApiDefaultExtension.Length + sizeof(UNICODE_NULL)) >=
|
||||||
|
sizeof(Teb->StaticUnicodeBuffer))
|
||||||
|
{
|
||||||
|
/* No space to add the extension */
|
||||||
|
DbgPrintEx(DPFLTR_LDR_ID,
|
||||||
|
DPFLTR_ERROR_LEVEL,
|
||||||
|
"LDR: %s - Dll name missing extension; with extension "
|
||||||
|
"added the name is too long\n"
|
||||||
|
" ImpDescName: (@ %p) \"%wZ\"\n"
|
||||||
|
" ImpDescName->Length: %u\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ImpDescName,
|
||||||
|
ImpDescName,
|
||||||
|
ImpDescName->Length);
|
||||||
|
return STATUS_NAME_TOO_LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add it. Needs to be null terminated, thus the length check above */
|
||||||
|
(VOID)RtlAppendUnicodeStringToString(ImpDescName,
|
||||||
|
&LdrApiDefaultExtension);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if it's loaded */
|
/* Check if it's loaded */
|
||||||
if (LdrpCheckForLoadedDll(DllPath,
|
if (LdrpCheckForLoadedDll(DllPath,
|
||||||
ImpDescName,
|
ImpDescName,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue