Dear Members,
We are writing a simple driver for windows systems. For this driver we create a virtual disk in My Computer like X: When read/write and device control requests arrive we forward these requests to a physical disk partition file system driver for example to file system driver for D: The problem is this that when we restart the system there runs file system check on the physical disk partition that was our target e.g. on D: What can be the problem for the file system check?
We are using the following code for getting the device object of the target parition.
//pdo is like this \??\D:
InitializeObjectAttributes(&oa, pdo, 0 , NULL, NULL);
status = ZwOpenFile(&myHandle,
FILE_READ_DATA|SYNCHRONIZE|FILE_READ_ATTRIBUTES|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES,
&oa,
&statusBlock,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_NON_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT);
if(status == STATUS_SUCCESS){
status = ObReferenceObjectByHandle(myHandle,
0,
*IoFileObjectType /*NULL*/,
KernelMode,
&fileObj,
NULL);
ZwClose(myHandle);
if( status == STATUS_SUCCESS ){
PDevExt->StorageDeviceObject = IoGetRelatedDeviceObject(fileObj);
targetDisk->StorageDeviceObject = IoGetRelatedDeviceObject(fileObj);
targetDisk->file_obj = fileObj;
}
}
The device object returned from IoGetRelatedDevoceObject is used for forwarding read/write and device control requests to the target.
According to MSDN documentation the access rights FILE_READ_DATA|SYNCHRONIZE|FILE_READ_ATTRIBUTES|FILE_WRITE_DATA|
FILE_WRITE_ATTRIBUTES will mount the file system driver of the target parition then why the file system check runs? Some times the file system check runs without finding errors and some times finds Index related issues. The file system of the target is currently NTFS. Previously we were getting many security descriptor related errors in file system check.
Please note that the driver is a function driver. Can this be a problem?
Do I need to make a filter driver for resolving the file system issue or the current function driver is OK?
Additionally when I try to dereference the file object in my shutdown routine I am getting REFERENCE_BY_POINTER BSD.
Your feedback will be helpful.
Thanks,
Uzair Lakhani