From: Kyle on
"Kyle" <me(a)privacy.net> wrote in message
news:ApqdnY9oR7YyRt3YnZ2dnUVZ_u6dnZ2d(a)comcast.com...
| "B-Mann" <johnbattaglio(a)gmail.com> wrote in message
| news:1161860584.379328.274480(a)i3g2000cwc.googlegroups.com...
| | Kyle wrote:
| | >
| | > To mimic a product like Ghost, you'll need to perform HD sector
| access
| | > as well as writing some very sophisticated code to
rewrite/resize
| the
| | > FAT or NTFS volume tables (I know little about NTFS volume
| | > design/structures, but certainly, NTFS is much more complex than
| | > FAT32). Ghost includes the ability to create a backup image and
| | > restore it to a target partition that is larger than the
original
| | > source partition, then Ghost will resize the FAT or NTFS file
data
| | > structures so that they correspond to the target partition size.
| | >
| | > IOW, you decide to image a 10 gig partition with Ghost, then
| decide to
| | > restore the image to a 20 gig partition, and Ghost will
recognize
| it
| | > needs to (and actually does) rewrite the FAT or NTFS file
| structures
| | > to correspond with the size of the target partition. Why is
this
| | > important? Well, if the FAT/volume structures are not resized
to
| | > "fit" the target partition when the target is larger than the
| source
| | > partition, then the OS will be unable to utilize the entire
| available
| | > disk space of the 20 gig drive since it now has a FAT or volume
| | > structure originally sized for a 10 gig partition. Ghost is
| | > essentially a sector copying program of significant
| sophistication, as
| | > it also includes file assembly capability (analyzing the FAT or
| NTFS
| | > volume structure to assemble individual files for recovery
| purposes)
| | > in addition to the aforementioned capability regarding resizing
| sector
| | > usage tables/structures. I suppose with some "helper" drivers
(a
| | > driver that enables direct sector read/write access) one might
| write a
| | > ghost-like program in VB6, but why? Purchasing a copy of Ghost
is
| a
| | > lot less headache.
| | >
| | > Hope I have not stifled your enthusiasm, it is perhaps a doable
| feat,
| | > but you will become a master of FAT and NTFS data structures
| before
| | > you are done. Reading and writing sectors will be the easy part
| of
| | > the challenge.
| | > --
| | > Best regards,
| | > Kyle
| |
| | Kyle,
| |
| | Yes I realize all the points you make, and understand these
| challanges.
| | I already have the ability to perform the sector copy process. I
| have
| | written this part and can create image files as well as volume to
| | volume imaging directly. Currently, I am only looking to perform
| same
| | size disk imaging, as the project expands, I will look at the
| resizing
| | of the drives as well. From what I am reading from the Disk
| Management
| | pages on MSDN, the DeviceIoControl should allow me to access the
| drive
| | at the disk level instead of a per volume level. This is all I am
| | attempting to accomplish at this point. If I am not able to
perform
| the
| | creation of the disk, I may as well stop at attempting anything
| | further. I can use the DeviceIoControl in combination with
| | IOCTL_DISK_DELETE_DRIVE_LAYOUT to delete all partitions on the
| drive,
| | so I know I have access at that level. When I attempt to create
the
| | disk using the code I provided prior, I get no error, but the
drive
| is
| | not created.
| | As for purchasing the Ghost product, that would be fine if I was
| only
| | wanting to make a single copy or image of a drive. But I have a
much
| | larger project in mind and the licensing of such a commercial
| product
| | would not be feasible.
| |
| | Again, any assistant would be helpful.
| | Thanks,
| |
|
|
| Perhaps there is a sequence of API calls required to "mount" the
drive
| for use by the system. It could be the create disk process in your
| code is working fine, but the drive is not accessible b/c it is not
| "mounted".
| --
| Best regards,
| Kyle
|

E.g.,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/setvolumemountpoint.asp

SetVolumeMountPoint is required to mount a new volume on a HD, and a
registry entry/GUI entry is created for persistent access to the
device. Or, maybe DefineDosDevice can be used to temporarily access
the HD without creating the GUI registry entries, am unceratin on
this.

