示例#1
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (2 + partition.Start >= partition.End)
            {
                return(false);
            }

            byte[] eigthBytes = new byte[8];

            byte[] ntfsBpb = imagePlugin.ReadSector(0 + partition.Start);

            Array.Copy(ntfsBpb, 0x003, eigthBytes, 0, 8);
            string oemName = StringHandlers.CToString(eigthBytes);

            if (oemName != "NTFS    ")
            {
                return(false);
            }

            byte   fatsNo    = ntfsBpb[0x010];
            ushort spFat     = BitConverter.ToUInt16(ntfsBpb, 0x016);
            ushort signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE);

            if (fatsNo != 0)
            {
                return(false);
            }
            if (spFat != 0)
            {
                return(false);
            }

            return(signature == 0xAA55);
        }
示例#2
0
        static DecodedVolumeDescriptor DecodeVolumeDescriptor(PrimaryVolumeDescriptor pvd)
        {
            var decodedVd = new DecodedVolumeDescriptor
            {
                SystemIdentifier       = StringHandlers.CToString(pvd.system_id).TrimEnd(),
                VolumeIdentifier       = StringHandlers.CToString(pvd.volume_id).TrimEnd(),
                VolumeSetIdentifier    = StringHandlers.CToString(pvd.volume_set_id).TrimEnd(),
                PublisherIdentifier    = StringHandlers.CToString(pvd.publisher_id).TrimEnd(),
                DataPreparerIdentifier = StringHandlers.CToString(pvd.preparer_id).TrimEnd(),
                ApplicationIdentifier  = StringHandlers.CToString(pvd.application_id).TrimEnd()
            };

            if (pvd.creation_date[0] == '0' ||
                pvd.creation_date[0] == 0x00)
            {
                decodedVd.CreationTime = DateTime.MinValue;
            }
            else
            {
                decodedVd.CreationTime = DateHandlers.Iso9660ToDateTime(pvd.creation_date);
            }

            if (pvd.modification_date[0] == '0' ||
                pvd.modification_date[0] == 0x00)
            {
                decodedVd.HasModificationTime = false;
            }
            else
            {
                decodedVd.HasModificationTime = true;
                decodedVd.ModificationTime    = DateHandlers.Iso9660ToDateTime(pvd.modification_date);
            }

            if (pvd.expiration_date[0] == '0' ||
                pvd.expiration_date[0] == 0x00)
            {
                decodedVd.HasExpirationTime = false;
            }
            else
            {
                decodedVd.HasExpirationTime = true;
                decodedVd.ExpirationTime    = DateHandlers.Iso9660ToDateTime(pvd.expiration_date);
            }

            if (pvd.effective_date[0] == '0' ||
                pvd.effective_date[0] == 0x00)
            {
                decodedVd.HasEffectiveTime = false;
            }
            else
            {
                decodedVd.HasEffectiveTime = true;
                decodedVd.EffectiveTime    = DateHandlers.Iso9660ToDateTime(pvd.effective_date);
            }

            decodedVd.Blocks    = pvd.volume_space_size;
            decodedVd.BlockSize = pvd.logical_block_size;

            return(decodedVd);
        }
示例#3
0
        public static string PrettifyHPModePage_3B(HP_ModePage_3B?modePage)
        {
            if (!modePage.HasValue)
            {
                return(null);
            }

            HP_ModePage_3B page = modePage.Value;
            StringBuilder  sb   = new StringBuilder();

            sb.AppendLine("HP Serial Number Override Mode Page:");

            if (page.PS)
            {
                sb.AppendLine("\tParameters can be saved");
            }

            switch (page.MSN)
            {
            case 1:
                sb.AppendLine("\tSerial number is the manufacturer's default value");
                break;

            case 3:
                sb.AppendLine("\tSerial number is not the manufacturer's default value");
                break;
            }

            sb.AppendFormat("\tSerial number: {0}", StringHandlers.CToString(page.SerialNumber)).AppendLine();

            return(sb.ToString());
        }
