Ejemplo n.º 1
0
        /// <summary>
        /// The ProcessRecord instantiates a NTFSVolumeData objects that
        /// corresponds to the VolumeName that is specified.
        /// </summary>

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

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

            string volLetter = volume.TrimStart('\\').TrimStart('.').TrimStart('\\') + '\\';

            WriteDebug("VolumeName: " + volume);

            byte[] mftBytes = MasterFileTable.GetBytes(volume);

            if (this.MyInvocation.BoundParameters.ContainsKey("Path"))
            {
                int index = IndexNumber.Get(volume, filePath);

                if (asbytes)
                {
                    WriteObject(MFTRecord.getMFTRecordBytes(mftBytes, index));
                }

                else
                {
                    WriteObject(MFTRecord.Get(mftBytes, index, volLetter, filePath));
                }
            }

            else if (this.MyInvocation.BoundParameters.ContainsKey("Index"))
            {
                if (asbytes)
                {
                    WriteObject(MFTRecord.getMFTRecordBytes(mftBytes, indexNumber));
                }

                else
                {
                    WriteObject(MFTRecord.Get(mftBytes, indexNumber, volLetter, null));
                }
            }

            else
            {
                MFTRecord[] records = MFTRecord.GetInstances(mftBytes, volLetter);

                foreach (MFTRecord record in records)
                {
                    WriteObject(record);
                }
            }
        } // ProcessRecord
Ejemplo n.º 2
0
        /// <summary>
        /// The ProcessRecord instantiates a NTFSVolumeData objects that
        /// corresponds to the VolumeName that is specified.
        /// </summary>

        protected override void ProcessRecord()
        {
            NativeMethods.getVolumeName(ref volume);

            string volLetter = volume.TrimStart('\\').TrimStart('.').TrimStart('\\') + '\\';

            byte[] mftBytes = MasterFileTable.GetBytes(volume);

            if (this.MyInvocation.BoundParameters.ContainsKey("Path"))
            {
                int index = IndexNumber.Get(volume, filePath);

                if (asbytes)
                {
                    WriteObject(MFTRecord.getMFTRecordBytes(mftBytes, index));
                }

                else
                {
                    WriteObject(MFTRecord.Get(mftBytes, index, volLetter, filePath));
                }
            }

            else if (this.MyInvocation.BoundParameters.ContainsKey("Index"))
            {
                if (asbytes)
                {
                    WriteObject(MFTRecord.getMFTRecordBytes(mftBytes, indexNumber));
                }

                else
                {
                    WriteObject(MFTRecord.Get(mftBytes, indexNumber, volLetter, null));
                }
            }

            else
            {
                MFTRecord[] records = MFTRecord.GetInstances(mftBytes, volLetter);

                foreach (MFTRecord record in records)
                {
                    WriteObject(record);
                }
            }
        } // ProcessRecord