コード例 #1
0
        protected override void ProcessRecord()
        {
            if (!(this.MyInvocation.BoundParameters.ContainsKey("BlockSize")))
            {
                blockSize = 512;
            }

            Regex lettersOnly = new Regex("^[a-zA-Z]{1}$");

            if (lettersOnly.IsMatch(inFile))
            {
                inFile = @"\\.\" + inFile + ":";
            }

            WriteDebug("VolumeName: " + inFile);

            if (this.MyInvocation.BoundParameters.ContainsKey("OutFile"))
            {
                DD.Get(inFile, outFile, offset, blockSize, count);
            }
            else
            {
                for (int i = 0; i <= count; i++)
                {
                    WriteObject(DD.Get(inFile, offset, blockSize));
                    offset += blockSize;
                }
            }
        } // ProcessRecord
コード例 #2
0
        /// <summary>
        /// The ProcessRecord Reads bytes from the InFile
        /// and outputs them to the OutFile.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (!(this.MyInvocation.BoundParameters.ContainsKey("Offset")))
            {
                offset = 0;
            }
            if (!(this.MyInvocation.BoundParameters.ContainsKey("BlockSize")))
            {
                blockSize = 512;
            }

            Util.getVolumeName(ref inFile);

            if (this.MyInvocation.BoundParameters.ContainsKey("OutFile"))
            {
                DD.Get(inFile, outFile, offset, blockSize, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    WriteObject(DD.Get(inFile, offset, blockSize));
                    offset += blockSize;
                }
            }
        }
コード例 #3
0
        private static DirectoryEntry[] GetRootDirectory(string volume)
        {
            string volLetter = Helper.GetVolumeLetter(volume);

            FatVolumeBootRecord vbr = VolumeBootRecord.Get(volume) as FatVolumeBootRecord;

            byte[] bytes = DD.Get(volume, vbr.BytesPerSector * vbr.RootDirectorySector, vbr.BytesPerSector, 2);

            return(GetInstances(bytes, volume, volLetter));
        }
コード例 #4
0
        private static DirectoryEntry[] GetRootDirectory(string volume)
        {
            string volLetter = Helper.GetVolumeLetter(volume);

            FatVolumeBootRecord vbr = VolumeBootRecord.Get(volume) as FatVolumeBootRecord;

            uint FirstRootDirSecNum = vbr.ReservedSectors + (vbr.BPB_NumberOfFATs * vbr.BPB_FatSize32);

            byte[] bytes = DD.Get(volume, vbr.BytesPerSector * FirstRootDirSecNum, vbr.BytesPerSector, 2);

            return(GetInstances(bytes, volume, volLetter));
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] GetContent()
        {
            FatVolumeBootRecord vbr = VolumeBootRecord.Get(this.Volume) as FatVolumeBootRecord;

            int RootDirSectors = ((vbr.BPB_RootEntryCount * 32) + (vbr.BytesPerSector - 1)) / vbr.BytesPerSector;

            uint FatSize = 0;

            if (vbr.BPB_FatSize16 != 0)
            {
                FatSize = vbr.BPB_FatSize16;
            }
            else
            {
                FatSize = vbr.BPB_FatSize32;
            }

            uint FirstDataSector = (uint)(vbr.ReservedSectors + (vbr.BPB_NumberOfFATs * FatSize) + RootDirSectors);

            uint FirstSectorofCluster = ((this.FirstCluster - 2) * vbr.SectorsPerCluster) + FirstDataSector;

            byte[] bytes = DD.Get(this.Volume, (long)FirstSectorofCluster * (long)vbr.BytesPerSector, vbr.BytesPerSector, 1);

            if (this.Directory)
            {
                return(bytes);
            }
            else
            {
                if (this.FileSize <= bytes.Length)
                {
                    return(Helper.GetSubArray(bytes, 0, this.FileSize));
                }
                else
                {
                    // Need to do more...
                    return(bytes);
                }
            }
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] GetContent()
        {
            FatVolumeBootRecord vbr = VolumeBootRecord.Get(this.Volume) as FatVolumeBootRecord;

            int RootDirSectors = ((vbr.BPB_RootEntryCount * 32) + (vbr.BytesPerSector - 1)) / vbr.BytesPerSector;

            uint FirstDataSector = (uint)(vbr.ReservedSectors + (vbr.BPB_NumberOfFATs * vbr.BPB_FatSize) + RootDirSectors);

            uint FirstSectorofCluster = ((this.FirstCluster - 2) * vbr.SectorsPerCluster) + FirstDataSector;

            byte[] bytes = DD.Get(this.Volume, (long)FirstSectorofCluster * (long)vbr.BytesPerSector, vbr.BytesPerSector, 1);

            if (this.Directory)
            {
                return(bytes);
            }
            else
            {
                if (this.FileSize <= bytes.Length)
                {
                    return(Helper.GetSubArray(bytes, 0, this.FileSize));
                }
                else
                {
                    List <byte> byteList = new List <byte>();

                    int[] clusters = FileAllocationTable.GetFatEntry(this.Volume, (int)this.FirstCluster);

                    foreach (int cluster in clusters)
                    {
                        long targetCluster = ((cluster - 2) * vbr.SectorsPerCluster) + FirstDataSector;
                        byteList.AddRange(DD.Get(this.Volume, targetCluster * vbr.BytesPerSector, vbr.BytesPerSector, 1));
                    }

                    return(Helper.GetSubArray(byteList.ToArray(), 0, this.FileSize));
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="volume"></param>
        /// <returns></returns>
        public static FileSystemInformation Get(string volume)
        {
            FatVolumeBootRecord vbr = VolumeBootRecord.Get(volume) as FatVolumeBootRecord;

            return(new FileSystemInformation(DD.Get(volume, (vbr.BytesPerSector * vbr.BPB_FileSytemInfo), vbr.BytesPerSector, 1)));
        }