示例#4
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            // Technically everything on Plan 9 from Bell Labs is in UTF-8
            Encoding    = Encoding.UTF8;
            information = "";
            if (imagePlugin.Info.SectorSize < 512)
            {
                return;
            }

            ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize;

            byte[]       sector = imagePlugin.ReadSector(partition.Start + hdrSector);
            FossilHeader hdr    = Marshal.ByteArrayToStructureBigEndian <FossilHeader>(sector);

            DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic,
                                      FOSSIL_HDR_MAGIC);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Fossil");
            sb.AppendFormat("Filesystem version {0}", hdr.version).AppendLine();
            sb.AppendFormat("{0} bytes per block", hdr.blockSize).AppendLine();
            sb.AppendFormat("Superblock resides in block {0}", hdr.super).AppendLine();
            sb.AppendFormat("Labels resides in block {0}", hdr.label).AppendLine();
            sb.AppendFormat("Data starts at block {0}", hdr.data).AppendLine();
            sb.AppendFormat("Volume has {0} blocks", hdr.end).AppendLine();

            ulong sbLocation = hdr.super * (hdr.blockSize / imagePlugin.Info.SectorSize) + partition.Start;

            XmlFsType = new FileSystemType
            {
                Type = "Fossil filesystem", ClusterSize = hdr.blockSize, Clusters = hdr.end
            };

            if (sbLocation <= partition.End)
            {
                sector = imagePlugin.ReadSector(sbLocation);
                FossilSuperBlock fsb = Marshal.ByteArrayToStructureBigEndian <FossilSuperBlock>(sector);

                DicConsole.DebugWriteLine("Fossil plugin", "magic 0x{0:X8} (expected 0x{1:X8})", fsb.magic,
                                          FOSSIL_SB_MAGIC);

                if (fsb.magic == FOSSIL_SB_MAGIC)
                {
                    sb.AppendFormat("Epoch low {0}", fsb.epochLow).AppendLine();
                    sb.AppendFormat("Epoch high {0}", fsb.epochHigh).AppendLine();
                    sb.AppendFormat("Next QID {0}", fsb.qid).AppendLine();
                    sb.AppendFormat("Active root block {0}", fsb.active).AppendLine();
                    sb.AppendFormat("Next root block {0}", fsb.next).AppendLine();
                    sb.AppendFormat("Curren root block {0}", fsb.current).AppendLine();
                    sb.AppendFormat("Volume label: \"{0}\"", StringHandlers.CToString(fsb.name, Encoding)).AppendLine();
                    XmlFsType.VolumeName = StringHandlers.CToString(fsb.name, Encoding);
                }
            }

            information = sb.ToString();
        }
示例#5
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            if ((stream.Length - Marshal.SizeOf <DriFooter>()) % 512 != 0)
            {
                return(false);
            }

            byte[] buffer = new byte[Marshal.SizeOf <DriFooter>()];
            stream.Seek(-buffer.Length, SeekOrigin.End);
            stream.Read(buffer, 0, buffer.Length);

            DriFooter tmpFooter = Marshal.ByteArrayToStructureLittleEndian <DriFooter>(buffer);

            string sig = StringHandlers.CToString(tmpFooter.signature);

            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.signature = \"{0}\"", sig);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.five = {0}", tmpFooter.bpb.five);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.driveCode = {0}", tmpFooter.bpb.driveCode);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown = {0}", tmpFooter.bpb.unknown);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.cylinders = {0}", tmpFooter.bpb.cylinders);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown2 = {0}", tmpFooter.bpb.unknown2);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.bps = {0}", tmpFooter.bpb.bps);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.spc = {0}", tmpFooter.bpb.spc);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.rsectors = {0}", tmpFooter.bpb.rsectors);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.fats_no = {0}", tmpFooter.bpb.fats_no);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.sectors = {0}", tmpFooter.bpb.sectors);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.media_descriptor = {0}",
                                      tmpFooter.bpb.media_descriptor);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.spfat = {0}", tmpFooter.bpb.spfat);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.sptrack = {0}", tmpFooter.bpb.sptrack);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.heads = {0}", tmpFooter.bpb.heads);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.hsectors = {0}", tmpFooter.bpb.hsectors);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.drive_no = {0}", tmpFooter.bpb.drive_no);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown3 = {0}", tmpFooter.bpb.unknown3);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown4 = {0}", tmpFooter.bpb.unknown4);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.sptrack2 = {0}", tmpFooter.bpb.sptrack2);
            DicConsole.DebugWriteLine("DRI DiskCopy plugin",
                                      "ArrayHelpers.ArrayIsNullOrEmpty(tmp_footer.bpb.unknown5) = {0}",
                                      ArrayHelpers.ArrayIsNullOrEmpty(tmpFooter.bpb.unknown5));

            Regex regexSignature = new Regex(REGEX_DRI);
            Match matchSignature = regexSignature.Match(sig);

            DicConsole.DebugWriteLine("DRI DiskCopy plugin", "MatchSignature.Success? = {0}", matchSignature.Success);

            if (!matchSignature.Success)
            {
                return(false);
            }

            if (tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors)
            {
                return(false);
            }

            return(tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf <DriFooter>() == stream.Length);
        }
