Direct disk access under NT/2000

Hi all,

Greetings.

I’m writing a program that performs a directory sorting
function, but I’m having problems
locking a volume for reading/writing under winNT/2K.

I can make it work under win95/98 by manipulating
\.\vwin32.vxd and it seems that the
3 level of locks all work with or without open files on the
volume being locked. However in
winNT/2K if there are open files, locking fails. I wonder how
some programs like the disk
Defragmenter does with direct disk access with open files. Is
there a way to tweak the arguments
to DeviceIOControl function a little bit to make it work? (It
seems winNT/2K provides only
one level of locking?) Or is there another way to do direct disk
access without using lock??

Here is the main part of my program:

// open volume, OK
m_hDeviceIO = CreateFile (szVolumeName, dwAccessFlags,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
NULL);
// lock volume, fails
DeviceIoControl (m_hDeviceIO, FSCTL_LOCK_VOLUME, NULL, 0, NULL,
0, &dwBytesReturned, NULL);

Any answers/comments are welcome. Thanx!

Darrel


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> winNT/2K if there are open files, locking fails. I wonder how

some programs like the disk
Defragmenter does with direct disk access with open files. Is

The NT’s defragmenters do not do direct disk access.
The FSD exports an IOCTL interface for them like:

  • move the file to other clusters
  • get the cluster numbers occupied by the file
  • get the free cluster numbers.
    So, all low-level work is done by the FSD - and the defragmenter makes the
    policy decisions on how to defragment.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Following work under NT/2000 if u have Administrator Privilage

CreateFile ( \.\physicaldrive0 , …)

Set position to 0 using SetFilePointer and Read sector u will get MBR of HDD

ReadFile ( … )

Set position to 0 using SetFilePointer and Write buffer to sector to
overwrite MBR

WriteFile ( …)

Satish K.S
Software Consultant

Aalayance e-Com Services Private Limited
26/1, 24th Main, 5th Phase,
J.C Road, Bangalore
TeleFax: +91 - 080 - 2995692

Mail me at: xxxxx@aalayance.com

----- Original Message -----
From: “Dazhi Liu”
To: “NT Developers Interest List”
Sent: Friday, December 22, 2000 2:11 AM
Subject: [ntdev] Direct disk access under NT/2000

> Hi all,
>
> Greetings.
>
> I’m writing a program that performs a directory sorting
> function, but I’m having problems
> locking a volume for reading/writing under winNT/2K.
>
> I can make it work under win95/98 by manipulating
> \.\vwin32.vxd and it seems that the
> 3 level of locks all work with or without open files on the
> volume being locked. However in
> winNT/2K if there are open files, locking fails. I wonder how
> some programs like the disk
> Defragmenter does with direct disk access with open files. Is
> there a way to tweak the arguments
> to DeviceIOControl function a little bit to make it work? (It
> seems winNT/2K provides only
> one level of locking?) Or is there another way to do direct disk
> access without using lock??
>
> Here is the main part of my program:
>
> // open volume, OK
> m_hDeviceIO = CreateFile (szVolumeName, dwAccessFlags,
> FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
> NULL);
> // lock volume, fails
> DeviceIoControl (m_hDeviceIO, FSCTL_LOCK_VOLUME, NULL, 0, NULL,
> 0, &dwBytesReturned, NULL);
>
> Any answers/comments are welcome. Thanx!
>
> Darrel
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@aalayance.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi!

I think the problem could be that you have not set the security attributes. You might not have the permission to do the task with the default security attributes

Nisha


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)

To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com