Is there an API to format the HD?

  • Thread starter Thread starter ZhangZQ
  • Start date Start date
Z

ZhangZQ

Is there an API to format the HD? I found to use the DeviceIoControl with
IOCTL_DISK_FORMAT_TRACKS code can format the floppy, but how to format the
HD, I don't want the SHFormatDrvie way.


Thank you very much!
 
ZhangZQ said:
Is there an API to format the HD? I found to use the DeviceIoControl with
IOCTL_DISK_FORMAT_TRACKS code can format the floppy, but how to format the
HD, I don't want the SHFormatDrvie way.


Thank you very much!

As a courtesy to the helpful members of this newsgroup, could you kindly
indicate how we can recognize the virus you're making?
 
ZhangZQ said:
Is there an API to format the HD? I found to use the DeviceIoControl with
IOCTL_DISK_FORMAT_TRACKS code can format the floppy, but how to format the
HD, I don't want the SHFormatDrvie way.

There's a section on Physical Disks and Volumes in the Platform SDK
documentation for CreateFile() but you probably saw that as a method of
getting a handle for DeviceIoControl. I do believe you can just write to
the media direct with WriteFile() but I've never tried it other than for
floppy disks (Google appears to confirm it).

Most of the modern file systems I know of only lay down their
super-structure when formatting. This makes formats very quick but many
do a disk scan or even clear every sector with a pattern, adding a huge
amount of time. I once did something like this for floppy disks by
simply laying down the initialisation state programmatically (i.e. a
MBR, BPB, FAT, Root Dir). If you know the file system media format you
can probably just lay down a default, empty one but I don't know how to
make a file system driver do a format on its own (would save you from
having to know the media format). You could write a pattern of your
devising to do a basic clearing of data but that won't do a forensic
safe cleanup - I believe the US DoD specifies a set of per-sector write
patterns they believe shreds the data to a forensic (or at least DoD
approved) state.
 
ZhangZQ said:
Thanks for your answer. Actually, I can create a specified filesystem by
direct-access the HD, but that newly partition can't be mounted and assigned
a driver letter until the Windows restart, I want to find a way to let the
OS to mount my newly created partition without reboot.

Reboot? Er, this is Windows...right? Have you looked at the services
for volume management. They associate volumes with mount points. Perhaps
you can coerce the OS into accepting the changes to the media and
activate the volumes you create. I don't know if they help or if you've
looked at them but, if not, they may contain the answer.
 
Thanks for your answer. Actually, I can create a specified filesystem by
direct-access the HD, but that newly partition can't be mounted and assigned
a driver letter until the Windows restart, I want to find a way to let the
OS to mount my newly created partition without reboot.


Regards,
ZhangZQ
 
Check Abdoul,

This information is very useful, but I still have some question.

1. I create a new raw partition by directly add a record in HD partition
table, after this partition was created, how to let the OS know there is a
new partition was created without reboot the OS.
2. I wonder about how to use the Windows MOUNT-POINT API to mount a raw
partition that without filesystem in it and assigns it a driver letter or
volume lable, those are the necessary parameters to pass to FormatEx
function.

Thank you very much!


Regards,
ZhangZQ


CheckAbdoul said:
Take a look at the following link

http://www.sysinternals.com/ntw2k/source/fmifs.shtml

--
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

ZhangZQ said:
Is there an API to format the HD? I found to use the DeviceIoControl with
IOCTL_DISK_FORMAT_TRACKS code can format the floppy, but how to format the
HD, I don't want the SHFormatDrvie way.


Thank you very much!
 
Back
Top