示例#6
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            // Always Shift-JIS
            Encoding    = Encoding.GetEncoding("shift_jis");
            information = "";

            byte[]     sector = imagePlugin.ReadSectors(partition.Start, 2);
            PcfxHeader header = Marshal.ByteArrayToStructureLittleEndian <PcfxHeader>(sector);

            string   date;
            DateTime dateTime = DateTime.MinValue;

            try
            {
                date = Encoding.GetString(header.date);
                int year  = int.Parse(date.Substring(0, 4));
                int month = int.Parse(date.Substring(4, 2));
                int day   = int.Parse(date.Substring(6, 2));
                dateTime = new DateTime(year, month, day);
            }
            catch
            {
                date = null;
            }

            var sb = new StringBuilder();

            sb.AppendLine("PC-FX executable:");
            sb.AppendFormat("Identifier: {0}", StringHandlers.CToString(header.signature, Encoding)).AppendLine();
            sb.AppendFormat("Copyright: {0}", StringHandlers.CToString(header.copyright, Encoding)).AppendLine();
            sb.AppendFormat("Title: {0}", StringHandlers.CToString(header.title, Encoding)).AppendLine();
            sb.AppendFormat("Maker ID: {0}", StringHandlers.CToString(header.makerId, Encoding)).AppendLine();
            sb.AppendFormat("Maker name: {0}", StringHandlers.CToString(header.makerName, Encoding)).AppendLine();
            sb.AppendFormat("Volume number: {0}", header.volumeNumber).AppendLine();
            sb.AppendFormat("Country code: {0}", header.country).AppendLine();
            sb.AppendFormat("Version: {0}.{1}", header.minorVersion, header.majorVersion).AppendLine();

            if (date != null)
            {
                sb.AppendFormat("Dated {0}", dateTime).AppendLine();
            }

            sb.AppendFormat("Load {0} sectors from sector {1}", header.loadCount, header.loadOffset).AppendLine();

            sb.AppendFormat("Load at 0x{0:X8} and jump to 0x{1:X8}", header.loadAddress, header.entryPoint).
            AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type                = "PC-FX", Clusters = partition.Length, ClusterSize = 2048,
                Bootable            = true,
                CreationDate        = dateTime, CreationDateSpecified = date != null,
                PublisherIdentifier = StringHandlers.CToString(header.makerName, Encoding),
                VolumeName          = StringHandlers.CToString(header.title, Encoding), SystemIdentifier = "PC-FX"
            };
        }
示例#7
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";

            if (imagePlugin.Info.SectorSize < 512)
            {
                return;
            }

            uint sbAddr = REISER4_SUPER_OFFSET / imagePlugin.Info.SectorSize;

            if (sbAddr == 0)
            {
                sbAddr = 1;
            }

            uint sbSize = (uint)(Marshal.SizeOf <Superblock>() / imagePlugin.Info.SectorSize);

            if (Marshal.SizeOf <Superblock>() % imagePlugin.Info.SectorSize != 0)
            {
                sbSize++;
            }

            byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);

            if (sector.Length < Marshal.SizeOf <Superblock>())
            {
                return;
            }

            Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

            if (!_magic.SequenceEqual(reiserSb.magic))
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendLine("Reiser 4 filesystem");
            sb.AppendFormat("{0} bytes per block", reiserSb.blocksize).AppendLine();
            sb.AppendFormat("Volume disk format: {0}", reiserSb.diskformat).AppendLine();
            sb.AppendFormat("Volume UUID: {0}", reiserSb.uuid).AppendLine();
            sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(reiserSb.label, Encoding)).AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type         = "Reiser 4 filesystem",
                ClusterSize  = reiserSb.blocksize,
                Clusters     = ((partition.End - partition.Start) * imagePlugin.Info.SectorSize) / reiserSb.blocksize,
                VolumeName   = StringHandlers.CToString(reiserSb.label, Encoding),
                VolumeSerial = reiserSb.uuid.ToString()
            };
        }
示例#8
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = new PETSCII();
            byte[] sector;

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Commodore file system");

            XmlFsType = new FileSystemType
            {
                Type = "Commodore file system", Clusters = imagePlugin.Info.Sectors, ClusterSize = 256
            };

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian <CommodoreHeader>(sector);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmHdr.directoryTrack,
                                           cbmHdr.directorySector).AppendLine();
                sbInformation
                .AppendFormat("Disk DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskDosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmHdr.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmHdr.diskId}";
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian <CommodoreBam>(sector);

                sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack,
                                           cbmBam.directorySector).AppendLine();
                sbInformation.AppendFormat("Disk DOS type: {0}",
                                           Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType)))
                .AppendLine();
                sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmBam.dosVersion }))
                .AppendLine();
                sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine();
                sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding))
                .AppendLine();

                XmlFsType.VolumeName   = StringHandlers.CToString(cbmBam.name, Encoding);
                XmlFsType.VolumeSerial = $"{cbmBam.diskId}";
            }

            information = sbInformation.ToString();
        }
示例#9
0
文件: Dir.cs 项目: morefun0302/Aaru
        Errno ReadDir(short dirId, out List <string> contents)
        {
            // Do same trick as Mac OS X, replace filesystem '/' with '-',
            // as '-' is the path separator in Lisa OS
            contents = (from entry in _catalogCache where entry.parentID == dirId
                        select StringHandlers.CToString(entry.filename, Encoding).Replace('/', '-')).ToList();

            return(Errno.NoError);
        }
