コード例 #1
0
        private static byte[] GenerateJunk(uint i, gcm_info g_i)
        {
            uint seed       = 0;
            uint blockcount = i * 8 * 0x1ef29123;

            byte[] JunkSector = new byte[0x40000];

            using (BinaryWriter mw = new BinaryWriter(new MemoryStream(JunkSector)))
            {
                while (mw.BaseStream.Position != mw.BaseStream.Length)
                {
                    if ((mw.BaseStream.Position & 0x00007fff) == 0)
                    {
                        seed = (((((uint)g_i.id[2] << 8) | g_i.id[1]) << 16) | ((uint)(g_i.id[3] + g_i.id[2]) << 8)) | (uint)(g_i.id[0] + g_i.id[1]);
                        seed = ((seed ^ g_i.disc_number) * 0x260bcd5) ^ blockcount;
                        init_rnd(seed);
                        blockcount += 0x1ef29123;
                    }

                    byte[] result = scramble(irnd());

                    mw.Write(result);
                }
            }
            return(JunkSector);
        }
コード例 #2
0
        private static gcm_info GetGcmInfo(string arg)
        {
            gcm_info temp = new gcm_info();

            using (BinaryReader br = new BinaryReader(new FileStream(arg, FileMode.Open)))
            {
                temp.id          = br.ReadBytes(6);
                temp.disc_number = br.ReadByte();
            }
            return(temp);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                if (CheckGCM(arg))
                {
                    type.dec = 0;
                    type.enc = 0;

                    gcm_info g_i = GetGcmInfo(arg);

                    using (BinaryReader br = new BinaryReader(new FileStream(arg, FileMode.Open)))
                    {
                        using (BinaryWriter bw = new BinaryWriter(new FileStream("temp_gcm", FileMode.Create)))
                        {
                            uint sector_number = 0;
                            while (br.BaseStream.Position != br.BaseStream.Length)
                            {
                                int read_length = ((int)(br.BaseStream.Length - br.BaseStream.Position) >= 0x40000) ? 0x40000 : (int)(br.BaseStream.Length - br.BaseStream.Position);

                                byte[] array1 = br.ReadBytes(read_length);
                                byte[] array2 = GenerateJunk(sector_number++, g_i);

                                switch (CompareArrays(array1, array2))
                                {
                                case 0:
                                    bw.Write(array1);
                                    break;

                                case 1:
                                    bw.Write(junk);
                                    break;

                                case 2:
                                    bw.Write(array2);
                                    break;
                                }

                                Console.Write(string.Format("\r{0}%", (Math.Round((((double)sector_number / 5570.0) * 100), 0).ToString())));
                            }
                        }
                    }

                    string arg_new = CreateName(arg);
                    File.Move("temp_gcm", arg_new);
                }
            }
        }