- Rename LdrLoadModule to MmLoadSystemImage and change prototype. No code change except update callers and return ImageBaseAddress parameter when requested.

svn path=/trunk/; revision=25875
This commit is contained in:
Alex Ionescu 2007-02-22 18:30:50 +00:00
parent 31446c8a3b
commit f141767094
5 changed files with 38 additions and 21 deletions

View file

@ -1267,7 +1267,6 @@ SSI_DEF(SystemLoadGdiDriverInformation)
PVOID ImageBase;
ULONG_PTR EntryPoint;
NTSTATUS Status;
PLDR_DATA_TABLE_ENTRY ModuleObject;
ULONG DirSize;
PIMAGE_NT_HEADERS NtHeader;
@ -1283,11 +1282,15 @@ SSI_DEF(SystemLoadGdiDriverInformation)
/* Load the driver */
ImageName = DriverInfo->DriverName;
Status = LdrLoadModule(&ImageName, &ModuleObject);
Status = MmLoadSystemImage(&ImageName,
NULL,
NULL,
0,
NULL,
&ImageBase);
if (!NT_SUCCESS(Status)) return Status;
/* Return the export pointer */
ImageBase = ModuleObject->DllBase;
DriverInfo->ExportSectionPointer =
RtlImageDirectoryEntryToData(ImageBase,
TRUE,
@ -1479,11 +1482,15 @@ SSI_DEF(SystemExtendServiceTableInformation)
ImageName = *(PUNICODE_STRING)Buffer;
/* Load the image */
Status = LdrLoadModule(&ImageName, &ModuleObject);
Status = MmLoadSystemImage(&ImageName,
NULL,
NULL,
0,
(PVOID)&ModuleObject,
&ImageBase);
if (!NT_SUCCESS(Status)) return Status;
/* Get the headers */
ImageBase = ModuleObject->DllBase;
NtHeader = RtlImageNtHeader(ImageBase);
if (!NtHeader)
{

View file

@ -66,10 +66,12 @@ LdrInitDebug(
NTSTATUS
NTAPI
LdrLoadModule(
PUNICODE_STRING Filename,
PLDR_DATA_TABLE_ENTRY *ModuleObject
);
MmLoadSystemImage(IN PUNICODE_STRING FileName,
IN PUNICODE_STRING NamePrefix OPTIONAL,
IN PUNICODE_STRING LoadedName OPTIONAL,
IN ULONG Flags,
OUT PVOID *ModuleObject,
OUT PVOID *ImageBaseAddress);
NTSTATUS
NTAPI

View file

@ -455,7 +455,7 @@ IopLoadServiceModule(
else
{
DPRINT("Loading module\n");
Status = LdrLoadModule(&ServiceImagePath, ModuleObject);
Status = MmLoadSystemImage(&ServiceImagePath, NULL, NULL, 0, (PVOID)ModuleObject, NULL);
}
}
else
@ -1721,11 +1721,10 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName)
* Load the driver module
*/
Status = LdrLoadModule(&ImagePath, &ModuleObject);
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0, (PVOID)&ModuleObject, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("LdrLoadModule() failed (Status %lx)\n", Status);
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
IopFreeDeviceNode(DeviceNode);
goto ReleaseCapturedString;
}

View file

@ -173,9 +173,12 @@ LdrUnloadModule ( PLDR_DATA_TABLE_ENTRY ModuleObject )
//
NTSTATUS
NTAPI
LdrLoadModule(
PUNICODE_STRING FileName,
PLDR_DATA_TABLE_ENTRY *ModuleObject )
MmLoadSystemImage(IN PUNICODE_STRING FileName,
IN PUNICODE_STRING NamePrefix OPTIONAL,
IN PUNICODE_STRING LoadedName OPTIONAL,
IN ULONG Flags,
OUT PVOID *ModuleObject,
OUT PVOID *ImageBaseAddress)
{
PVOID ModuleLoadBase;
NTSTATUS Status;
@ -199,7 +202,8 @@ LdrLoadModule(
PCHAR MissingApiName, Buffer;
PWCHAR MissingDriverName;
*ModuleObject = NULL;
if (ModuleObject) *ModuleObject = NULL;
if (ImageBaseAddress) *ImageBaseAddress = NULL;
DPRINT("Loading Module %wZ...\n", FileName);
@ -507,7 +511,8 @@ LdrLoadModule(
/* Cleanup */
ExFreePool(ModuleLoadBase);
*ModuleObject = Module;
if (ModuleObject) *ModuleObject = Module;
if (ImageBaseAddress) *ImageBaseAddress = Module->DllBase;
/* Hook for KDB on loading a driver. */
KDB_LOADDRIVER_HOOK(FileName, Module);

View file

@ -484,7 +484,12 @@ CheckDllState:
DllName.Buffer[(DllName.MaximumLength - 1) / 2] = UNICODE_NULL;
/* Load the image */
Status = LdrLoadModule(&DllName, &DllEntry);
Status = MmLoadSystemImage(&DllName,
NamePrefix,
NULL,
0,
(PVOID)&DllEntry,
&DllBase);
if (NT_SUCCESS(Status))
{
/* We can free the DLL Name */
@ -511,8 +516,7 @@ CheckDllState:
/* We're now loaded */
Loaded = TRUE;
/* Get the base address and other information */
DllBase = DllEntry->DllBase;
/* Sanity check */
ASSERT(DllBase = DllEntry->DllBase);
/* Call the initialization routines */