Ejemplo n.º 1
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string  location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ISO9660", _testFiles[i]);
                IFilter filter   = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), $"{_testFiles[i]}: Open()");
                Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, $"{_testFiles[i]}: MediaType");
                Assert.AreEqual(_sectors[i], image.Info.Sectors, $"{_testFiles[i]}: Sectors");
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, $"{_testFiles[i]}: SectorSize");
                IFilesystem fs = new ISO9660();

                var wholePart = new Partition
                {
                    Name   = "Whole device",
                    Length = image.Info.Sectors,
                    Size   = image.Info.Sectors * image.Info.SectorSize
                };

                Assert.AreEqual(true, fs.Identify(image, wholePart), $"{_testFiles[i]}: Identify()");
                fs.GetInformation(image, wholePart, out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, $"{_testFiles[i]}: Clusters");
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, $"{_testFiles[i]}: ClusterSize");
                Assert.AreEqual("ISO9660", fs.XmlFsType.Type, $"{_testFiles[i]}: Type");
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, $"{_testFiles[i]}: VolumeName");
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, $"{_testFiles[i]}: VolumeSerial");
                Assert.AreEqual(_sysid[i], fs.XmlFsType.SystemIdentifier, $"{_testFiles[i]}: SystemIdentifier");

                Assert.AreEqual(_appid[i], fs.XmlFsType.ApplicationIdentifier,
                                $"{_testFiles[i]}: ApplicationIdentifier");
            }
        }
Ejemplo n.º 2
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string  location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "MINIX", _testFiles[i]);
                IFilter filter   = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                Assert.AreEqual(_wanted[i].Length, partitions.Count, _testFiles[i]);

                for (int j = 0; j < partitions.Count; j++)
                {
                    // Too chatty
                    //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]);
                    Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testFiles[i]);

                    //                    Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]);
                    Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testFiles[i]);
                    Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testFiles[i]);
                    Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testFiles[i]);
                    Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testFiles[i]);
                    Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testFiles[i]);
                }
            }
        }
Ejemplo n.º 3
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "QNX 4 filesystem (MBR)",
                                               _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                IFilesystem      fs         = new QNX4();
                int part = -1;

                for (int j = 0; j < partitions.Count; j++)
                {
                    if (partitions[j].Type == "0x4D")
                    {
                        part = j;

                        break;
                    }
                }

                Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}");
                Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]);
                fs.GetInformation(image, partitions[part], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual("QNX4 filesystem", fs.XmlFsType.Type, _testFiles[i]);
            }
        }
Ejemplo n.º 4
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Universal Disc Format",
                                               _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                IFilesystem fs = new UDF();

                var wholePart = new Partition
                {
                    Name   = "Whole device",
                    Length = image.Info.Sectors,
                    Size   = image.Info.Sectors * image.Info.SectorSize
                };

                Assert.AreEqual(true, fs.Identify(image, wholePart), _testFiles[i]);
                fs.GetInformation(image, wholePart, out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual(_udfversion[i], fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSetIdentifier, _testFiles[i]);
                Assert.AreEqual(_oemId[i], fs.XmlFsType.SystemIdentifier, _testFiles[i]);
            }
        }
Ejemplo n.º 5
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "High Performance File System",
                                               _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                IFilesystem      fs         = new HPFS();
                Assert.AreEqual(true, fs.Identify(image, partitions[0]), _testFiles[i]);
                fs.GetInformation(image, partitions[0], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual("HPFS", fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]);
                Assert.AreEqual(_oemId[i], fs.XmlFsType.SystemIdentifier, _testFiles[i]);
            }
        }
Ejemplo n.º 6
0
        public async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            string path = await GetPath();

            if (path == null)
            {
                return;
            }

            await Task.Run(() =>
            {
                AaruFormat image = new AaruFormat();
                IFilter filter   = new ZZZNoFilter();
                filter.Open(path);
                image.Open(filter);

                Player.Init(image, App.Settings.AutoPlay);
            });

            await Dispatcher.UIThread.InvokeAsync(() =>
            {
                MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
            }
                                                  );
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Retrieve file information for a single file
        /// </summary>
        /// <param name="input">Filename to get information from</param>
        /// <param name="header">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
        /// <param name="hashes">Hashes to include in the information</param>
        /// <param name="asFiles">TreatAsFiles representing special format scanning</param>
        /// <returns>Populated BaseFile object if success, empty one on error</returns>
        public static BaseFile GetInfo(string input, string header = null, Hash hashes = Hash.Standard, TreatAsFile asFiles = 0x00)
        {
            // Add safeguard if file doesn't exist
            if (!File.Exists(input))
            {
                return(null);
            }

            // Get input information
            var    fileType    = GetFileType(input);
            Stream inputStream = File.OpenRead(input);

            // Try to match the supplied header skipper
            if (header != null)
            {
                SkipperMatch.Init();
                var rule = SkipperMatch.GetMatchingRule(input, Path.GetFileNameWithoutExtension(header));

                // If there's a match, transform the stream before getting info
                if (rule.Tests != null && rule.Tests.Count != 0)
                {
                    // Create the output stream
                    MemoryStream outputStream = new MemoryStream();

                    // Transform the stream and get the information from it
                    rule.TransformStream(inputStream, outputStream, keepReadOpen: false, keepWriteOpen: true);
                    inputStream = outputStream;
                }
            }

            // Get the info in the proper manner
            BaseFile baseFile;

            if (fileType == FileType.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat))
            {
                baseFile = AaruFormat.Create(inputStream);
            }
            else if (fileType == FileType.CHD && !asFiles.HasFlag(TreatAsFile.CHD))
            {
                baseFile = CHDFile.Create(inputStream);
            }
            else
            {
                baseFile = GetInfo(inputStream, hashes: hashes, keepReadOpen: false);
            }

            // Dispose of the input stream
            inputStream?.Dispose();

            // Add unique data from the file
            baseFile.Filename = Path.GetFileName(input);
            baseFile.Date     = new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss");

            return(baseFile);
        }
