Hi All,
I have written a simple volume filter driver that tries to attach to a hard coded volume
\device\Harddisk0\Partition3. This partition is non system/boot drive.I am attaching to the device in function DriverEntry.I have created following registry keys.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\voldrv Start = 0(boot time).
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{71A27CDD-812A-11D0-BEC7-08002BE2092F} UpperFilters=voldrv.
Code is written such that except create operation, all other requests are passed to lower driver.
I find that the OS does not load the driver at boot time.
Please help me solve this problem.
Code snipet from DriverEntry is like this:
VolumeDeviceObject = ExAllocatePool(NonPagedPool,sizeof(DEVICE_OBJECT));
if(VolumeDeviceObject == NULL)
{
DebugPrint((1,“ExAllocatePoolWithTag failed for VolumeDeviceObject\n”));
KeBugCheckEx(0xFFFFFFFF,0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,0xFFFFFFFF);
}
//
// Create a filter device object for this device (partition).
//
DebugPrint((2, “VolDrvAddDevice: Driver %X Device %X\n”,
DriverObject, VolumeDeviceObject));
RtlInitUnicodeString(&volumeFilter, L"\Device\VolumeFilter" );
status = IoCreateDevice(DriverObject,
DEVICE_EXTENSION_SIZE,
&volumeFilter,
FILE_DEVICE_DISK,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&filterDeviceObject);
if (!NT_SUCCESS(status)) {
DebugPrint((1, “VolDrvAddDevice: Cannot create filterDeviceObject\n”));
return status;
}
filterDeviceObject->Flags |= DO_DIRECT_IO;
deviceExtension = (PDEVICE_EXTENSION) filterDeviceObject->DeviceExtension;
RtlZeroMemory(deviceExtension, DEVICE_EXTENSION_SIZE);
RtlInitUnicodeString( &deviceName,L"\Device\Harddisk0\Partition3");
deviceExtension->fileObject = ExAllocatePool(NonPagedPool,sizeof(FILE_OBJECT));
if(deviceExtension->fileObject == NULL)
{
DebugPrint((1,“ExAllocatePoolWithTag failed for VolumeDeviceObject\n”));
KeBugCheckEx(0xFFFFFFFF,0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,0xFFFFFFFF);
}
// get pointer to target device object
status = IoGetDeviceObjectPointer( &deviceName,
FILE_READ_DATA,
&deviceExtension->fileObject,
&VolumeDeviceObject );
if( !NT_SUCCESS(status) )
{
DebugPrint((1,“IoGetDeviceObjectPointer failed with status %d\n”));
return status;
}
obj = IoAttachDeviceToDeviceStack( filterDeviceObject,
VolumeDeviceObject
);
if( obj == NULL )
{
DebugPrint((1,“IoAttachDeviceToDeviceStack failed\n”));
Thanks in advance.
Regards,
Ameet