示例#10
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";

            var sb = new StringBuilder();

            byte[] bfsSbSector = imagePlugin.ReadSector(0 + partition.Start);
            byte[] sbStrings   = new byte[6];

            var bfsSb = new SuperBlock
            {
                s_magic = BitConverter.ToUInt32(bfsSbSector, 0x00),
                s_start = BitConverter.ToUInt32(bfsSbSector, 0x04),
                s_end   = BitConverter.ToUInt32(bfsSbSector, 0x08),
                s_from  = BitConverter.ToUInt32(bfsSbSector, 0x0C),
                s_to    = BitConverter.ToUInt32(bfsSbSector, 0x10),
                s_bfrom = BitConverter.ToInt32(bfsSbSector, 0x14),
                s_bto   = BitConverter.ToInt32(bfsSbSector, 0x18)
            };

            Array.Copy(bfsSbSector, 0x1C, sbStrings, 0, 6);
            bfsSb.s_fsname = StringHandlers.CToString(sbStrings, Encoding);
            Array.Copy(bfsSbSector, 0x22, sbStrings, 0, 6);
            bfsSb.s_volume = StringHandlers.CToString(sbStrings, Encoding);

            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_magic: 0x{0:X8}", bfsSb.s_magic);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_start: 0x{0:X8}", bfsSb.s_start);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_end: 0x{0:X8}", bfsSb.s_end);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_from: 0x{0:X8}", bfsSb.s_from);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_to: 0x{0:X8}", bfsSb.s_to);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_bfrom: 0x{0:X8}", bfsSb.s_bfrom);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_bto: 0x{0:X8}", bfsSb.s_bto);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_fsname: 0x{0}", bfsSb.s_fsname);
            AaruConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_volume: 0x{0}", bfsSb.s_volume);

            sb.AppendLine("UNIX Boot filesystem");

            sb.AppendFormat("Volume goes from byte {0} to byte {1}, for {2} bytes", bfsSb.s_start, bfsSb.s_end,
                            bfsSb.s_end - bfsSb.s_start).AppendLine();

            sb.AppendFormat("Filesystem name: {0}", bfsSb.s_fsname).AppendLine();
            sb.AppendFormat("Volume name: {0}", bfsSb.s_volume).AppendLine();

            XmlFsType = new FileSystemType
            {
                Type        = "BFS",
                VolumeName  = bfsSb.s_volume,
                ClusterSize = imagePlugin.Info.SectorSize,
                Clusters    = (partition.End - partition.Start) + 1
            };

            information = sb.ToString();
        }
示例#11
0
        Dictionary <string, DirectoryEntryWithPointers> DecodeDirectory(int firstBlock)
        {
            Dictionary <string, DirectoryEntryWithPointers> entries =
                new Dictionary <string, DirectoryEntryWithPointers>();

            int nextBlock = firstBlock;

            DirectoryHeader header;

            do
            {
                byte[] data = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), _volumeBlockSizeRatio);
                header    = Marshal.ByteArrayToStructureBigEndian <DirectoryHeader>(data);
                nextBlock = header.next_block + firstBlock;

                int off = (int)header.first_used;

                var entry = new DirectoryEntry();

                while (off + _directoryEntrySize < data.Length)
                {
                    entry = Marshal.ByteArrayToStructureBigEndian <DirectoryEntry>(data, off, _directoryEntrySize);
                    string name = StringHandlers.CToString(entry.name, Encoding);

                    var entryWithPointers = new DirectoryEntryWithPointers
                    {
                        entry    = entry,
                        pointers = new uint[entry.last_copy + 1]
                    };

                    for (int i = 0; i <= entry.last_copy; i++)
                    {
                        entryWithPointers.pointers[i] =
                            BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + (i * 4));
                    }

                    entries.Add(name, entryWithPointers);

                    if ((entry.flags & (uint)FileFlags.LastEntry) != 0 ||
                        (entry.flags & (uint)FileFlags.LastEntryInBlock) != 0)
                    {
                        break;
                    }

                    off += (int)(_directoryEntrySize + ((entry.last_copy + 1) * 4));
                }

                if ((entry.flags & (uint)FileFlags.LastEntry) != 0)
                {
                    break;
                }
            } while(header.next_block != -1);

            return(entries);
        }
示例#12
0
文件: VxFS.cs 项目: paulyc/Aaru
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.UTF8;
            ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;

            byte[] sector = imagePlugin.ReadSector(partition.Start + vmfsSuperOff);

            SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);

            var sbInformation = new StringBuilder();

            sbInformation.AppendLine("Veritas file system");

            sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine();

            sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, Encoding)).
            AppendLine();

            sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).
            AppendLine();

            sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine();
            sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine();
            sbInformation.AppendFormat("Volume has {0} free blocks", vxSb.vs_free).AppendLine();

            sbInformation.AppendFormat("Volume created on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine();

            sbInformation.AppendFormat("Volume last modified on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine();

            if (vxSb.vs_clean != 0)
            {
                sbInformation.AppendLine("Volume is dirty");
            }

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                Type                      = "Veritas file system",
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime),
                ModificationDateSpecified = true,
                Clusters                  = (ulong)vxSb.vs_size,
                ClusterSize               = (uint)vxSb.vs_bsize,
                Dirty                     = vxSb.vs_clean != 0,
                FreeClusters              = (ulong)vxSb.vs_free,
                FreeClustersSpecified     = true
            };
        }
