Hello,
I have a controller which has one logical drive
configured to it.
I am creating a filter driver which attaches itself as
Lower filter driver to the Disk.
I am struck with creating a PDO for the logical disk.
I am thinking of making another PDO(virtual) in
addition to the 1 PDO made by the system.
I am creating the virtualPDO when I get the
IRP_MN_START_DEVICE for FiDO.
/////////Code
swprintf(wName, L"\Device\VirtualRAIDDisk%d",
deviceCnt);
++deviceCnt;
RtlInitUnicodeString(&UniDeviceName, wName);
status =
IoCreateDevice(deviceExtension->DeviceObject->DriverObject,
sizeof(DISK_DEVICE_EXTENSION), &UniDeviceName,
FILE_DEVICE_DISK, FILE_DEVICE_SECURE_OPEN,
FALSE,
&VirtualLogicalDisk);
if(!NT_SUCCESS(status))
{
DbgPrint(“\nAddDevice: Cannot create pdo\n”);
return status;
}
SET_FLAG(VirtualLogicalDisk->Flags, DO_DIRECT_IO);
virtualDeviceExtension =
VirtualLogicalDisk->DeviceExtension;
IoInitializeRemoveLock(&virtualDeviceExtension->RemoveLock,
REMLOCK_TAG, REMLOCK_MAXIMUM, REMLOCK_HIGHWATER);
virtualDeviceExtension->DeviceType =
TEAM_PDO_DEVICE_TYPE;
virtualDeviceExtension->IsVirtualDeviceObject = TRUE;
virtualDeviceExtension->DeviceObject =
VirtualLogicalDisk;
virtualDeviceExtension->TargetDeviceObject =
deviceExtension->TargetDeviceObject;
deviceExtension->VirtualDeviceObject =
VirtualLogicalDisk;
VirtualLogicalDisk->StackSize =
DeviceObject->StackSize;
VirtualLogicalDisk->AlignmentRequirement =
FILE_WORD_ALIGNMENT;
IoInvalidateDeviceRelations(deviceExtension->PhysicalDeviceObject,
BusRelations);
CLEAR_FLAG(VirtualLogicalDisk->Flags,
DO_DEVICE_INITIALIZING);
//////////////////////
and when I get the IRP_MN_DEVICE_RELATIONS
for the bus relations, I fill the following fields:
//////////////Code
if(type == BusRelations)
{
status = STATUS_INSUFFICIENT_RESOURCES;
relationsSize = (sizeof(DEVICE_RELATIONS) +
sizeof(PDEVICE_OBJECT));
DeviceRelations =
ExAllocatePool(PagedPool,relationsSize);
if(DeviceRelations != NULL)
{
RtlZeroMemory(DeviceRelations,relationsSize);
if(deviceExtension->VirtualDeviceObject)
{ DeviceRelations->Count = 1;
DeviceRelations->Objects[0] =
deviceExtension->VirtualDeviceObject;
ObReferenceObject(DeviceRelations->Objects[0]);
}
else
{
DeviceRelations->Count = 0;
}
Irp->IoStatus.Information =
(ULONG_PTR)DeviceRelations;
status = STATUS_SUCCESS;
}
Irp->IoStatus.Status = status;
IoReleaseRemoveLock(&deviceExtension->RemoveLock,
Irp);
IoCompleteRequest(Irp,IO_NO_INCREMENT);
break;
}
///////////////
Now I get the IRP_MN_START_DEVICE for the virtual
DeviceObject.
But whenever I try to call IoRegisterDeviceInterface()
for this virtual PDO, it fails.
////////Code
case IRP_MN_START_DEVICE:
{
UNICODE_STRING interfaceName;
status = IoRegisterDeviceInterface(pdo,
(LPGUID)&PartitionClassGuid,
NULL,
&interfaceName);
if(NT_SUCCESS(status))
{
DbgPrint(“Interface assigned\n”);
deviceExtension->DiskInterfaceString = interfaceName;
status = IoSetDeviceInterfaceState(&interfaceName,
TRUE);
}
else
{
interfaceName.Buffer = NULL;
}
irpCompleted = FALSE;
break;
}
Thanks for the patience and help.
Thanks and Regards,
Gurpreet
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com