Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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; }

            StringBuilder 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"
            };
        }
Exemplo n.º 3
0
        static DecodedVolumeDescriptor DecodeVolumeDescriptor(FileStructureVolumeDescriptor pvd)
        {
            DecodedVolumeDescriptor 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_data).TrimEnd()
            };

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

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

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

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

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

            return(decodedVD);
        }
Exemplo n.º 4
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 <Reiser4_Superblock>() / imagePlugin.Info.SectorSize);

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

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

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

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

            if (!reiser4_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()
            };
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = new Radix50();
            information = "";

            StringBuilder sb = new StringBuilder();

            byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start);

            GCHandle      handle    = GCHandle.Alloc(hbSector, GCHandleType.Pinned);
            RT11HomeBlock homeblock =
                (RT11HomeBlock)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(RT11HomeBlock));

            handle.Free();

            /* TODO: Is this correct?
             * Assembler:
             *      MOV address, R0
             *      CLR R1
             *      MOV #255., R2
             * 10$: ADD (R0)+, R1
             *      SOB R2, 10$
             *      MOV 1,@R0
             */
            ushort check = 0;

            for (int i = 0; i < 512; i += 2)
            {
                check += BitConverter.ToUInt16(hbSector, i);
            }

            sb.AppendFormat("Volume format is {0}",
                            StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)).AppendLine();
            sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512)
            .AppendLine();
            sb.AppendFormat("First directory segment starts at block {0}", homeblock.rootBlock).AppendLine();
            sb.AppendFormat("Volume owner is \"{0}\"", Encoding.GetString(homeblock.ownername).TrimEnd()).AppendLine();
            sb.AppendFormat("Volume label: \"{0}\"", Encoding.GetString(homeblock.volname).TrimEnd()).AppendLine();
            sb.AppendFormat("Checksum: 0x{0:X4} (calculated 0x{1:X4})", homeblock.checksum, check).AppendLine();

            byte[] bootBlock = imagePlugin.ReadSector(0);

            XmlFsType = new FileSystemType
            {
                Type        = "RT-11",
                ClusterSize = homeblock.cluster * 512,
                Clusters    = homeblock.cluster,
                VolumeName  = StringHandlers.SpacePaddedToString(homeblock.volname, Encoding),
                Bootable    = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlock)
            };

            information = sb.ToString();
        }
Exemplo n.º 8
0
Arquivo: VxFS.cs Projeto: 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
            };
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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()
            };
        }
Exemplo n.º 11
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
            };
        }
Exemplo n.º 12
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)
            };
        }
Exemplo n.º 13
0
        Errno GetFileEntry(string path, out PascalFileEntry entry)
        {
            entry = new PascalFileEntry();

            foreach (PascalFileEntry ent in fileEntries.Where(ent =>
                                                              string.Compare(path,
                                                                             StringHandlers
                                                                             .PascalToString(ent.Filename,
                                                                                             Encoding),
                                                                             StringComparison
                                                                             .InvariantCultureIgnoreCase) == 0))
            {
                entry = ent;
                return(Errno.NoError);
            }

            return(Errno.NoSuchFile);
        }
Exemplo n.º 14
0
        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  ");
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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));
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 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
            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);
        }
Exemplo n.º 21
0
        public void Open(string path)
        {
            string parentFolder = Path.GetDirectoryName(path);
            string baseFilename = Path.GetFileName(path);

            parentFolder = parentFolder ?? "";

            var finderDatStream =
                new FileStream(Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, FileAccess.Read);

            while (finderDatStream.Position + 0x5C <= finderDatStream.Length)
            {
                var    datEntry   = new PCExchangeEntry();
                byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
                finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
                datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian <PCExchangeEntry>(datEntry_b);

                string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));

                byte[] tmpDosName_b = new byte[8];
                byte[] tmpDosExt_b  = new byte[3];
                Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
                Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);

                string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
                                 Encoding.ASCII.GetString(tmpDosExt_b).Trim();

                string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);

                if (baseFilename != macName &&
                    baseFilename != dosName &&
                    baseFilename != dosNameLow)
                {
                    continue;
                }

                if (File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())))
                {
                    dataPath = Path.Combine(parentFolder, macName);
                }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        public void Open(byte[] buffer)
        {
            var ms = new MemoryStream(buffer);

            ms.Seek(0, SeekOrigin.Begin);

            byte[] hdr_b = new byte[128];
            ms.Read(hdr_b, 0, 128);
            header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b);

            uint blocks = 1;

            blocks += (uint)(header.secondaryHeaderLength / 128);

            if (header.secondaryHeaderLength % 128 > 0)
            {
                blocks++;
            }

            dataForkOff = blocks * 128;
            blocks     += header.dataLength / 128;

            if (header.dataLength % 128 > 0)
            {
                blocks++;
            }

            rsrcForkOff = blocks * 128;

            filename      = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh"));
            creationTime  = DateHandlers.MacToDateTime(header.creationTime);
            lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime);

            ms.Close();
            opened  = true;
            isBytes = true;
            bytes   = buffer;
        }
Exemplo n.º 24
0
        public void Open(string path)
        {
            var fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.Seek(0, SeekOrigin.Begin);

            byte[] hdr_b = new byte[128];
            fs.Read(hdr_b, 0, 128);
            header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b);

            uint blocks = 1;

            blocks += (uint)(header.secondaryHeaderLength / 128);

            if (header.secondaryHeaderLength % 128 > 0)
            {
                blocks++;
            }

            dataForkOff = blocks * 128;
            blocks     += header.dataLength / 128;

            if (header.dataLength % 128 > 0)
            {
                blocks++;
            }

            rsrcForkOff = blocks * 128;

            filename      = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh"));
            creationTime  = DateHandlers.MacToDateTime(header.creationTime);
            lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime);

            fs.Close();
            opened   = true;
            isPath   = true;
            basePath = path;
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
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
            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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        public Errno ReadDir(string path, out List <string> contents)
        {
            contents = null;
            if (!mounted)
            {
                return(Errno.AccessDenied);
            }

            if (!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(Errno.NotSupported);
            }

            contents = fileEntries.Select(ent => StringHandlers.PascalToString(ent.Filename, Encoding)).ToList();

            if (debug)
            {
                contents.Add("$");
                contents.Add("$Boot");
            }

            contents.Sort();
            return(Errno.NoError);
        }
Exemplo n.º 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);
        }