示例#13
0
        public void Update(byte[] data, bool bigEndian)
        {
            VersionInfo versionInfo = bigEndian
                                          ? BigEndianMarshal.ByteArrayToStructureBigEndian <VersionInfo>(data)
                                          : BigEndianMarshal.ByteArrayToStructureLittleEndian <VersionInfo>(data);

            txtMajorVersion.Text  = $"{versionInfo.major}";
            txtMiddleVersion.Text = $"{versionInfo.middle}";
            txtMinorVersion.Text  = $"{versionInfo.minor}";
            txtVariety.Text       = $"{versionInfo.variety}";
            txtInternal.Text      = $"{versionInfo.interna1}";
            txtShortInfo.Text     = StringHandlers.CToString(versionInfo.short_info, Encoding.UTF8);
            txtLongInfo.Text      = StringHandlers.CToString(versionInfo.long_info, Encoding.UTF8);
        }
示例#14
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.UTF8;
            ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize;

            byte[] sector = imagePlugin.ReadSector(partition.Start + vmfsSuperOff);

            VolumeInfo volInfo    = new VolumeInfo();
            IntPtr     volInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(volInfo));

            Marshal.Copy(sector, 0, volInfoPtr, Marshal.SizeOf(volInfo));
            volInfo = (VolumeInfo)Marshal.PtrToStructure(volInfoPtr, typeof(VolumeInfo));
            Marshal.FreeHGlobal(volInfoPtr);

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("VMware file system");

            uint ctimeSecs     = (uint)(volInfo.ctime / 1000000);
            uint ctimeNanoSecs = (uint)(volInfo.ctime % 1000000);
            uint mtimeSecs     = (uint)(volInfo.mtime / 1000000);
            uint mtimeNanoSecs = (uint)(volInfo.mtime % 1000000);

            sbInformation.AppendFormat("Volume version {0}", volInfo.version).AppendLine();
            sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name, Encoding))
            .AppendLine();
            sbInformation.AppendFormat("Volume size {0} bytes", volInfo.size * 256).AppendLine();
            sbInformation.AppendFormat("Volume UUID {0}", volInfo.uuid).AppendLine();
            sbInformation
            .AppendFormat("Volume created on {0}", DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs))
            .AppendLine();
            sbInformation.AppendFormat("Volume last modified on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs)).AppendLine();

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                Type                      = "VMware file system",
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs),
                ModificationDateSpecified = true,
                Clusters                  = volInfo.size * 256 / imagePlugin.Info.SectorSize,
                ClusterSize               = (int)imagePlugin.Info.SectorSize,
                VolumeSerial              = volInfo.uuid.ToString()
            };
        }
示例#15
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
            byte[] sector = imagePlugin.ReadSector(partition.Start);
            uint   magic  = BitConverter.ToUInt32(sector, 0x00);

            CramSuperBlock crSb         = new CramSuperBlock();
            bool           littleEndian = true;

            switch (magic)
            {
            case CRAM_MAGIC:
                IntPtr crSbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(crSb));
                Marshal.Copy(sector, 0, crSbPtr, Marshal.SizeOf(crSb));
                crSb = (CramSuperBlock)Marshal.PtrToStructure(crSbPtr, typeof(CramSuperBlock));
                Marshal.FreeHGlobal(crSbPtr);
                break;

            case CRAM_CIGAM:
                crSb         = BigEndianMarshal.ByteArrayToStructureBigEndian <CramSuperBlock>(sector);
                littleEndian = false;
                break;
            }

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Cram file system");
            sbInformation.AppendLine(littleEndian ? "Little-endian" : "Big-endian");
            sbInformation.AppendFormat("Volume edition {0}", crSb.edition).AppendLine();
            sbInformation.AppendFormat("Volume name: {0}", StringHandlers.CToString(crSb.name, Encoding)).AppendLine();
            sbInformation.AppendFormat("Volume has {0} bytes", crSb.size).AppendLine();
            sbInformation.AppendFormat("Volume has {0} blocks", crSb.blocks).AppendLine();
            sbInformation.AppendFormat("Volume has {0} files", crSb.files).AppendLine();

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                VolumeName            = StringHandlers.CToString(crSb.name, Encoding),
                Type                  = "Cram file system",
                Clusters              = crSb.blocks,
                Files                 = crSb.files,
                FilesSpecified        = true,
                FreeClusters          = 0,
                FreeClustersSpecified = true
            };
        }
