diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index d52ed8f717e..8615b4b2241 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -480,6 +480,7 @@ NTSTATUS IopCreateDeviceNode( IN PDEVICE_NODE ParentNode, IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PUNICODE_STRING ServiceName, OUT PDEVICE_NODE *DeviceNode ); @@ -781,6 +782,7 @@ PnpRootDriverEntry( NTSTATUS PnpRootCreateDevice( + IN PUNICODE_STRING ServiceName, IN OUT PDEVICE_OBJECT *PhysicalDeviceObject ); diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 04fbcb86220..23ac695fc0f 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -726,7 +726,9 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) PWCHAR FileNameWithoutPath; LPWSTR FileExtension; PUNICODE_STRING ModuleName = &LdrEntry->BaseDllName; + UNICODE_STRING ServiceName; #if 1 // Disable for FreeLDR 2.5 + UNICODE_STRING ServiceNameWithExtension; PLDR_DATA_TABLE_ENTRY ModuleObject; #endif @@ -735,18 +737,6 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) */ IopDisplayLoadingMessage(ModuleName->Buffer, TRUE); - /* - * Determine the right device object - */ - /* Use IopRootDeviceNode for now */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); - if (!NT_SUCCESS(Status)) - { - CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); - return(Status); - } - - /* * Generate filename without path (not needed by freeldr) */ @@ -763,13 +753,11 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) /* * Load the module. */ - RtlCreateUnicodeString(&DeviceNode->ServiceName, FileNameWithoutPath); - #if 1 // Remove for FreeLDR 2.5. - Status = LdrProcessDriverModule(LdrEntry, &DeviceNode->ServiceName, &ModuleObject); + RtlCreateUnicodeString(&ServiceNameWithExtension, FileNameWithoutPath); + Status = LdrProcessDriverModule(LdrEntry, &ServiceNameWithExtension, &ModuleObject); if (!NT_SUCCESS(Status)) { - IopFreeDeviceNode(DeviceNode); CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); return Status; } @@ -778,13 +766,26 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) /* * Strip the file extension from ServiceName */ - FileExtension = wcsrchr(DeviceNode->ServiceName.Buffer, '.'); + RtlCreateUnicodeString(&ServiceName, FileNameWithoutPath); + FileExtension = wcsrchr(ServiceName.Buffer, '.'); if (FileExtension != NULL) { - DeviceNode->ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR); + ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR); FileExtension[0] = 0; } + /* + * Determine the right device object + */ + /* Use IopRootDeviceNode for now */ + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode); + if (!NT_SUCCESS(Status)) + { + CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); + return(Status); + } + DeviceNode->ServiceName = ServiceName; + /* * Initialize the driver */ @@ -793,7 +794,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) if (!NT_SUCCESS(Status)) { - IopFreeDeviceNode(DeviceNode); + IopFreeDeviceNode(DeviceNode); CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); return Status; } @@ -830,7 +831,7 @@ IopInitializeBootDrivers(VOID) NTSTATUS Status; /* Use IopRootDeviceNode for now */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, NULL, &DeviceNode); if (!NT_SUCCESS(Status)) return; /* Setup the module object for the RAW FS Driver */ @@ -1577,7 +1578,7 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName) */ /* Use IopRootDeviceNode for now */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode); if (!NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 03ba255e4cc..0e13c736275 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -789,14 +789,15 @@ Quickie: NTSTATUS IopCreateDeviceNode(PDEVICE_NODE ParentNode, PDEVICE_OBJECT PhysicalDeviceObject, + PUNICODE_STRING ServiceName, PDEVICE_NODE *DeviceNode) { PDEVICE_NODE Node; NTSTATUS Status; KIRQL OldIrql; - DPRINT("ParentNode 0x%p PhysicalDeviceObject 0x%p\n", - ParentNode, PhysicalDeviceObject); + DPRINT("ParentNode 0x%p PhysicalDeviceObject 0x%p ServiceName %wZ\n", + ParentNode, PhysicalDeviceObject, ServiceName); Node = (PDEVICE_NODE)ExAllocatePool(NonPagedPool, sizeof(DEVICE_NODE)); if (!Node) @@ -808,7 +809,7 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode, if (!PhysicalDeviceObject) { - Status = PnpRootCreateDevice(&PhysicalDeviceObject); + Status = PnpRootCreateDevice(ServiceName, &PhysicalDeviceObject); if (!NT_SUCCESS(Status)) { ExFreePool(Node); @@ -2386,7 +2387,8 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, DeviceNode->ServiceName.Buffer, Status); } } - } else + } + else { DPRINT("Service %S is disabled or already initialized\n", DeviceNode->ServiceName.Buffer); @@ -2531,6 +2533,7 @@ IopInvalidateDeviceRelations( Status = IopCreateDeviceNode( DeviceNode, DeviceRelations->Objects[i], + NULL, &ChildDeviceNode); DeviceNode->Flags |= DNF_ENUMERATED; if (!NT_SUCCESS(Status)) @@ -3297,7 +3300,7 @@ PnpInit(VOID) KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0); } - Status = IopCreateDeviceNode(NULL, Pdo, &IopRootDeviceNode); + Status = IopCreateDeviceNode(NULL, Pdo, NULL, &IopRootDeviceNode); if (!NT_SUCCESS(Status)) { CPRINT("Insufficient resources\n"); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c index 05cf170c584..3bd084c6e4e 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c @@ -45,8 +45,12 @@ IoReportDetectedDevice( Pdo = *DeviceObject; else { + UNICODE_STRING ServiceName; + ServiceName.Buffer = DriverObject->DriverName.Buffer + sizeof(DRIVER_ROOT_NAME) / sizeof(WCHAR) - 1; + ServiceName.Length = ServiceName.MaximumLength = DriverObject->DriverName.Length - sizeof(DRIVER_ROOT_NAME) + sizeof(WCHAR); + /* create a new PDO and return it in *DeviceObject */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &ServiceName, &DeviceNode); if (!NT_SUCCESS(Status)) { DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnproot.c b/reactos/ntoskrnl/io/pnpmgr/pnproot.c index 2f72a3b42d9..550807d5a16 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnproot.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnproot.c @@ -108,6 +108,7 @@ PDEVICE_OBJECT PnpRootDeviceObject; NTSTATUS PnpRootCreateDevice( + PUNICODE_STRING ServiceName, PDEVICE_OBJECT *PhysicalDeviceObject) { PPNPROOT_PDO_DEVICE_EXTENSION PdoDeviceExtension;