public DeviceElementValue(Guid parentObject, PhysicalVolumeInfo pvi)
        {
            _parentObject = parentObject;

            PartitionRecord record = new PartitionRecord();
            record.Type = 6;
            if (pvi.VolumeType == PhysicalVolumeType.BiosPartition)
            {
                record.PartitionType = 1;
                record.DiskIdentity = new byte[4];
                Utilities.WriteBytesLittleEndian(pvi.DiskSignature, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[8];
                Utilities.WriteBytesLittleEndian(pvi.PhysicalStartSector * 512, record.PartitionIdentity, 0);
            }
            else if (pvi.VolumeType == PhysicalVolumeType.GptPartition)
            {
                record.PartitionType = 0;
                record.DiskIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.DiskIdentity, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.PartitionIdentity, record.PartitionIdentity, 0);
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "Unknown how to convert volume type {0} to a Device element", pvi.VolumeType));
            }

            _record = record;
        }
Example #2
0
        /// <summary>
        /// Formats the specified volume.
        /// </summary>
        /// <param name="volume">The volume.</param>
        /// <param name="options">The options.</param>
        /// <param name="label">The label.</param>
        /// <returns></returns>
        public static ExFatFileSystem Format(PhysicalVolumeInfo volume, ExFatFormatOptions options = null, string label = null)
        {
            var partitionStream = volume.Open();

            using (ExFatPathFilesystem.Format(partitionStream, options, label)) { }
            return(new ExFatFileSystem(partitionStream));
        }
        public DeviceElementValue(Guid parentObject, PhysicalVolumeInfo pvi)
        {
            _parentObject = parentObject;

            PartitionRecord record = new PartitionRecord();
            record.Type = 6;
            if (pvi.VolumeType == PhysicalVolumeType.BiosPartition)
            {
                record.PartitionType = 1;
                record.DiskIdentity = new byte[4];
                Utilities.WriteBytesLittleEndian(pvi.DiskSignature, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[8];
                Utilities.WriteBytesLittleEndian(pvi.PhysicalStartSector * 512, record.PartitionIdentity, 0);
            }
            else if (pvi.VolumeType == PhysicalVolumeType.GptPartition)
            {
                record.PartitionType = 0;
                record.DiskIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.DiskIdentity, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.PartitionIdentity, record.PartitionIdentity, 0);
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "Unknown how to convert volume type {0} to a Device element", pvi.VolumeType));
            }

            _record = record;
        }
Example #4
0
        /// <summary>
        /// Determines if a physical volume contains LDM data.
        /// </summary>
        /// <param name="volumeInfo">The volume to inspect</param>
        /// <returns><c>true</c> if the physical volume contains LDM data, else <c>false</c>.</returns>
        public static bool HandlesPhysicalVolume(PhysicalVolumeInfo volumeInfo)
        {
            PartitionInfo pi = volumeInfo.Partition;
            if (pi != null)
            {
                return IsLdmPartition(pi);
            }

            return false;
        }
        /// <summary>
        /// Determines if a physical volume contains LDM data.
        /// </summary>
        /// <param name="volumeInfo">The volume to inspect</param>
        /// <returns><c>true</c> if the physical volume contains LDM data, else <c>false</c>.</returns>
        public static bool HandlesPhysicalVolume(PhysicalVolumeInfo volumeInfo)
        {
            PartitionInfo pi = volumeInfo.Partition;

            if (pi != null)
            {
                return(IsLdmPartition(pi));
            }
            return(false);
        }
Example #6
0
        /// <summary>
        /// Determines if a physical volume contains LVM data.
        /// </summary>
        /// <param name="volumeInfo">The volume to inspect.</param>
        /// <returns><c>true</c> if the physical volume contains LVM data, else <c>false</c>.</returns>
        public static bool HandlesPhysicalVolume(PhysicalVolumeInfo volumeInfo)
        {
            var partition = volumeInfo.Partition;

            if (partition == null)
            {
                return(false);
            }
            return(partition.BiosType == BiosPartitionTypes.LinuxLvm ||
                   partition.GuidType == GuidPartitionTypes.LinuxLvm);
        }
Example #7
0
        private static void CreateVirtualDisk(string filePath, int size)
        {
            using (FileStream fsStream = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                using (VirtualDisk disk = DiscUtils.Vhd.Disk.InitializeDynamic(fsStream, DiscUtils.Streams.Ownership.Dispose, size * 1024 * 1024))
                {
                    GuidPartitionTable.Initialize(disk, WellKnownPartitionType.WindowsNtfs);

                    PhysicalVolumeInfo volume = VolumeManager.GetPhysicalVolumes(disk)[0];

                    NtfsFileSystem.Format(volume, "CryptoBox");
                }
        }
Example #8
0
        public void CloseContainer()
        {
            fsHandler = null; discFs.Dispose();
            fsInfo    = null; volume = null;
            disk.Dispose();

            File.Delete(originalPath);

            Crypto.EncryptFile(temporaryPath, originalPath, pwdKey, new AesEngine(), 128, 128);

            File.Delete(temporaryPath);
        }
Example #9
0
        private void LoadContainer(string filePath)
        {
            disk = VirtualDisk.OpenDisk(filePath, FileAccess.ReadWrite);

            Debug.WriteLine(disk.Capacity + ", " + disk.DiskTypeInfo.Name);

            volume = VolumeManager.GetPhysicalVolumes(disk.Content)[0];

            fsInfo = FileSystemManager.DetectFileSystems(volume)[0];

            discFs = fsInfo.Open(volume);

            tmpFiles = new List <string>();

            Debug.WriteLine(fsInfo.Name + " - " + fsInfo.Description);

            fsHandler = new FileSystemHandler.FileSystemHandler(this);
        }
 public override bool HandlesPhysicalVolume(PhysicalVolumeInfo volume)
 {
     return DynamicDiskManager.HandlesPhysicalVolume(volume);
 }
 public override bool HandlesPhysicalVolume(PhysicalVolumeInfo volume)
 {
     return(DynamicDiskManager.HandlesPhysicalVolume(volume));
 }
 public override bool HandlesPhysicalVolume(PhysicalVolumeInfo volume)
 {
     return(LogicalVolumeManager.HandlesPhysicalVolume(volume));
 }
Example #13
0
 /// <summary>
 /// Gets a value representing a device (aka partition).
 /// </summary>
 /// <param name="parentObject">Object containing detailed information about the device.</param>
 /// <param name="physicalVolume">The volume to represent.</param>
 /// <returns>The value as an object.</returns>
 public static ElementValue ForDevice(Guid parentObject, PhysicalVolumeInfo physicalVolume)
 {
     return(new DeviceElementValue(parentObject, physicalVolume));
 }
Example #14
0
 /// <summary>
 /// Gets a value representing a device (aka partition).
 /// </summary>
 /// <param name="parentObject">Object containing detailed information about the device.</param>
 /// <param name="physicalVolume">The volume to represent.</param>
 /// <returns>The value as an object.</returns>
 public static ElementValue ForDevice(Guid parentObject, PhysicalVolumeInfo physicalVolume)
 {
     return new DeviceElementValue(parentObject, physicalVolume);
 }
Example #15
0
 public abstract bool HandlesPhysicalVolume(PhysicalVolumeInfo volume);