示例#16
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";

            if (imagePlugin.Info.SectorSize < 256)
            {
                return;
            }

            byte[]      sector = imagePlugin.ReadSector(partition.Start);
            SystemBlock lifSb  = Marshal.ByteArrayToStructureBigEndian <SystemBlock>(sector);

            if (lifSb.magic != LIF_MAGIC)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendLine("HP Logical Interchange Format");
            sb.AppendFormat("Directory starts at cluster {0}", lifSb.directoryStart).AppendLine();
            sb.AppendFormat("LIF identifier: {0}", lifSb.lifId).AppendLine();
            sb.AppendFormat("Directory size: {0} clusters", lifSb.directorySize).AppendLine();
            sb.AppendFormat("LIF version: {0}", lifSb.lifVersion).AppendLine();

            // How is this related to volume size? I have only CDs to test and makes no sense there
            sb.AppendFormat("{0} tracks", lifSb.tracks).AppendLine();
            sb.AppendFormat("{0} heads", lifSb.heads).AppendLine();
            sb.AppendFormat("{0} sectors", lifSb.sectors).AppendLine();
            sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(lifSb.volumeLabel, Encoding)).AppendLine();
            sb.AppendFormat("Volume created on {0}", DateHandlers.LifToDateTime(lifSb.creationDate)).AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type                  = "HP Logical Interchange Format",
                ClusterSize           = 256,
                Clusters              = partition.Size / 256,
                CreationDate          = DateHandlers.LifToDateTime(lifSb.creationDate),
                CreationDateSpecified = true,
                VolumeName            = StringHandlers.CToString(lifSb.volumeLabel, Encoding)
            };
        }
示例#17
0
文件: SolarFS.cs 项目: paulyc/Aaru
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (2 + partition.Start >= partition.End)
            {
                return(false);
            }

            byte[] bpb = imagePlugin.ReadSector(0 + partition.Start);

            byte[] fsTypeB = new byte[8];

            byte signature = bpb[0x25];

            Array.Copy(bpb, 0x35, fsTypeB, 0, 8);
            string fsType = StringHandlers.CToString(fsTypeB);

            return(signature == 0x29 && fsType == "SOL_FS  ");
        }
示例#18
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);
            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            Encoding shiftjis = Encoding.GetEncoding("shift_jis");

            v98Hdr = new Virtual98Header();

            if (stream.Length < Marshal.SizeOf(v98Hdr))
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
            stream.Read(hdrB, 0, hdrB.Length);

            GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);

            v98Hdr =
                (Virtual98Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Virtual98Header));
            handle.Free();

            if (!v98Hdr.signature.SequenceEqual(signature))
            {
                return(false);
            }

            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.signature = \"{0}\"",
                                      StringHandlers.CToString(v98Hdr.signature, shiftjis));
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.comment = \"{0}\"",
                                      StringHandlers.CToString(v98Hdr.comment, shiftjis));
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.padding = {0}", v98Hdr.padding);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.mbsize = {0}", v98Hdr.mbsize);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectorsize = {0}", v98Hdr.sectorsize);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectors = {0}", v98Hdr.sectors);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.surfaces = {0}", v98Hdr.surfaces);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.cylinders = {0}", v98Hdr.cylinders);
            DicConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.totals = {0}", v98Hdr.totals);

            return(true);
        }
示例#19
0
        public bool Open(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);
            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            Encoding shiftjis = Encoding.GetEncoding("shift_jis");

            v98Hdr = new Virtual98Header();

            if (stream.Length < Marshal.SizeOf(v98Hdr))
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
            stream.Read(hdrB, 0, hdrB.Length);

            GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);

            v98Hdr =
                (Virtual98Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Virtual98Header));
            handle.Free();

            imageInfo.MediaType = MediaType.GENERIC_HDD;

            imageInfo.ImageSize            = (ulong)(stream.Length - 0xDC);
            imageInfo.CreationTime         = imageFilter.GetCreationTime();
            imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
            imageInfo.MediaTitle           = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
            imageInfo.Sectors         = v98Hdr.totals;
            imageInfo.XmlMediaType    = XmlMediaType.BlockMedia;
            imageInfo.SectorSize      = v98Hdr.sectorsize;
            imageInfo.Cylinders       = v98Hdr.cylinders;
            imageInfo.Heads           = v98Hdr.surfaces;
            imageInfo.SectorsPerTrack = v98Hdr.sectors;
            imageInfo.Comments        = StringHandlers.CToString(v98Hdr.comment, shiftjis);

            nhdImageFilter = imageFilter;

            return(true);
        }
示例#20
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);
            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            Encoding shiftjis = Encoding.GetEncoding("shift_jis");

            nhdhdr = new Nhdr0Header();

            if (stream.Length < Marshal.SizeOf(nhdhdr))
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf(nhdhdr)];
            stream.Read(hdrB, 0, hdrB.Length);

            GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);

            nhdhdr = (Nhdr0Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Nhdr0Header));
            handle.Free();

            if (!nhdhdr.szFileID.SequenceEqual(signature))
            {
                return(false);
            }

            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szFileID = \"{0}\"",
                                      StringHandlers.CToString(nhdhdr.szFileID, shiftjis));
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.reserved1 = {0}", nhdhdr.reserved1);
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szComment = \"{0}\"",
                                      StringHandlers.CToString(nhdhdr.szComment, shiftjis));
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwHeadSize = {0}", nhdhdr.dwHeadSize);
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwCylinder = {0}", nhdhdr.dwCylinder);
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wHead = {0}", nhdhdr.wHead);
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSect = {0}", nhdhdr.wSect);
            DicConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSectLen = {0}", nhdhdr.wSectLen);

            return(true);
        }
