Author: mjmartin
Date: Fri Sep 10 21:25:53 2010
New Revision: 48738
URL:
http://svn.reactos.org/svn/reactos?rev=48738&view=rev
Log:
[ntoskrnl/io]
- Modify IopCreateDriver to accept the PLDR_DATA_TABLE_ENTRY instead of the DllBase and
SizeOfImage from this structure.
- Set the DriverObject->DriverSection before calling the DriverEntry routine.
- If the DriverEntry routine fails then set the DriverObject->DriverSection back to
NULL so that IopDeleteDriver doesnt attempt to unload the ModuleObject, after it was
already unloaded by the caller.
Modified:
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/io/iomgr/driver.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Fri Sep 10 21:25:53 2010
@@ -996,8 +996,7 @@
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
IN PUNICODE_STRING RegistryPath,
- IN PVOID DllBase,
- IN ULONG SizeOfImage,
+ PLDR_DATA_TABLE_ENTRY ModuleObject,
OUT PDRIVER_OBJECT *pDriverObject);
VOID
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Fri Sep 10 21:25:53 2010
@@ -481,8 +481,7 @@
DriverName.Length > 0 ? &DriverName : NULL,
DriverEntry,
&RegistryKey,
- ModuleObject->DllBase,
- ModuleObject->SizeOfImage,
+ ModuleObject,
&Driver);
RtlFreeUnicodeString(&RegistryKey);
@@ -1388,8 +1387,7 @@
IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
IN PDRIVER_INITIALIZE InitializationFunction,
IN PUNICODE_STRING RegistryPath,
- IN PVOID DllBase,
- IN ULONG SizeOfImage,
+ PLDR_DATA_TABLE_ENTRY ModuleObject,
OUT PDRIVER_OBJECT *pDriverObject)
{
WCHAR NameBuffer[100];
@@ -1451,7 +1449,7 @@
DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1);
DriverObject->DriverExtension->DriverObject = DriverObject;
DriverObject->DriverInit = InitializationFunction;
-
+ DriverObject->DriverSection = ModuleObject;
/* Loop all Major Functions */
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
@@ -1525,8 +1523,8 @@
ZwClose(hDriver);
DriverObject->HardwareDatabase = &IopHardwareDatabaseKey;
- DriverObject->DriverStart = DllBase;
- DriverObject->DriverSize = SizeOfImage;
+ DriverObject->DriverStart = ModuleObject ? ModuleObject->DllBase : 0;
+ DriverObject->DriverSize = ModuleObject ? ModuleObject->SizeOfImage : 0;
/* Finally, call its init function */
DPRINT("RegistryKey: %wZ\n", RegistryPath);
@@ -1536,6 +1534,7 @@
{
/* If it didn't work, then kill the object */
DPRINT1("'%wZ' initialization failed, status (0x%08lx)\n",
DriverName, Status);
+ DriverObject->DriverSection = NULL;
ObMakeTemporaryObject(DriverObject);
ObDereferenceObject(DriverObject);
}
@@ -1581,7 +1580,7 @@
IN PDRIVER_INITIALIZE InitializationFunction)
{
PDRIVER_OBJECT DriverObject;
- return IopCreateDriver(DriverName, InitializationFunction, NULL, 0, 0,
&DriverObject);
+ return IopCreateDriver(DriverName, InitializationFunction, NULL, NULL,
&DriverObject);
}
/*
@@ -1895,6 +1894,7 @@
*/
Status = MmLoadSystemImage(&ImagePath, NULL, NULL, 0,
(PVOID)&ModuleObject, &BaseAddress);
+
if (!NT_SUCCESS(Status) && Status != STATUS_IMAGE_ALREADY_LOADED)
{
DPRINT("MmLoadSystemImage() failed (Status %lx)\n", Status);
@@ -1934,9 +1934,6 @@
}
}
- /* Store its DriverSection, so that it could be unloaded */
- DriverObject->DriverSection = ModuleObject;
-
/* Initialize and start device */
IopInitializeDevice(DeviceNode, DriverObject);
Status = IopStartDevice(DeviceNode);