阅读:2881回复:12
求助:关于IoCreateFileSpecifyDeviceObjectHint
想在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 ); |
|
沙发#
发布于:2007-07-12 22:39
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.
|
|
板凳#
发布于:2007-07-12 23:03
Thanks very much!
But how to get particular attached device object of the drive? Would you please give me some advice? |
|
地板#
发布于:2007-07-13 00:15
I believe your FSFD attached to all local drives, so you should be able to know which attached device object to use.
|
|
地下室#
发布于:2007-07-13 11:17
不同的盘AttachedToDeviceObject 也是不一样的,你不能让C盘对应的设备去打开D盘上的文件
|
|
|
5楼#
发布于:2007-07-13 12:33
引用第4楼devia于2007-07-13 11:17发表的 : 谢谢! 那可以把最后一个参数改成D盘的DeviceObject吗? |
|
6楼#
发布于:2007-07-13 14:55
可以
|
|
|
7楼#
发布于:2007-07-13 15:16
那又怎样获得D盘的deviceobject呢?
再请教一下 |
|
8楼#
发布于:2007-07-16 16:14
引用第6楼devia于2007-07-13 14:55发表的 : 现在问题是:知道文件路径(盘符),怎么得到相应的DeviceObject?? 我查了查,IoGetRelatedDeviceObject, IoGetDevicePoint ,好像都不行啊, 请大侠们再教教我吧,谢谢! |
|
9楼#
发布于:2007-07-17 16:18
我试图用IoGetDeviceObjectPointer获得DeviceObject:
RtlInitUnicodeString(&TestName,L"\\Device\\HarddiskVolume2"); Status1=IoGetDeviceObjectPointer(&TestName, FILE_READ_DATA, &FileObjectTest, &DeviceObjectTest); 每次开机后第一次运行可以成功,再后来得到返回值都是STATUS_SHARING_VIOLATION 这是什么原因呢? 谢谢! |
|
10楼#
发布于:2007-07-17 22:56
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. |
|
11楼#
发布于:2007-07-20 12:51
多谢您的指导!我看了点资料,还是挺晕的
我理解的是,volume device object是在卷mount的时候由文件系统生成的,而我的设备对象附加在卷设备对象上, 那么我获得D盘的卷设备对象后,再IoGetAttachedDevice可以获得我的过滤的设备对象,可以用于IoCreateFileSpecifyDeviceObjectHint的最后一个参数。 不知道对不对,期待您的进一步指点,很感谢啊! |
|
12楼#
发布于:2007-07-23 23:46
顶一下
大侠们多指教 ![]() |
|