博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Problem in locking and unlocking volumes

Posted on 2006-06-24 10:39  晓平  阅读(280)  评论(0)    收藏  举报
hi,
I am looking for getting volumes locked in the kernal
mode for my application. I am trying to use the
FSCTL_LOCK_VOLUME and FSCTL_DISMOUNT_VOLUME
respectively using the ZwFsControlFile() API. Locking
operation works but the dismount miserably fails with
and error saying "handle invalid".
Also unlocking the volume resulted in error "volume
dismounted" error.
Please provide some pointer to correct me if i am
doing something wrong.

Thanks in advance,
Amol.

Re:  Problem in locking and unlocking volumes

Unless you open a handle with the OBJ_KERNEL_HANDLE set in
OBJECT_ATTRIBUTES.Attributes, the handle is only valid in the context
the process that was running when you called ZwCreateFile.  You should
probably specify OBJ_KERNEL_HANDLE, or guarantee that your code is
running in the same process as was running when you called ZwCreateFile.
The first solution is usually the easiest and best.

-- arlie