示例#21
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            if (stream.Length < 512)
            {
                return(false);
            }

            byte[] headerB = new byte[256];
            stream.Read(headerB, 0, 256);
            CpcDiskInfo header = Marshal.ByteArrayToStructureLittleEndian <CpcDiskInfo>(headerB);

            AaruConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"",
                                       StringHandlers.CToString(header.magic));

            return(cpcdskId.SequenceEqual(header.magic.Take(cpcdskId.Length)) || edskId.SequenceEqual(header.magic) ||
                   du54Id.SequenceEqual(header.magic));
        }
示例#22
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            var shiftjis = Encoding.GetEncoding("shift_jis");

            if (stream.Length < Marshal.SizeOf <Nhdr0Header>())
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf <Nhdr0Header>()];
            stream.Read(hdrB, 0, hdrB.Length);

            _nhdhdr = Marshal.ByteArrayToStructureLittleEndian <Nhdr0Header>(hdrB);

            if (!_nhdhdr.szFileID.SequenceEqual(_signature))
            {
                return(false);
            }

            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szFileID = \"{0}\"",
                                       StringHandlers.CToString(_nhdhdr.szFileID, shiftjis));

            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.reserved1 = {0}", _nhdhdr.reserved1);

            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szComment = \"{0}\"",
                                       StringHandlers.CToString(_nhdhdr.szComment, shiftjis));

            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwHeadSize = {0}", _nhdhdr.dwHeadSize);
            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwCylinder = {0}", _nhdhdr.dwCylinder);
            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wHead = {0}", _nhdhdr.wHead);
            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSect = {0}", _nhdhdr.wSect);
            AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSectLen = {0}", _nhdhdr.wSectLen);

            return(true);
        }
示例#23
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            var shiftjis = Encoding.GetEncoding("shift_jis");

            if (stream.Length < Marshal.SizeOf <Virtual98Header>())
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf <Virtual98Header>()];
            stream.Read(hdrB, 0, hdrB.Length);

            v98Hdr = Marshal.ByteArrayToStructureLittleEndian <Virtual98Header>(hdrB);

            if (!v98Hdr.signature.SequenceEqual(signature))
            {
                return(false);
            }

            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.signature = \"{0}\"",
                                       StringHandlers.CToString(v98Hdr.signature, shiftjis));

            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.comment = \"{0}\"",
                                       StringHandlers.CToString(v98Hdr.comment, shiftjis));

            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.padding = {0}", v98Hdr.padding);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.mbsize = {0}", v98Hdr.mbsize);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectorsize = {0}", v98Hdr.sectorsize);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectors = {0}", v98Hdr.sectors);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.surfaces = {0}", v98Hdr.surfaces);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.cylinders = {0}", v98Hdr.cylinders);
            AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.totals = {0}", v98Hdr.totals);

            return(true);
        }
示例#24
0
        public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset)
        {
            partitions = new List <Partition>();

            if (sectorOffset + 2 >= imagePlugin.Info.Sectors)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSector(sectorOffset + 1);

            // While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
            string[] really = StringHandlers.CToString(sector).Split('\n');

            foreach (string[] tokens in really.TakeWhile(part => part.Length >= 5 && part.Substring(0, 5) == "part ").
                     Select(part => part.Split(' ')).TakeWhile(tokens => tokens.Length == 4))
            {
                if (!ulong.TryParse(tokens[2], out ulong start) ||
                    !ulong.TryParse(tokens[3], out ulong end))
                {
                    break;
                }

                var part = new Partition
                {
                    Length   = (end - start) + 1,
                    Offset   = (start + sectorOffset) * imagePlugin.Info.SectorSize,
                    Scheme   = Name,
                    Sequence = (ulong)partitions.Count,
                    Size     = ((end - start) + 1) * imagePlugin.Info.SectorSize,
                    Start    = start + sectorOffset,
                    Type     = tokens[1]
                };

                partitions.Add(part);
            }

            return(partitions.Count > 0);
        }
示例#25
0
        public static byte[] ClearInquiry(byte[] inquiry)
        {
            Inquiry?decodedNullable = Inquiry.Decode(inquiry);

            if (!decodedNullable.HasValue)
            {
                return(inquiry);
            }

            Inquiry decoded = decodedNullable.Value;

            // Clear Seagate serial number
            if (decoded.SeagatePresent &&
                StringHandlers.CToString(decoded.VendorIdentification)?.Trim().ToLowerInvariant() == "seagate")
            {
                for (int i = 36; i <= 43; i++)
                {
                    inquiry[i] = 0;
                }
            }

            return(inquiry);
        }
