Exemplo n.º 1
0
        public DiscStream(Disc disc, EDiscStreamView view, int from_lba)
        {
            SectorSize = 2048;
            Disc       = disc;
            NumSectors = disc.Session1.LeadoutLBA;
            dsr        = new DiscSectorReader(disc);

            //following the provided view
            switch (view)
            {
            case EDiscStreamView.DiscStreamView_Mode1_2048:
                dsr.Policy.UserData2048Mode = DiscSectorReaderPolicy.EUserData2048Mode.AssumeMode1;
                break;

            case EDiscStreamView.DiscStreamView_Mode2_Form1_2048:
                dsr.Policy.UserData2048Mode = DiscSectorReaderPolicy.EUserData2048Mode.AssumeMode2_Form1;
                break;

            default:
                throw new NotSupportedException("Unsupported EDiscStreamView");
            }


            currPosition       = from_lba * SectorSize;
            cachedSector       = -1;
            cachedSectorBuffer = new byte[SectorSize];
        }
Exemplo n.º 2
0
        public DiscIdentifier(Disc disc)
        {
            this.disc = disc;
            dsr       = new DiscSectorReader(disc);

            //the first check for mode 0 should be sufficient for blocking attempts to read audio sectors, so dont do this
            //dsr.Policy.ThrowExceptions2048 = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// calculates the complete disc hash for matching to a redump
        /// </summary>
        public uint Calculate_PSX_RedumpHash()
        {
            //a special CRC32 is used to help us match redump's DB
            SpecialCRC32 crc = new SpecialCRC32();

            byte[] buffer2352 = new byte[2352];

            var dsr = new DiscSectorReader(disc);

            dsr.Policy.DeterministicClearBuffer = false; //live dangerously

            //read all sectors for redump hash
            for (int i = 0; i < disc.Session1.LeadoutLBA; i++)
            {
                dsr.ReadLBA_2352(i, buffer2352, 0);
                crc.Add(buffer2352, 0, 2352);
            }

            return(crc.Result);
        }
Exemplo n.º 4
0
        // gets an identifying hash. hashes the first 512 sectors of
        // the first data track on the disc.
        //TODO - this is a very platform-specific thing. hashing the TOC may be faster and be just as effective. so, rename it appropriately
        public string OldHash()
        {
            byte[]           buffer = new byte[512 * 2352];
            DiscSectorReader dsr    = new DiscSectorReader(disc);

            foreach (var track in disc.Session1.Tracks)
            {
                if (track.IsAudio)
                {
                    continue;
                }

                int lba_len = Math.Min(track.NextTrack.LBA, 512);
                for (int s = 0; s < 512 && s < lba_len; s++)
                {
                    dsr.ReadLBA_2352(track.LBA + s, buffer, s * 2352);
                }

                return(buffer.HashMD5(0, lba_len * 2352));
            }
            return("no data track found");
        }
Exemplo n.º 5
0
        /// <summary>
        /// calculates the hash for quick PSX Disc identification
        /// </summary>
        public uint Calculate_PSX_BizIDHash()
        {
            //notes about the hash:
            //"Arc the Lad II (J) 1.0 and 1.1 conflict up to 25 sectors (so use 26)
            //Tekken 3 (Europe) (Alt) and Tekken 3 (Europe) conflict in track 2 and 3 unfortunately, not sure what to do about this yet
            //the TOC isn't needed!
            //but it will help detect dumps with mangled TOCs which are all too common
            //
            //a possibly special CRC32 is used to help us match redump's DB elsewhere

            SpecialCRC32 crc = new SpecialCRC32();

            byte[] buffer2352 = new byte[2352];

            var dsr = new DiscSectorReader(disc);

            dsr.Policy.DeterministicClearBuffer = false; //live dangerously

            //hash the TOC
            crc.Add((int)disc.TOC.Session1Format);
            crc.Add(disc.TOC.FirstRecordedTrackNumber);
            crc.Add(disc.TOC.LastRecordedTrackNumber);
            for (int i = 1; i <= 100; i++)
            {
                //if (disc.TOC.TOCItems[i].Exists) Console.WriteLine("{0:X8} {1:X2} {2:X2} {3:X8}", crc.Current, (int)disc.TOC.TOCItems[i].Control, disc.TOC.TOCItems[i].Exists ? 1 : 0, disc.TOC.TOCItems[i].LBATimestamp.Sector); //a little debugging
                crc.Add((int)disc.TOC.TOCItems[i].Control);
                crc.Add(disc.TOC.TOCItems[i].Exists ? 1 : 0);
                crc.Add((int)disc.TOC.TOCItems[i].LBA);
            }

            //hash first 26 sectors
            for (int i = 0; i < 26; i++)
            {
                dsr.ReadLBA_2352(i, buffer2352, 0);
                crc.Add(buffer2352, 0, 2352);
            }

            return(crc.Result);
        }