您的位置:首页 > 移动开发 > Objective-C

求助:关于IoCreateFileSpecifyDeviceObjectHint返回结果是STATUS_INVALID_DEVICE_OBJECT_PARAMETER的问题

2011-07-25 12:45 477 查看
链接:http://bbs2.driverdevelop.com/read.php?tid=103564想在sfcreate中用IoCreateFileSpecifyDeviceObjectHint打开一个文件来判断文件是否存在,
如果打开同盘的文件可以实现(返回STATUS_OBJECT_NAME_NOT_FOUND
或者STATUS_SUCCESS)
但如果打开不同盘的文件则总是返回STATUS_INVALID_DEVICE_OBJECT_PARAMETER??
请教下这是为什么??
谢谢!
Status1=IoCreateFileSpecifyDeviceObjectHint(
&FileHandle,
FILE_READ_ATTRIBUTES,
&ObjectAttributes,
&IoStatus1,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE,
NULL,
0,
CreateFileTypeNone,
NULL,
IO_IGNORE_SHARE_ACCESS_CHECK,
devExt->NLExtHeader.AttachedToDeviceObject
); //////////////////////////////////////////////////////The returned status clearly tells the error that the device object you passed to the function is not correct. Since you are trying to access a file on another drive, you need to find a way to get particular attached device object of that drive, not the device object in current MJ_CREATE. ///////////////////////////////////////////////////Thanks very much!
But how to get particular attached device object of the drive?
Would you please give me some advice? ////////////////////////////////////////////////////I believe your FSFD attached to all local drives, so you should be able to know which attached device object to use. ///////////////////////////////////不同的盘AttachedToDeviceObject 也是不一样的,你不能让C盘对应的设备去打开D盘上的文件 /////////////////////////////引用 引用第4楼devia于2007-07-13 11:17发表的 :
不同的盘AttachedToDeviceObject 也是不一样的,你不能让C盘对应的设备去打开D盘上的文件

谢谢!
那可以把最后一个参数改成D盘的DeviceObject吗? ////////////////////////////////////可以 ///////////////////////////////那又怎样获得D盘的deviceobject呢?
再请教一下 引用 引用第6楼devia于2007-07-13 14:55发表的 :
可以
````
现在问题是:知道文件路径(盘符),怎么得到相应的DeviceObject??
我查了查,IoGetRelatedDeviceObject, IoGetDevicePoint ,好像都不行啊,
请大侠们再教教我吧,谢谢! ```````我试图用IoGetDeviceObjectPointer获得DeviceObject:
RtlInitUnicodeString(&TestName,L"\\Device\\HarddiskVolume2");
Status1=IoGetDeviceObjectPointer(&TestName,
FILE_READ_DATA,
&FileObjectTest,
&DeviceObjectTest);

每次开机后第一次运行可以成功,再后来得到返回值都是STATUS_SHARING_VIOLATION
这是什么原因呢?
谢谢! ///////////////////////////// Try FILE_READ_ATTRIBUTES instead.

But wait, the device object you got this way is volume device object, not file system device object! IoGetBaseFileSystemDeviceObject() and IoGetAttachedDevice() may need to be called after that. As I remember either SFilter or FileSpy can show you how to do it.

Suggest you read the some books, such as "Windows NT Device Driver Development", to be familiar with storage and file system stacks. ///////////////////////////////多谢您的指导!我看了点资料,还是挺晕的
我理解的是,volume device object是在卷mount的时候由文件系统生成的,而我的设备对象附加在卷设备对象上,
那么我获得D盘的卷设备对象后,再IoGetAttachedDevice可以获得我的过滤的设备对象,可以用于IoCreateFileSpecifyDeviceObjectHint的最后一个参数。
不知道对不对,期待您的进一步指点,很感谢啊! /////////////////////
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