예제 #1
0
        public ArcContainer(Reader reader)
        {
            string FileName = System.IO.Path.GetFileNameWithoutExtension(reader.GetFilename());

            if (!reader.ReadBytes(4).SequenceEqual(MAGIC))
            {
                Console.WriteLine("This isn't an ARC file! aborting!");
                return;
            }

            ushort Filecount = reader.ReadUInt16();

            byte[] FileData = reader.ReadBytes(0x28 * Filecount);

            ARCKey = Filecount;

            for (int f = 0; f < Filecount; f++)
            {
                FileInfo file     = new FileInfo();
                byte[]   FilePtr  = new byte[4];
                byte[]   FilePtr2 = new byte[4];
                for (int i = 0; i < 0x28; i++)
                {
                    byte Buffer        = FileData[i + (f * 0x28)];
                    byte DecryptedByte = (byte)(DecryptARCFileInfo() % 0xFF ^ Buffer);
                    if (i < 32)
                    {
                        file.Name += (char)DecryptedByte;
                    }
                    else if (i >= 32 && i < 36)
                    {
                        FilePtr[i - 32] = DecryptedByte;
                    }
                    else
                    {
                        FilePtr2[i - 36] = DecryptedByte;
                    }
                }
                file.Name     = file.Name.Replace("\0", "");
                file.Offset   = BitConverter.ToInt32(FilePtr, 0);
                file.FileSize = BitConverter.ToInt32(FilePtr2, 0);
                long ReadPos = reader.BaseStream.Position;
                reader.Seek(file.Offset, SeekOrigin.Begin);
                file.FileData = reader.ReadBytes(file.FileSize);
                reader.Seek(ReadPos, SeekOrigin.Begin);
                Files.Add(file);
            }

            reader.Close();
        }