Ejemplo n.º 8
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (MBR)",
                                               _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                IFilesystem      fs         = new FFSPlugin();
                int part = -1;

                for (int j = 0; j < partitions.Count; j++)
                {
                    if (partitions[j].Type == "0x63" ||
                        partitions[j].Type == "0xA8" ||
                        partitions[j].Type == "0xA5" ||
                        partitions[j].Type == "0xA9" ||
                        partitions[j].Type == "0x82" ||
                        partitions[j].Type == "0x83" ||
                        partitions[j].Type == "4.2BSD Fast File System" ||
                        partitions[j].Type == "Sun boot")
                    {
                        part = j;

                        break;
                    }
                }

                Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}");
                Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]);
                fs.GetInformation(image, partitions[part], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]);
            }
        }
Ejemplo n.º 9
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems",
                                               "New Technology File System (MBR)", _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                IFilesystem      fs         = new NTFS();
                int part = -1;

                for (int j = 0; j < partitions.Count; j++)
                {
                    if (partitions[j].Type == "0x07" ||

                        // Value incorrectly set by Haiku
                        partitions[j].Type == "0x86")
                    {
                        part = j;

                        break;
                    }
                }

                Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}");
                Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]);
                fs.GetInformation(image, partitions[part], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual("NTFS", fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]);
                Assert.AreEqual(_oemId[i], fs.XmlFsType.SystemIdentifier, _testFiles[i]);
            }
        }
Ejemplo n.º 10
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string  location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ext2", _testFiles[i]);
                IFilter filter   = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                IPartition parts = new MBR();
                Assert.AreEqual(true, parts.GetInformation(image, out List <Partition> partitions, 0), _testFiles[i]);
                IFilesystem fs   = new ext2FS();
                int         part = -1;

                for (int j = 0; j < partitions.Count; j++)
                {
                    if (partitions[j].Type == "0x83")
                    {
                        part = j;

                        break;
                    }
                }

                Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}");
                Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]);
                fs.GetInformation(image, partitions[part], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual(_extversion[i], fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]);
            }
        }
Ejemplo n.º 11
0
        public async void Init(AaruFormat image, bool autoPlay = false)
        {
            this.Image = image;

            if (await Task.Run(() => image.Info.ReadableMediaTags?.Contains(MediaTagType.CD_FullTOC)) != true)
            {
                Console.WriteLine("Full TOC not found");
                return;
            }

            byte[] tocBytes = await Task.Run(() => image.ReadDiskTag(MediaTagType.CD_FullTOC));

            if ((tocBytes?.Length ?? 0) == 0)
            {
                Console.WriteLine("Error reading TOC from disc image");
                return;
            }

            if (Swapping.Swap(BitConverter.ToUInt16(tocBytes, 0)) + 2 != tocBytes.Length)
            {
                byte[] tmp = new byte[tocBytes.Length + 2];
                Array.Copy(tocBytes, 0, tmp, 2, tocBytes.Length);
                tmp[0]   = (byte)((tocBytes.Length & 0xFF00) >> 8);
                tmp[1]   = (byte)(tocBytes.Length & 0xFF);
                tocBytes = tmp;
            }

            FullTOC.CDFullTOC?nullableToc = await Task.Run(() => FullTOC.Decode(tocBytes));

            if (nullableToc == null)
            {
                Console.WriteLine("Error decoding TOC");
                return;
            }

            toc = nullableToc.Value;

            Console.WriteLine(FullTOC.Prettify(toc));

            if (deEmphasisFilterLeft == null)
            {
                deEmphasisFilterLeft  = new DeEmphasisFilter();
                deEmphasisFilterRight = new DeEmphasisFilter();
            }
            else
            {
                deEmphasisFilterLeft.Reset();
                deEmphasisFilterRight.Reset();
            }

            if (source == null)
            {
                source = new PlayerSource(ProviderRead);

                soundOut = new ALSoundOut(100);
                soundOut.Initialize(source);
            }
            else
            {
                soundOut.Stop();
            }

            CurrentTrack = 0;
            LoadTrack(0);

            if (autoPlay)
            {
                soundOut.Play();
            }
            else
            {
                TotalIndexes = 0;
            }

            TotalTracks = image.Tracks.Count;
            TrackDataDescriptor firstTrack = toc.TrackDescriptors.First(d => d.ADR == 1 && d.POINT == 1);

            TimeOffset = (ulong)(firstTrack.PMIN * 60 * 75 + firstTrack.PSEC * 75 + firstTrack.PFRAME);
            TotalTime  = TimeOffset + image.Tracks.Last().TrackEndSector;

            Volume = App.Settings.Volume;

            Initialized = true;

            source.Start();
        }