Don't call DriverEntry more than once. Fix suggested by Filip Navara.
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
Modified: trunk/reactos/ntoskrnl/io/driver.c
Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c
_____
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
--- trunk/reactos/ntoskrnl/include/internal/io.h 2005-04-11
21:50:15 UTC (rev 14593)
+++ trunk/reactos/ntoskrnl/include/internal/io.h 2005-04-11
22:29:31 UTC (rev 14594)
@@ -478,6 +478,7 @@
IopCreateDriverObject(
PDRIVER_OBJECT *DriverObject,
PUNICODE_STRING ServiceName,
+ ULONG CreateAttributes,
BOOLEAN FileSystemDriver,
PVOID DriverImageStart,
ULONG DriverImageSize);
_____
Modified: trunk/reactos/ntoskrnl/io/driver.c
--- trunk/reactos/ntoskrnl/io/driver.c 2005-04-11 21:50:15 UTC (rev
14593)
+++ trunk/reactos/ntoskrnl/io/driver.c 2005-04-11 22:29:31 UTC (rev
14594)
@@ -199,6 +199,7 @@
IopCreateDriverObject(
PDRIVER_OBJECT *DriverObject,
PUNICODE_STRING ServiceName,
+ ULONG CreateAttributes,
BOOLEAN FileSystem,
PVOID DriverImageStart,
ULONG DriverImageSize)
@@ -240,7 +241,7 @@
InitializeObjectAttributes(
&ObjectAttributes,
&DriverName,
- OBJ_PERMANENT,
+ CreateAttributes | OBJ_PERMANENT,
NULL,
NULL);
@@ -265,9 +266,14 @@
Object->DriverSize = DriverImageSize;
if (Buffer)
{
- Object->DriverName.Buffer = Buffer;
- Object->DriverName.Length = Object->DriverName.MaximumLength =
DriverName.Length;
- RtlCopyMemory(Object->DriverName.Buffer, DriverName.Buffer,
DriverName.Length);
+ if (!Object->DriverName.Buffer)
+ {
+ Object->DriverName.Buffer = Buffer;
+ Object->DriverName.Length = Object->DriverName.MaximumLength =
DriverName.Length;
+ RtlCopyMemory(Object->DriverName.Buffer, DriverName.Buffer,
DriverName.Length);
+ }
+ else
+ ExFreePool(Buffer);
}
*DriverObject = Object;
@@ -479,7 +485,7 @@
else
{
DPRINT("Module already loaded\n");
- Status = STATUS_SUCCESS;
+ Status = STATUS_IMAGE_ALREADY_LOADED;
}
RtlFreeUnicodeString(&ServiceImagePath);
@@ -538,6 +544,7 @@
Status = IopCreateDriverObject(
DriverObject,
ServiceName,
+ 0,
FileSystemDriver,
ModuleObject->Base,
ModuleObject->Length);
@@ -614,13 +621,29 @@
/* Load and initialize the filter driver */
Status = IopLoadServiceModule(&ServiceName, &ModuleObject);
- if (!NT_SUCCESS(Status))
- continue;
+ if (Status != STATUS_IMAGE_ALREADY_LOADED)
+ {
+ if (!NT_SUCCESS(Status))
+ continue;
- Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
&ServiceName,
- FALSE, &DriverObject);
- if (!NT_SUCCESS(Status))
- continue;
+ Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
&ServiceName,
+ FALSE, &DriverObject);
+ if (!NT_SUCCESS(Status))
+ continue;
+ }
+ else
+ {
+ /* get existing DriverObject pointer */
+ Status = IopCreateDriverObject(
+ &DriverObject,
+ &ServiceName,
+ OBJ_OPENIF,
+ FALSE,
+ ModuleObject->Base,
+ ModuleObject->Length);
+ if (!NT_SUCCESS(Status))
+ continue;
+ }
Status = IopInitializeDevice(DeviceNode, DriverObject);
if (!NT_SUCCESS(Status))
_____
Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c
--- trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-04-11 21:50:15 UTC (rev
14593)
+++ trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-04-11 22:29:31 UTC (rev
14594)
@@ -1499,10 +1499,22 @@
PDRIVER_OBJECT DriverObject;
Status = IopLoadServiceModule(&DeviceNode->ServiceName,
&ModuleObject);
- if (NT_SUCCESS(Status))
+ if (NT_SUCCESS(Status) || Status == STATUS_IMAGE_ALREADY_LOADED)
{
- Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
- &DeviceNode->ServiceName, FALSE, &DriverObject);
+ if (Status != STATUS_IMAGE_ALREADY_LOADED)
+ Status = IopInitializeDriverModule(DeviceNode,
ModuleObject,
+ &DeviceNode->ServiceName, FALSE, &DriverObject);
+ else
+ {
+ /* get existing DriverObject pointer */
+ Status = IopCreateDriverObject(
+ &DriverObject,
+ &DeviceNode->ServiceName,
+ OBJ_OPENIF,
+ FALSE,
+ ModuleObject->Base,
+ ModuleObject->Length);
+ }
if (NT_SUCCESS(Status))
{
/* Attach lower level filter drivers. */
@@ -1787,7 +1799,7 @@
* Create root device node
*/
- Status = IopCreateDriverObject(&IopRootDriverObject, NULL, FALSE,
NULL, 0);
+ Status = IopCreateDriverObject(&IopRootDriverObject, NULL, 0, FALSE,
NULL, 0);
if (!NT_SUCCESS(Status))
{
CPRINT("IoCreateDriverObject() failed\n");