Ejemplo n.º 1
0
            private void Reconstruct(byte[] secbuf, int type)
            {
                //sync
                secbuf[0] = 0;
                for (int i = 1; i <= 10; i++)
                {
                    secbuf[i] = 0xFF;
                }
                secbuf[11] = 0x00;

                //misc stuff
                switch (type)
                {
                case 1:
                    //mode 1
                    secbuf[15] = 0x01;
                    //reserved
                    for (int i = 0x814; i <= 0x81B; i++)
                    {
                        secbuf[i] = 0x00;
                    }
                    break;

                case 2:
                case 3:
                    //mode 2
                    secbuf[15] = 0x02;
                    //flags - apparently CD XA specifies two copies of these 4bytes of flags. ECM didnt store the first copy; so we clone the second copy which was stored down to the spot for the first copy.
                    secbuf[0x10] = secbuf[0x14];
                    secbuf[0x11] = secbuf[0x15];
                    secbuf[0x12] = secbuf[0x16];
                    secbuf[0x13] = secbuf[0x17];
                    break;
                }

                //edc
                switch (type)
                {
                case 1: ECM.PokeUint(secbuf, 0x810, ECM.EDC_Calc(secbuf, 0, 0x810)); break;

                case 2: ECM.PokeUint(secbuf, 0x818, ECM.EDC_Calc(secbuf, 16, 0x808)); break;

                case 3: ECM.PokeUint(secbuf, 0x92C, ECM.EDC_Calc(secbuf, 16, 0x91C)); break;
                }

                //ecc
                switch (type)
                {
                case 1: ECM.ECC_Populate(secbuf, 0, secbuf, 0, false); break;

                case 2: ECM.ECC_Populate(secbuf, 0, secbuf, 0, true); break;
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Synthesizes the complete ECM data (EDC + ECC) for a Mode 1 data sector (and puts it in place)
        /// Make sure everything else in the sector userdata is done before calling this
        /// </summary>
        public static void ECM_Mode1(byte[] buf2352, int offset, int LBA)
        {
            //EDC
            uint edc = ECM.EDC_Calc(buf2352, offset, 2064);

            ECM.PokeUint(buf2352, offset + 2064, edc);

            //reserved, zero
            for (int i = 0; i < 8; i++)
            {
                buf2352[offset + 2068 + i] = 0;
            }

            //ECC
            ECM.ECC_Populate(buf2352, offset, buf2352, offset, false);
        }