驱动老牛
|
阅读:1349回复:3
BUS如何创建多个PDO(高手请进100分)
设计的时候,我在虚拟的BUS驱动中只创建了一个PDO,现在想根据实际情况创建多个PDO,可以当我创建第二个PDO的时候,第一个PDO和FDO就被自动删除了,而桌面上也出现了“不安全删除设备”的对话框。如何实现创建多个PDO?
|
|
沙发#
发布于:2005-03-07 11:14
DDK中不是说一个驱动中PDO只能有一个,只有FDO才可以有多个?
|
|
驱动老牛
|
板凳#
发布于:2005-03-07 11:47
DDK中不是说一个驱动中PDO只能有一个,只有FDO才可以有多个? 总线驱动程序为总线上它所枚举的每个设备产生PDO,PDO代表一个设备,可以有多个。 DEAMON TOOL创建多个虚拟光驱,设备管理器就有多个设备 |
|
驱动老牛
|
地板#
发布于:2005-03-08 11:46
算了,自己已经解决了,可以创建多个PDO FDO
就知道在这不会找到答案的。 这就是枚举设备的过程 NTSTATUS PnpRootQueryBusRelations( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp) { PDEVICE_RELATIONS Relations; PLIST_ENTRY CurrentEntry; PPNPROOT_DEVICE Device; NTSTATUS Status; ULONG Size; ULONG i; DPRINT(\"Called\\n\"); Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) * (PnpRootDeviceListCount - 1); Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size); if (!Relations) return STATUS_INSUFFICIENT_RESOURCES; Relations->Count = PnpRootDeviceListCount; i = 0; CurrentEntry = PnpRootDeviceListHead.Flink; while (CurrentEntry != &PnpRootDeviceListHead) { Device = CONTAINING_RECORD( CurrentEntry, PNPROOT_DEVICE, ListEntry); if (!Device->Pdo) { /* Create a physical device object for the device as it does not already have one */ Status = IoCreateDevice(DeviceObject->DriverObject, 0, NULL, FILE_DEVICE_CONTROLLER, 0, FALSE, &Device->Pdo); if (!NT_SUCCESS(Status)) { DPRINT(\"IoCreateDevice() failed with status 0x%X\\n\", Status); ExFreePool(Relations); return Status; } Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; } /* Reference the physical device object. The PnP manager will dereference it again when it is no longer needed */ ObReferenceObject(Device->Pdo); Relations->Objects = Device->Pdo; i++; CurrentEntry = CurrentEntry->Flink; } Irp->IoStatus.Information = (ULONG)Relations; return Status; } |
|