求助:关于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的最后一个参数。
不知道对不对,期待您的进一步指点,很感谢啊! /////////////////////
如果打开同盘的文件可以实现(返回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的最后一个参数。
不知道对不对,期待您的进一步指点,很感谢啊! /////////////////////
相关文章推荐
- Linux出现cannot create temp file for here-document: No space left on device的问题解决
- 关于EXT用json返回结果分页的问题
- 关于sar的一个问题: Invalid system activity file
- 关于Android file.createNewFile() 方法出现的问题总结
- 关于ServletFileUpload中parseRequest(request)返回的list<FileItem>为空的问题
- 【Hibernate】关于hibernate中使用createSQLQuery后返回的结果处理
- 关于ACE.DLL : fatal error LNK1136: invalid or corrupt file问题的解决
- 关于ios8不能定位问题 - 总是返回kCLAuthorizationStatusNotDetermined
- 关于Create NSManagedobjectModel SubClass 文件编译出现Duplicate Symbol 重复引用的问题
- 关于c#代码Convert.ToChar(null);出现异常,而object obj = null; Convert.ToChar(obj);//返回'\0'空字符问题详解
- win7下使用共享内存方式CreateFileMapping返回GetLastError总是0x5的问题解决
- 解决Invalid 'log4jConfigLocation' parameter: Log4j config file[F:/*路径*/]not found问题
- 关于Android file.createNewFile() 方法出现的问题总结
- mybatis关于一对一映射返回结果与数据库查出的不符问题
- 关于运行系统服务时出现 System.IO.FileLoadException的问题
- java.io.File的基本使用以及关于Windows中大小写问题
- 关于JAVA中的MVC结果,Controller方法返回字符串到前端js出现乱码问题
- 关于Android的This text field does not specify an inputType or a hint 问题
- 关于STM32头文件包含出现No such file or directory和 invalid redeclaration of type name...的问题
- 关于Genymotion出现“An error occured while deploying the file.INSTALL_FAILED_INVALID_URI”问题的原因分析