- Fix IoReportDetectedDevice to use the caller's driver object

svn path=/trunk/; revision=53392
This commit is contained in:
Cameron Gutman 2011-08-23 03:57:24 +00:00
parent 4ee1da837b
commit 6cf62841ad
4 changed files with 15 additions and 13 deletions

View file

@ -1022,6 +1022,7 @@ PnpRootDriverEntry(
NTSTATUS NTSTATUS
PnpRootCreateDevice( PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName, IN PUNICODE_STRING ServiceName,
IN OPTIONAL PDRIVER_OBJECT DriverObject,
OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject,
OUT OPTIONAL PUNICODE_STRING FullInstancePath OUT OPTIONAL PUNICODE_STRING FullInstancePath
); );

View file

@ -690,7 +690,7 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
RtlAppendUnicodeStringToString(&FullServiceName, &LegacyPrefix); RtlAppendUnicodeStringToString(&FullServiceName, &LegacyPrefix);
RtlAppendUnicodeStringToString(&FullServiceName, ServiceName1); RtlAppendUnicodeStringToString(&FullServiceName, ServiceName1);
Status = PnpRootCreateDevice(&FullServiceName, &PhysicalDeviceObject, &Node->InstancePath); Status = PnpRootCreateDevice(&FullServiceName, NULL, &PhysicalDeviceObject, &Node->InstancePath);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("PnpRootCreateDevice() failed with status 0x%08X\n", Status); DPRINT1("PnpRootCreateDevice() failed with status 0x%08X\n", Status);

View file

@ -202,12 +202,12 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
if (DeviceObject && *DeviceObject) if (DeviceObject && *DeviceObject)
{ {
Pdo = *DeviceObject; Pdo = *DeviceObject;
DeviceNode = IopGetDeviceNode(*DeviceObject);
} }
else else
{ {
/* Create the PDO */ /* Create the PDO */
Status = PnpRootCreateDevice(&ServiceName, Status = PnpRootCreateDevice(&ServiceName,
DriverObject,
&Pdo, &Pdo,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -215,18 +215,18 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status); DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status);
return Status; return Status;
} }
}
/* Create the device node for the new PDO */ /* Create the device node for the new PDO */
Status = IopCreateDeviceNode(IopRootDeviceNode, Status = IopCreateDeviceNode(IopRootDeviceNode,
Pdo, Pdo,
NULL, NULL,
&DeviceNode); &DeviceNode);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status); DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status);
return Status; return Status;
}
} }
/* We don't call AddDevice for devices reported this way */ /* We don't call AddDevice for devices reported this way */

View file

@ -130,6 +130,7 @@ LocateChildDevice(
NTSTATUS NTSTATUS
PnpRootCreateDevice( PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName, IN PUNICODE_STRING ServiceName,
IN OPTIONAL PDRIVER_OBJECT DriverObject,
OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject,
OUT OPTIONAL PUNICODE_STRING FullInstancePath) OUT OPTIONAL PUNICODE_STRING FullInstancePath)
{ {
@ -271,7 +272,7 @@ tryagain:
/* Initialize a device object */ /* Initialize a device object */
Status = IoCreateDevice( Status = IoCreateDevice(
PnpRootDeviceObject->DriverObject, DriverObject ? DriverObject : PnpRootDeviceObject->DriverObject,
sizeof(PNPROOT_PDO_DEVICE_EXTENSION), sizeof(PNPROOT_PDO_DEVICE_EXTENSION),
NULL, NULL,
FILE_DEVICE_CONTROLLER, FILE_DEVICE_CONTROLLER,