示例#26
0
        public static CID DecodeCID(byte[] response)
        {
            if (response?.Length != 16)
            {
                return(null);
            }

            CID cid = new CID
            {
                Manufacturer        = response[0],
                DeviceType          = (byte)(response[1] & 0x03),
                ProductRevision     = response[9],
                ProductSerialNumber = BitConverter.ToUInt32(response, 10),
                ManufacturingDate   = response[14],
                CRC = (byte)((response[15] & 0xFE) >> 1)
            };

            byte[] tmp = new byte[6];
            Array.Copy(response, 3, tmp, 0, 6);
            cid.ProductName = StringHandlers.CToString(tmp);

            return(cid);
        }
示例#27
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            if (stream.Length < Marshal.SizeOf(typeof(RayHdr)))
            {
                return(false);
            }

            byte[] buffer = new byte[Marshal.SizeOf(typeof(RayHdr))];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(buffer, 0, buffer.Length);

            IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);

            Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
            RayHdr header = (RayHdr)Marshal.PtrToStructure(ftrPtr, typeof(RayHdr));

            Marshal.FreeHGlobal(ftrPtr);

            string signature = StringHandlers.CToString(header.signature);

            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.signature = {0}", signature);
            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.diskType = {0}", header.diskType);
            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.heads = {0}", header.heads);
            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.cylinders = {0}", header.cylinders);
            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.sectorsPerTrack = {0}",
                                      header.sectorsPerTrack);

            Regex sx = new Regex(REGEX_SIGNATURE);
            Match sm = sx.Match(signature);

            DicConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.signature matches? = {0}",
                                      sm.Success);

            return(sm.Success);
        }
示例#28
0
文件: Read.cs 项目: morefun0302/Aaru
        public bool Open(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            // Even if comment is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
            var shiftjis = Encoding.GetEncoding("shift_jis");

            if (stream.Length < Marshal.SizeOf <Virtual98Header>())
            {
                return(false);
            }

            byte[] hdrB = new byte[Marshal.SizeOf <Virtual98Header>()];
            stream.Read(hdrB, 0, hdrB.Length);

            _v98Hdr = Marshal.ByteArrayToStructureLittleEndian <Virtual98Header>(hdrB);

            _imageInfo.MediaType = MediaType.GENERIC_HDD;

            _imageInfo.ImageSize            = (ulong)(stream.Length - 0xDC);
            _imageInfo.CreationTime         = imageFilter.GetCreationTime();
            _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
            _imageInfo.MediaTitle           = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
            _imageInfo.Sectors         = _v98Hdr.totals;
            _imageInfo.XmlMediaType    = XmlMediaType.BlockMedia;
            _imageInfo.SectorSize      = _v98Hdr.sectorsize;
            _imageInfo.Cylinders       = _v98Hdr.cylinders;
            _imageInfo.Heads           = _v98Hdr.surfaces;
            _imageInfo.SectorsPerTrack = _v98Hdr.sectors;
            _imageInfo.Comments        = StringHandlers.CToString(_v98Hdr.comment, shiftjis);

            _nhdImageFilter = imageFilter;

            return(true);
        }
示例#29
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = Encoding.GetEncoding("koi8-r");
            byte[]          sector = imagePlugin.ReadSector(0);
            AODOS_BootBlock bb     = new AODOS_BootBlock();
            IntPtr          bbPtr  = Marshal.AllocHGlobal(Marshal.SizeOf(bb));

            Marshal.Copy(sector, 0, bbPtr, Marshal.SizeOf(bb));
            bb = (AODOS_BootBlock)Marshal.PtrToStructure(bbPtr, typeof(AODOS_BootBlock));
            Marshal.FreeHGlobal(bbPtr);

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Alexander Osipov DOS file system");

            XmlFsType = new FileSystemType
            {
                Type                  = "Alexander Osipov DOS file system",
                Clusters              = (long)imagePlugin.Info.Sectors,
                ClusterSize           = (int)imagePlugin.Info.SectorSize,
                Files                 = bb.files,
                FilesSpecified        = true,
                FreeClusters          = (long)(imagePlugin.Info.Sectors - bb.usedSectors),
                FreeClustersSpecified = true,
                VolumeName            = StringHandlers.SpacePaddedToString(bb.volumeLabel, Encoding),
                Bootable              = true
            };

            sbInformation.AppendFormat("{0} files on volume", bb.files).AppendLine();
            sbInformation.AppendFormat("{0} used sectors on volume", bb.usedSectors).AppendLine();
            sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(bb.volumeLabel, Encoding))
            .AppendLine();

            information = sbInformation.ToString();
        }
示例#30
0
        public static XboxDMI?DecodeXbox(byte[] response)
        {
            bool isXbox = IsXbox(response);

            if (!isXbox)
            {
                return(null);
            }

            XboxDMI dmi = new XboxDMI
            {
                DataLength = (ushort)((response[0] << 8) + response[1]),
                Reserved1  = response[2],
                Reserved2  = response[3],
                Version    = BitConverter.ToUInt32(response, 4),
                Timestamp  = BitConverter.ToInt64(response, 20)
            };

            byte[] tmp = new byte[8];
            Array.Copy(response, 12, tmp, 0, 8);
            dmi.CatalogNumber = StringHandlers.CToString(tmp);

            return(dmi);
        }