Exemplo 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
Exemplo 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
Exemplo n.º 3
0
        /// <summary>
        /// The ProcessRecord method calls ManagementClass.GetInstances()
        /// method to iterate through each BindingObject on each system specified.
        /// </summary>
        protected override void ProcessRecord()
        {
            Regex lettersOnly = new Regex("^[a-zA-Z]{1}$");

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

            WriteDebug("VolumeName: " + volume);

            byte[] recordBytes = MFTRecord.getMFTRecordBytes(volume, indexNumber);

            if (asbytes)
            {
                WriteObject(Attr.GetBytes(recordBytes, attribute));
            }

            else
            {
                WriteObject(Attr.Get(recordBytes, attribute));
            }
        } // ProcessRecord