Пример #1
0
        public RPF7File(Stream inputStream, String filname = "")
        {
            this.Filename = filname;
            Stream = inputStream;

            Info = new Structs.RPF7Header(Stream);

            if (new string(Info.Magic) != "RPF7")
            {
                throw new Exception("Invalid RPF Magic");
            }

            sixteenRoundsDecrypt = (Info.Flag >> 28) == 0xf;

            if (sixteenRoundsDecrypt)
            {
                throw new Exception("Needed to be tested first");
            }

            using (BinaryReader binaryStream = new BinaryReader(AES.DecryptStream(new StreamKeeper(this.Stream), sixteenRoundsDecrypt)))
            {
                MemoryStream entriesInfo = new MemoryStream(binaryStream.ReadBytes(0x10 * Info.EntriesCount));
                MemoryStream filenames = new MemoryStream(binaryStream.ReadBytes(Info.EntriesNamesLength));
                this.Root = Entry.CreateFromHeader(new Structs.RPF7EntryInfoTemplate(entriesInfo), this, entriesInfo, filenames);
            }

            if (!(this.Root is DirectoryEntry))
            {
                throw new Exception("Expected root to be directory");
            }
        }
Пример #2
0
        public RPF7File(Stream inputStream, String filname = "")
        {
            this.Filename = filname;
            Stream        = inputStream;

            Info = new Structs.RPF7Header(Stream);

            if (new string(Info.Magic) != "RPF7")
            {
                throw new Exception("Invalid RPF Magic");
            }

            sixteenRoundsDecrypt = (Info.Flag >> 28) == 0xf;

            if (sixteenRoundsDecrypt)
            {
                throw new Exception("Needed to be tested first");
            }

            using (BinaryReader binaryStream = new BinaryReader(AES.DecryptStream(new StreamKeeper(this.Stream), sixteenRoundsDecrypt)))
            {
                MemoryStream entriesInfo = new MemoryStream(binaryStream.ReadBytes(0x10 * Info.EntriesCount));
                MemoryStream filenames   = new MemoryStream(binaryStream.ReadBytes(Info.EntriesNamesLength));
                this.Root = Entry.CreateFromHeader(new Structs.RPF7EntryInfoTemplate(entriesInfo), this, entriesInfo, filenames);
            }


            if (!(this.Root is DirectoryEntry))
            {
                throw new Exception("Expected root to be directory");
            }
        }