Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Modify the return value of IOCTL in disk.sys

194 views
Skip to first unread message

Nidhi Malik

unread,
Aug 1, 2007, 2:16:40 AM8/1/07
to
Hi,
I want my application to directly write on the disk in vista ( vista does
not alow it) . I am going to write a disk filter driver that modifies the
return value for the IOCTL for the disk . Looking at the source code of
disk.sys, i guess the modifcation should be in IOCTL_DISK_IS_WRITABLE case.
-----------------------------------------------------------------------------------
case IOCTL_DISK_IS_WRITABLE: {


status = STATUS_MEDIA_WRITE_PROTECTED;

break;
}

to

case IOCTL_DISK_IS_WRITABLE: {


status = STATUS_SUCESS;

break;
}
------------------------------------------------------------------------------
So i want to force disk.sys ( IOCTL_DISK_IS_WRITABLE ) to return
STATUS_SUCESS every time my application want to write on disk using filter
driver.
So, i need help to know that i am going in right direction or not . If i am
in right direction how can i do this modification.

Thanks a lot


Nike Chen

unread,
Aug 1, 2007, 3:14:42 AM8/1/07
to
On Aug 1, 2:16 pm, "Nidhi Malik" <nidhi.ma...@stellarinfo.com> wrote:
> Hi,
> I want my application to directly write on the disk in vista ( vista does
> not alow it) . I am going to write a disk filter driver that modifies the
> return value for the IOCTL for the disk . Looking at the source code of
> disk.sys, i guess the modifcation should be in IOCTL_DISK_IS_WRITABLE case.
> ---------------------------------------------------------------------------­--------

> case IOCTL_DISK_IS_WRITABLE: {
>
> status = STATUS_MEDIA_WRITE_PROTECTED;
>
> break;
>
> }
>
> to
>
> case IOCTL_DISK_IS_WRITABLE: {
>
> status = STATUS_SUCESS;
>
> break;}
>
> ---------------------------------------------------------------------------­---

> So i want to force disk.sys ( IOCTL_DISK_IS_WRITABLE ) to return
> STATUS_SUCESS every time my application want to write on disk using filter
> driver.
> So, i need help to know that i am going in right direction or not . If i am
> in right direction how can i do this modification.
>
> Thanks a lot

May I know why you thought Vista didn't allow you to write to the disk
directly? Could you show your code snippet regarding the writing
logic, thanks.

Maxim S. Shatskih

unread,
Aug 1, 2007, 4:42:16 AM8/1/07
to
This will not give you anything, Vista will fail the writes anyway :-)

IOCTL_DISK_IS_WRITABLE is only for FSD use, for FSD to know whether to
mount itself read-only or writable.

Vista fails the writes only to physical disk LUN device
(\\.\PhysicalDisk%d), and only if the range touched by the write is covered by
a defined partition.

Writes to volumes (\\.\D: or such) are fine in Vista, provided you are
"administrator enough" for this.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"Nidhi Malik" <nidhi...@stellarinfo.com> wrote in message
news:OQ5aCOA1...@TK2MSFTNGP03.phx.gbl...

Gary G. Little

unread,
Aug 1, 2007, 10:13:33 AM8/1/07
to
It doesn't? Since when? I work on a team that produces and supports an
application that will write to every LBA on any disk in the system, whether
ATA, SATA, SAS, SCSI, FC, or USB mass storage. It does this on Windows, DOS,
Linux or Vista using pass through with the standard OEM drivers for which
ever HBA is in the system. You do have to have the proper adminsistrative
access and priviledges, but it does work, without any pesky filters or
modifications to disk.sys. However, you do have to know what you are doing,
since arbitrarily writing to the boot disk can really ruin your day.

--
The personal opinion of
Gary G. Little


"Nidhi Malik" <nidhi...@stellarinfo.com> wrote in message
news:OQ5aCOA1...@TK2MSFTNGP03.phx.gbl...

Nidhi Malik

unread,
Aug 2, 2007, 1:52:26 AM8/2/07
to
Hi ,
Thanks for the reply
But i want to write driectly on disk for my disk wiping utility in
vc+++.WriteFile() function fails to write on sectors. Software is properly
working on all
other windows operating system accep vista. That is the reasion i want to
write i driver for vista compatibality. Same as EldoS Corporation
Driver (RawDisk) enables access to disk sectors in Windows XP/Vista. Did
you know any other way that can help me to solve my problem.

Wating for reply
Nidhi Malik


"Maxim S. Shatskih" <ma...@storagecraft.com> wrote in message
news:OGD5cfB...@TK2MSFTNGP06.phx.gbl...

David J. Craig

unread,
Aug 2, 2007, 2:09:02 AM8/2/07
to
Did you bother to read the newsgroups for information on mounted volumes and
writing directly to their sectors under Vista?

--
David J. Craig
Engineer, Sr. Staff Software Systems
Broadcom Corporation


"Nidhi Malik" <nidhi...@stellarinfo.com> wrote in message

news:ueF3VlM1...@TK2MSFTNGP02.phx.gbl...

Gary G. Little

unread,
Aug 2, 2007, 10:22:17 AM8/2/07
to
First, you won't, or typically you shouldn't, be dealing with
ReadFile\WriteFile. Though those two can munge their way, incrementally,
through a harddrive, it is by far easier to use raw READS and WRITES and
increment the LBA that is used for the associated TFR or CDB. That means you
will be using either ATA or SCSI passthrough, which means you have acquired
a handle to the physical drive. To acquire the handle to the physical drive
your application MUST be elevated to Admin, but then that restriction also
applies to XP. Be aware, you will not do this on anything less than XP SP2,
Server 2003, or Vista, since Microsoft bork'd ATA pass through in XP and XP
SP1. You will be writing to every LBA of the drive, zero to MaxLBA. If your
requirement is that this functionality MUST work from non-admin users, then
you simply write a service and provide an application interface that permits
a non-admin user to tell the service to open a handle to a disk and then
munge it's way through every LBA.

You do NOT need a filter driver You do NOT need to modify disk.sys. Disk.sys
is fragile enough without the inexperienced tramping though it.

You need to look at IOCTL_SCSI_PASS_THROUGH and IOCTL_ATA_PASS_THROUGH, and
understand what an LBA is, and how it is used in a TFR (which you have to
know) and CDB (something else you have to know). Before it is over you
should be intimate with the SetupDiXxxx API.

--
The personal opinion of
Gary G. Little

"Nidhi Malik" <nidhi...@stellarinfo.com> wrote in message
news:ueF3VlM1...@TK2MSFTNGP02.phx.gbl...

0 new messages