Let me just preface what follows by saying that file systems are not
really my thing, but as it is late and you ight not get another response
this evening, I think I can give you a few places to start. My other
comment is that, I believe, the list of IOCTLS that ZwFsControlFile is
documented as servicing does not contain either FSCTL_LOCK_VOLUME or
FSCTL_UNLOCK_VOLUME. In any case, the first thing to note is that I
believe that ZwFsControlFile(FSCTL_LOCK_VOLUME) will fail if there any
open handles to anything on the volume, which is quite likely. I would
start by downloading Handle from sysinternals/microsoft
(http://www.microsoft.com/technet/sysinternals/utilities/handle.mspx)
and see what running it (without arguments) gives you in the value of
anything on your N: drive. If this is not the issue, the only other
thing that I can suggest is to give FSCTL_LOCK_VOLUME a try via
DeviceIoControl, as it is documented. I just don’t know enough about FS
to be of much help.
mm
>> xxxxx@gmail.com 2007-05-23 20:48 >>>
Yes you are right. Something weird happened there, sorry about that.
Basically what I tried to do is get a handle to a partition ( drive N
in my
case ) and try to lock it and unlock it. But I get this error when
sending
the FSCTL. c0000010: STATUS_INVALID_DEVICE_REQUEST. THere’s no error
return
from the ZwOpenFIle though, so I assume I managed to get a handle.
// code follows…
PAGED_CODE();
RtlInitUnicodeString(&VolumeName, L"\DosDevices\N:");
//KdPrint((FUNCTION_NAME “Full Volume Path: %s\n”,
VolumeName.Buffer));
InitializeObjectAttributes(&oa,
&VolumeName,
OBJ_CASE_INSENSITIVE| OBJ_KERNEL_HANDLE,
NULL, NULL);
status = ZwOpenFile(&fileHandle,
SYNCHRONIZE,
&oa,
&ioStatusBlock,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT);
if(!NT_SUCCESS(status)) {
KdPrint((FUNCTION_NAME “Could not open volume\n”));
return STATUS_UNSUCCESSFUL;
}
status = ZwFsControlFile(fileHandle, NULL, NULL, NULL,
&ioStatusBlock,
FSCTL_LOCK_VOLUME,
NULL,0, NULL,0);
if(!NT_SUCCESS(status))
{
KdPrint((FUNCTION_NAME “Could not lock volume - status: %x\n”,
status));
return STATUS_UNSUCCESSFUL;
}
status = ZwFsControlFile(fileHandle, NULL, NULL, NULL,
&ioStatusBlock,
FSCTL_UNLOCK_VOLUME,
NULL,0, NULL,0);
if(!NT_SUCCESS(status))
{
KdPrint((FUNCTION_NAME “Could not unlock volume - status: %x\n”,
status));
return STATUS_UNSUCCESSFUL;
}
On 5/24/07, Martin O’Brien wrote:
>
> I’m wondering if your e-mail program did a number of your post,
because
> what you have (‘RtlInitUnicodeString(&VolumeName, L"\DosDevices\N>
> <file:>,’ among other things) make absolutely no
sense
> whatsoever, and there seems to be confusion as to what Maxim meant.
> That is, “\DosDevices\N>file://’ is in no way, shape or form a
> properly formed path as far as the kernel is concerned.
>
> mm
>
>
> >>> xxxxx@gmail.com 2007-05-23 12:05 >>>
> I don’t get it. Could you elaborate? Thanks!
>
> On 5/22/07, Maxim S. Shatskih wrote:
> >
> > The file:// element is not used in kernel paths.
> >
> > –
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> > “kelvin lim” wrote in message
> news:xxxxx@ntfsd…
> > > Hi all,
> > >
> > > I’m trying to lock and unlock a volume from my driver. I keep
> getting
> > error
> > > code c0000010: STATUS_INVALID_DEVICE_REQUEST
> > >
> > > In my driver I have this code:
> > >
> > > PAGED_CODE();
> > >
> > > RtlInitUnicodeString(&VolumeName, L”\DosDevices\N
> > <file:>
> > > :“);
> > > //RtlInitUnicodeString(&VolumeName, L”\??\N
<file:>:“);
> > > //RtlUnicodeStringPrintf(&VolumeName,
> > > L”\DosDevices\%c<file:>:",
> > > DriveLetter);
> > >
> > > //KdPrint((FUNCTION_NAME “Full Volume Path: %s\n”,
> VolumeName.Buffer));
> > >
> > > InitializeObjectAttributes(&oa,
> > > &VolumeName,
> > > OBJ_CASE_INSENSITIVE| OBJ_KERNEL_HANDLE,
> > > NULL, NULL);
> > >
> > > status = ZwOpenFile(&fileHandle,
> > > SYNCHRONIZE,
> > > &oa,
> > > &ioStatusBlock,
> > > FILE_SHARE_READ|FILE_SHARE_WRITE,
> > > FILE_SYNCHRONOUS_IO_NONALERT);
> > >
> > > if(!NT_SUCCESS(status)) {
> > > KdPrint((FUNCTION_NAME “Could not open volume\n”));
> > > return STATUS_UNSUCCESSFUL;
> > > }
> > >
> > > status = ZwFsControlFile(fileHandle, NULL, NULL, NULL,
> > > &ioStatusBlock,
> > > FSCTL_LOCK_VOLUME,
> > > NULL,0, NULL,0);
> > > if(!NT_SUCCESS(status)) {
> > > KdPrint((FUNCTION_NAME “Could not lock volume - status: %x\n”,
> > status));
> > > return STATUS_UNSUCCESSFUL;
> > > }
> > >
> > > status = ZwFsControlFile(fileHandle, NULL, NULL, NULL,
> > > &ioStatusBlock,
> > > FSCTL_UNLOCK_VOLUME,
> > > NULL,0, NULL,0);
> > > if(!NT_SUCCESS(status)) {
> > > KdPrint((FUNCTION_NAME “Could not unlock volume - status:
%x\n”,
> > status));
> > > return STATUS_UNSUCCESSFUL;
> > > }
> > >
> > >
> > >
> > > Thanks,
> > >
> > > Kelvin
> > >
> >
> > —
> > Questions? First check the IFS FAQ at
> > https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@gmail.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@evitechnology.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@evitechnology.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</file:></file:></file:></file:>