From: unclepauly on
Doran,

Can you hold my hand just for 2 more minutes please...im sure im almost
there...i think what you are saying is what i tried to do initially, i must
be doing it wrong.

the AddDevice code in the diskperf sample is as such:

NTSTATUS DiskPerfAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT
PhysicalDeviceObject)
{
NTSTATUS status;
PDEVICE_OBJECT filterDeviceObject;

status = IoCreateDevice(DriverObject, DEVICE_EXTENSION_SIZE, NULL,
FILE_DEVICE_DISK, FILE_DEVICE_SECURE_OPEN, FALSE, &filterDeviceObject);

filterDeviceObject->Flags |= DO_DIRECT_IO;

deviceExtension = (PDEVICE_EXTENSION)
filterDeviceObject->DeviceExtension;
deviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
deviceExtension->TargetDeviceObject =
IoAttachDeviceToDeviceStack(filterDeviceObject, PhysicalDeviceObject);
deviceExtension->DeviceObject = filterDeviceObject;
deviceExtension->PhysicalDeviceName.Buffer =
deviceExtension->PhysicalDeviceNameBuffer;

filterDeviceObject->Flags |= DO_POWER_PAGABLE;
filterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

return STATUS_SUCCESS;
}


when you say i should attach the filer device object (FDO) with a unique
type, i changed the code to be:

if(isUsb)
{
status = IoCreateDevice(DriverObject, DEVICE_EXTENSION_SIZE, NULL,
FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &filterDeviceObject);
//just to make sure
filterDeviceObject->DeviceType = FILE_DEVICE_UNKNOWN;
}
else
{
status = IoCreateDevice(DriverObject, DEVICE_EXTENSION_SIZE, NULL,
FILE_DEVICE_DISK, FILE_DEVICE_SECURE_OPEN, FALSE, &filterDeviceObject);
}

so as you can see i created the device using FILE_DEVICE_UNKNOWN instead of
FILE_DEVICE_DISK. i tried tried other values too. this doesnt work though.
what have i misunderstood ?

thanks again for your help, sorry if my knowledge is very poor on this matter.
From: unclepauly on
i see - so looking at my code above can you tell me where i have gone wrong ?
ie, i detect usb and then create the filterDeviceObject via IoCreateDevice,
by passing in FILE_DEVICE_UNKNOWN instead of FILE_DEVICE_DISK.

thanks for your help.