Looks like this page will be of assistance to you with volume
manipulation API calls:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/volume_management_functions.asp

--
Best regards,
Kyle

From: B-Mann on
Kyle,

Thanks for your responses. I have looked at those links, and have
made some headway.

All,

I am currently able to create a disk from a RAW drive using the
following:

================================================
Dim cd As CREATE_DISK
Dim newdli As DRIVE_LAYOUT_INFORMATION

With cd
.PartitionStyle = PARTITION_STYLE_MBR
.PartitionMBRType.Signature = PARTITION_FAT32
.PartitionGPTType.DiskId.Data1 = 0
.PartitionGPTType.DiskId.Data2 = 0
.PartitionGPTType.DiskId.Data3 = 0
For j = 0 To 7
.PartitionGPTType.DiskId.Data4(j) = 0
Next j
.PartitionGPTType.MaxPartitionCount =
UBound(newdli.PartitionEntry)
End With

Call DiskCreateDisk(hdevice, cd)
Call DiskUpdateProperties(hdevice)

Sub DiskCreateDisk(hdevice As Long, cd As CREATE_DISK)
Dim retval As Long
Dim bytesreturned As Long

retval = DeviceIoControl(hdevice, _
IOCTL_DISK_CREATE_DISK, _
cd, _
Len(cd), _
ByVal 0&, _
0&, _
bytesreturned, _
ByVal 0&)

' At this point the entire disk is unallocated.
End Sub

Sub DiskUpdateProperties(hdevice As Long)
Dim retval As Long
Dim bytesreturned As Long

retval = DeviceIoControl(hdevice, _
IOCTL_DISK_UPDATE_PROPERTIES, _
ByVal 0&, _
0&, _
ByVal 0&, _
0&, _
bytesreturned, _
ByVal 0&)

End Sub

================================================
My next hurdle is to create the partition(s) on the drive.
The following code creates a single partition which is the entire
size of the disk no matter what I make the PartitionLength:

Public Const IOCTL_DISK_SET_DRIVE_LAYOUT = &H7C010

newdli.PartitionCount = UBound(newdli.PartitionEntry) - 1
newdli.Signature = 0
With newdli.PartitionEntry(0)
.BootIndicator = False
.HiddenSectors = 63
.PartitionLength.liLow = 1073447424
.PartitionLength.liHigh = 0
.PartitionNumber = 1
.PartitionType = 7
.RecognizedPartition = True
.RewritePartition = True
.StartingOffset.liLow = 32256
.StartingOffset.liHigh = 0
End With

For k = 2 To newdli.PartitionCount
With newdli.PartitionEntry(k)
.BootIndicator = False
.HiddenSectors = 0
.PartitionLength.liLow = 0
.PartitionLength.liHigh = 0
.PartitionNumber = k
.PartitionType = PARTITION_ENTRY_UNUSED
.RecognizedPartition = False
.RewritePartition = True
.StartingOffset.liLow = 0
.StartingOffset.liHigh = 0
End With
Next k

Call SetDriveLayout(hdevice, newdli)
Call DiskUpdateProperties(hdevice)

Sub SetDriveLayout(hdevice As Long, dli As DRIVE_LAYOUT_INFORMATION)
Dim retval As Long
Dim bytesreturned As Long

retval = DeviceIoControl(hdevice, _
IOCTL_DISK_SET_DRIVE_LAYOUT, _
dli, _
Len(dli), _
ByVal 0&, _
0&, _
bytesreturned, _
ByVal 0&)

End Sub

The values that I am using to create the first partition was returned
from
a call to DeviceIoControl using IOCTL_DISK_GET_PARTITION_INFO
against the same disk prior to deleting the disk. The partition should
be a 1GB
partition, and the remaining area of the disk should be unallocated.

Thanks for any assistance,

B-Mann

First  |  Prev  | 
Pages: 1 2
Prev: Saving picture in VB6
Next: ShellExecuteEx example