mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Added check for loaded module prior to loading it.
svn path=/trunk/; revision=3157
This commit is contained in:
parent
5b7f97ebf6
commit
1f6b602dc5
2 changed files with 24 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: driver.c,v 1.7 2002/06/18 07:11:44 ekohl Exp $
|
||||
/* $Id: driver.c,v 1.8 2002/06/27 17:49:34 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -198,6 +198,12 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName)
|
|||
return(Status);
|
||||
}
|
||||
|
||||
ModuleObject = LdrGetModuleObject(DriverServiceName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
return(STATUS_IMAGE_ALREADY_LOADED);
|
||||
}
|
||||
|
||||
Status = LdrLoadModule(&FullImagePath, &ModuleObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.113 2002/06/16 11:44:34 ekohl Exp $
|
||||
/* $Id: loader.c,v 1.114 2002/06/27 17:52:32 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -736,10 +736,14 @@ LdrpLoadImage(PUNICODE_STRING DriverName,
|
|||
PMODULE_OBJECT ModuleObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = LdrLoadModule(DriverName, &ModuleObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ModuleObject = LdrGetModuleObject(DriverName);
|
||||
if (ModuleObject == NULL)
|
||||
{
|
||||
return(Status);
|
||||
Status = LdrLoadModule(DriverName, &ModuleObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModuleBase)
|
||||
|
@ -772,6 +776,12 @@ LdrpLoadAndCallImage(PUNICODE_STRING ModuleName)
|
|||
PMODULE_OBJECT ModuleObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
ModuleObject = LdrGetModuleObject(ModuleName);
|
||||
if (ModuleObject != NULL)
|
||||
{
|
||||
return(STATUS_IMAGE_ALREADY_LOADED);
|
||||
}
|
||||
|
||||
Status = LdrLoadModule(ModuleName, &ModuleObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -804,14 +814,6 @@ LdrLoadModule(PUNICODE_STRING Filename,
|
|||
|
||||
*ModuleObject = NULL;
|
||||
|
||||
/* Check for module already loaded */
|
||||
Module = LdrGetModuleObject(Filename);
|
||||
if (Module != NULL)
|
||||
{
|
||||
*ModuleObject = Module;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DPRINT("Loading Module %wZ...\n", Filename);
|
||||
|
||||
/* Open the Module */
|
||||
|
@ -1329,7 +1331,7 @@ LdrGetModuleObject(PUNICODE_STRING ModuleName)
|
|||
|
||||
KeReleaseSpinLock(&ModuleListLock, Irql);
|
||||
|
||||
CPRINT("LdrpGetModuleObject: Failed to find module %wZ\n", ModuleName);
|
||||
DPRINT("Could not find module '%wZ'\n", ModuleName);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
@ -1558,7 +1560,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
|
|||
LibraryModuleObject = LdrGetModuleObject(&ModuleName);
|
||||
if (LibraryModuleObject == NULL)
|
||||
{
|
||||
DPRINT("Module '%wZ' not loaded\n", &ModuleName);
|
||||
CPRINT("Module '%wZ' not loaded yet\n", &ModuleName);
|
||||
wcscpy(NameBuffer, L"\\SystemRoot\\system32\\drivers\\");
|
||||
wcscat(NameBuffer, ModuleName.Buffer);
|
||||
RtlInitUnicodeString(&NameString, NameBuffer);
|
||||
|
@ -1997,7 +1999,7 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
|
|||
FunctionList[Hint - ExportDir->Base]);
|
||||
}
|
||||
|
||||
if (ExportAddress == 0)
|
||||
if (ExportAddress == NULL)
|
||||
{
|
||||
CPRINT("Export not found for %d:%s\n",
|
||||
Hint,
|
||||
|
|
Loading…
Reference in a new issue