Exemplo n.º 1
0
        public DiscInspector Start(DetectedDiscType detectedDiscType)
        {
            // cue existance check
            if (discI.CuePath == null || !File.Exists(discI.CuePath))
            {
                return(discI);
            }

            //////////////////
            /* OtherFormats */
            //////////////////

            // discjuggler - currently only implemented for dreamcast CDI files
            if (IntenseScan)
            {
                if (Path.GetExtension(discI.CuePath).ToLower() == ".cdi")
                {
                    discI.DetectedDiscType = ScanDiscJuggler();

                    return(discI);
                }
            }


            // attempt to mount the disc
            try
            {
                disc = Disc.LoadAutomagic(discI.CuePath);
                if (disc == null)
                {
                    return(discI);
                }
            }
            catch { return(discI); }

            // detect disc mode
            discView = EDiscStreamView.DiscStreamView_Mode1_2048;
            if (disc.TOC.Session1Format == SessionFormat.Type20_CDXA)
            {
                discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048;
            }

            // biztools discident init
            di = new DiscIdentifier(disc);

            // try and mount it as an ISO
            isIso = iso.Parse(new DiscStream(disc, discView, 0));

            // if iso is mounted, populate data from volume descriptor(s) (at the moment just from the first one)
            if (isIso)
            {
                var vs = iso.VolumeDescriptors.Where(a => a != null).ToArray().First();

                // translate the vd
                discI.Data._ISOData          = PopulateISOData(vs);
                discI.Data._ISOData.ISOFiles = iso.Root.Children;
                ifn = null;
            }

            // populate basic disc data
            int dataTracks  = 0;
            int audioTracks = 0;

            foreach (var t in disc.Structure.Sessions.Where(a => a != null))
            {
                for (int i = 0; i < t.Tracks.Count(); i++)
                {
                    if (t.Tracks[i].IsData == true)
                    {
                        dataTracks++;
                        continue;
                    }

                    if (t.Tracks[i].IsAudio == true)
                    {
                        audioTracks++;
                        continue;
                    }
                }
            }

            discI.Data.TotalAudioTracks = audioTracks;
            discI.Data.TotalDataTracks  = dataTracks;
            discI.Data.TotalTracks      = audioTracks + dataTracks;

            discI.DiscStructure = disc.Structure;

            // do actual interrogation
            switch (detectedDiscType)
            {
            case DetectedDiscType.UnknownFormat:
            case DetectedDiscType.UnknownCDFS:
                discI.DetectedDiscType = InterrogateALL();
                break;

            default:
                discI.DetectedDiscType = InterrogateSpecific(detectedDiscType);
                break;
            }


            discI.DiscTypeString = discI.DetectedDiscType.ToString();
            discI.DiscViewString = discView.ToString();

            return(discI);
        }
Exemplo n.º 2
0
        /// <summary>
        /// returns the PSX serial - Bizhawk DiscSystem requires either cue, ccd or iso (not bin or img)
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string GetPSXSerial(string path)
        {
            //path = @"G:\_Emulation\PSX\iso\Metal Gear Solid - Integral (J) [SLPM-86247]\Metal Gear Solid - Integral (J) (Disc 1) [SLPM-86247].cue";

            int  lba  = 23;
            Disc disc = Disc.LoadAutomagic(path);

            if (disc == null)
            {
                // unable to mount disc - return null
                return(null);
            }

            var discView = EDiscStreamView.DiscStreamView_Mode1_2048;

            if (disc.TOC.Session1Format == SessionFormat.Type20_CDXA)
            {
                discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048;
            }

            var  iso   = new ISOFile();
            bool isIso = iso.Parse(new DiscStream(disc, discView, 0));

            if (isIso)
            {
                var appId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' ');

                var desc = iso.Root.Children;

                ISONode ifn = null;

                foreach (var i in desc)
                {
                    if (i.Key.Contains("SYSTEM.CNF"))
                    {
                        ifn = i.Value;
                    }
                }

                if (ifn == null)
                {
                    lba = 23;
                }
                else
                {
                    lba = Convert.ToInt32(ifn.Offset);
                }
            }
            else
            {
                lba = 23;
            }


            DiscIdentifier di = new DiscIdentifier(disc);

            // start by checking sector 23 (as most discs seem to have system.cfg there
            byte[] data = di.GetPSXSerialNumber(lba);
            // take first 32 bytes
            byte[] data32 = data.ToList().Take(46).ToArray();

            string sS = System.Text.Encoding.Default.GetString(data32);

            if (!sS.Contains("cdrom:"))
            {
                return(null);
            }

            // get the actual serial number from the returned string
            string[] arr    = sS.Split(new string[] { "cdrom:" }, StringSplitOptions.None);
            string[] arr2   = arr[1].Split(new string[] { ";1" }, StringSplitOptions.None);
            string   serial = arr2[0].Replace("_", "-").Replace(".", "");

            if (serial.Contains("\\"))
            {
                serial = serial.Split('\\').Last();
            }
            else
            {
                serial = serial.TrimStart('\\').TrimStart('\\');
            }

            // try and remove any nonsense after the serial
            string[] sarr2 = serial.Split('\r');
            if (sarr2.Length > 1)
            {
                serial = sarr2.First();
            }

            return(serial);
        }
Exemplo n.º 3
0
        public static string GetSaturnSerial(string cuePath)
        {
            if (!File.Exists(cuePath))
            {
                return("");
            }

            int  lba  = 0;
            Disc disc = Disc.LoadAutomagic(cuePath);

            if (disc == null)
            {
                // unable to mount disc - return null
                return("");
            }

            var discView = EDiscStreamView.DiscStreamView_Mode1_2048;

            if (disc.TOC.Session1Format == SessionFormat.Type20_CDXA)
            {
                discView = EDiscStreamView.DiscStreamView_Mode2_Form1_2048;
            }

            var  iso   = new ISOFile();
            bool isIso = iso.Parse(new DiscStream(disc, discView, 0));

            /*
             * if (isIso)
             * {
             *  var appId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' ');
             *
             *  var desc = iso.Root.Children;
             *
             *  ISONode ifn = null;
             *
             *  foreach (var i in desc)
             *  {
             *      if (i.Key.Contains("SYSTEM.CNF"))
             *          ifn = i.Value;
             *  }
             *
             *  if (ifn == null)
             *  {
             *      lba = 23;
             *  }
             *  else
             *  {
             *      lba = Convert.ToInt32(ifn.Offset);
             *  }
             * }
             * else
             * {
             *  lba = 23;
             * }
             *
             */

            DiscIdentifier di = new DiscIdentifier(disc);

            // start at lba 0 (saturn header information is usually there)
            byte[] data = di.GetPSXSerialNumber(lba);

            Dictionary <int, string> sDict = new Dictionary <int, string>();

            DiscData sd = new DiscData();

            for (int i = 0; i < 8; i++)
            {
                int    blockSize = 32;
                byte[] data32    = data.ToList().Skip(i * (blockSize)).Take(blockSize).ToArray();
                string sS        = System.Text.Encoding.Default.GetString(data32);
                sDict.Add(i, sS);
            }



            return("");
        }