mirror of
https://github.com/reactos/reactos.git
synced 2025-06-22 20:30:18 +00:00
- Split LdrpProcessImportDirectory into LdrpProcessImportDirectory and
LdrpProcessImportDirectoryEntry. Sometimes it is necessary to process a single entry from import directory and sometimes it is necessary to process all entries with the same name. svn path=/trunk/; revision=8684
This commit is contained in:
parent
05825a6aab
commit
c417fd21b1
1 changed files with 121 additions and 105 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.83 2004/03/06 20:32:06 navaraf Exp $
|
/* $Id: utils.c,v 1.84 2004/03/13 18:14:04 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -1416,11 +1416,10 @@ LdrpGetOrLoadModule(PWCHAR SerachPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
LdrpProcessImportDirectory(
|
LdrpProcessImportDirectoryEntry(
|
||||||
PLDR_MODULE Module,
|
PLDR_MODULE Module,
|
||||||
PLDR_MODULE ImportedModule,
|
PLDR_MODULE ImportedModule,
|
||||||
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory,
|
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory)
|
||||||
PCHAR ImportedName)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID* ImportAddressList;
|
PVOID* ImportAddressList;
|
||||||
|
@ -1430,39 +1429,11 @@ LdrpProcessImportDirectory(
|
||||||
ULONG Ordinal;
|
ULONG Ordinal;
|
||||||
ULONG IATSize;
|
ULONG IATSize;
|
||||||
|
|
||||||
DPRINT("LdrpProcessImportDirectory(%x '%wZ', '%s')\n",
|
if (ImportModuleDirectory == NULL || ImportModuleDirectory->dwRVAModuleName == 0)
|
||||||
Module, &Module->BaseDllName, ImportedName);
|
|
||||||
|
|
||||||
if (ImportModuleDirectory == NULL)
|
|
||||||
{
|
|
||||||
PCHAR Name;
|
|
||||||
|
|
||||||
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
|
|
||||||
RtlImageDirectoryEntryToData(Module->BaseAddress,
|
|
||||||
TRUE,
|
|
||||||
IMAGE_DIRECTORY_ENTRY_IMPORT,
|
|
||||||
NULL);
|
|
||||||
if (ImportModuleDirectory == NULL)
|
|
||||||
{
|
{
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ImportModuleDirectory->dwRVAModuleName)
|
|
||||||
{
|
|
||||||
Name = (PCHAR)Module->BaseAddress + ImportModuleDirectory->dwRVAModuleName;
|
|
||||||
if (0 == _stricmp(Name, ImportedName))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ImportModuleDirectory++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImportModuleDirectory->dwRVAModuleName == 0)
|
|
||||||
{
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the import address list. */
|
/* Get the import address list. */
|
||||||
ImportAddressList = (PVOID *)(Module->BaseAddress + ImportModuleDirectory->dwRVAFunctionAddressList);
|
ImportAddressList = (PVOID *)(Module->BaseAddress + ImportModuleDirectory->dwRVAFunctionAddressList);
|
||||||
|
|
||||||
|
@ -1534,8 +1505,53 @@ LdrpProcessImportDirectory(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
LdrpProcessImportDirectory(
|
||||||
|
PLDR_MODULE Module,
|
||||||
|
PLDR_MODULE ImportedModule,
|
||||||
|
PCHAR ImportedName)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
|
||||||
|
PCHAR Name;
|
||||||
|
|
||||||
NTSTATUS LdrpAdjustImportDirectory(PLDR_MODULE Module,
|
DPRINT("LdrpProcessImportDirectory(%x '%wZ', '%s')\n",
|
||||||
|
Module, &Module->BaseDllName, ImportedName);
|
||||||
|
|
||||||
|
|
||||||
|
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
|
||||||
|
RtlImageDirectoryEntryToData(Module->BaseAddress,
|
||||||
|
TRUE,
|
||||||
|
IMAGE_DIRECTORY_ENTRY_IMPORT,
|
||||||
|
NULL);
|
||||||
|
if (ImportModuleDirectory == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (ImportModuleDirectory->dwRVAModuleName)
|
||||||
|
{
|
||||||
|
Name = (PCHAR)Module->BaseAddress + ImportModuleDirectory->dwRVAModuleName;
|
||||||
|
if (0 == _stricmp(Name, ImportedName))
|
||||||
|
{
|
||||||
|
Status = LdrpProcessImportDirectoryEntry(Module,
|
||||||
|
ImportedModule,
|
||||||
|
ImportModuleDirectory);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImportModuleDirectory++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
LdrpAdjustImportDirectory(PLDR_MODULE Module,
|
||||||
PLDR_MODULE ImportedModule,
|
PLDR_MODULE ImportedModule,
|
||||||
PUCHAR ImportedName)
|
PUCHAR ImportedName)
|
||||||
{
|
{
|
||||||
|
@ -1733,7 +1749,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
||||||
{
|
{
|
||||||
TRACE_LDR("%wZ has stale binding to %wZ\n",
|
TRACE_LDR("%wZ has stale binding to %wZ\n",
|
||||||
&Module->BaseDllName, &ImportedModule->BaseDllName);
|
&Module->BaseDllName, &ImportedModule->BaseDllName);
|
||||||
Status = LdrpProcessImportDirectory(Module, ImportedModule, NULL, ImportedName);
|
Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("failed to import %s\n", ImportedName);
|
DPRINT1("failed to import %s\n", ImportedName);
|
||||||
|
@ -1794,7 +1810,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
||||||
if (WrongForwarder ||
|
if (WrongForwarder ||
|
||||||
ImportedModule->Flags & IMAGE_NOT_AT_BASE)
|
ImportedModule->Flags & IMAGE_NOT_AT_BASE)
|
||||||
{
|
{
|
||||||
Status = LdrpProcessImportDirectory(Module, ImportedModule, NULL, ImportedName);
|
Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("failed to import %s\n", ImportedName);
|
DPRINT1("failed to import %s\n", ImportedName);
|
||||||
|
@ -1820,7 +1836,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
||||||
*/
|
*/
|
||||||
TRACE_LDR("Stale BIND %s from %wZ\n",
|
TRACE_LDR("Stale BIND %s from %wZ\n",
|
||||||
ImportedName, &Module->BaseDllName);
|
ImportedName, &Module->BaseDllName);
|
||||||
Status = LdrpProcessImportDirectory(Module, ImportedModule, NULL, ImportedName);
|
Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportedName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("faild to import %s\n", ImportedName);
|
DPRINT1("faild to import %s\n", ImportedName);
|
||||||
|
@ -1858,7 +1874,7 @@ LdrFixupImports(IN PWSTR SearchPath OPTIONAL,
|
||||||
|
|
||||||
TRACE_LDR("Initializing imports for %wZ from %s\n",
|
TRACE_LDR("Initializing imports for %wZ from %s\n",
|
||||||
&Module->BaseDllName, ImportedName);
|
&Module->BaseDllName, ImportedName);
|
||||||
Status = LdrpProcessImportDirectory(Module, ImportedModule, ImportModuleDirectoryCurrent, ImportedName);
|
Status = LdrpProcessImportDirectoryEntry(Module, ImportedModule, ImportModuleDirectoryCurrent);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("failed to import %s\n", ImportedName);
|
DPRINT1("failed to import %s\n", ImportedName);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue