コード例 #1
0
ファイル: RgssFileStream.cs プロジェクト: qipa/RGSS-Decryptor
 public RgssFileStream(RgssFilePointer fp)
 {
     _fileStream = File.OpenRead(fp.Source.DataPath);
     _decKey     = new RgssDecryptionKey(7, 3);
     _decKey.PushState(fp.Key);
     _fileRange = new RangeStream(_fileStream, fp.Offset, fp.Size);
 }
コード例 #2
0
        public RgssArchiveV3(string path) : base(path)
        {
            using (var fs = File.OpenRead(path))
            {
                switch (CheckVersion(path, 3))
                {
                case -1:
                    throw new InvalidDataException("Invalid RGSS Data");

                case 0:
                    throw new InvalidDataException("Invalid RGSSAD Version");

                case 1:
                default:
                    break;
                }
                using (var br = new BinaryReader(fs))
                {
                    fs.Position = 8;
                    var dKey = new RgssDecryptionKey(9, 3);
                    dKey.PushState(br.ReadUInt32());
                    dKey.Step();

                    while (true)
                    {
                        var fp = new RgssFilePointer();

                        fp.Offset = ReadEncryptedInt(br, dKey);
                        if (fp.Offset == 0)
                        {
                            break;
                        }

                        fp.Source = this;
                        fp.Size   = ReadEncryptedInt(br, dKey);
                        fp.Key    = (uint)ReadEncryptedInt(br, dKey);
                        fp.Name   = ReadEncryptedString(br, dKey);

                        FilePointers.Add(fp);
                    }
                }
            }
        }
コード例 #3
0
        public RgssArchiveV1(string path) : base(path)
        {
            using (var fs = File.OpenRead(path))
            {
                switch (CheckVersion(path, 1))
                {
                case -1:
                    throw new InvalidDataException("Invalid RGSS Data");

                case 0:
                    throw new InvalidDataException("Invalid RGSSAD Version");

                case 1:
                default:
                    break;
                }
                using (var br = new BinaryReader(fs))
                {
                    fs.Position = 8;
                    var dKey = new RgssDecryptionKey(7, 3);
                    dKey.PushState(0xDEADCAFE);

                    while (fs.Length - fs.Position > 0)
                    {
                        var fp = new RgssFilePointer();

                        fp.Source    = this;
                        fp.Name      = ReadEncryptedString(br, dKey);
                        fp.Size      = ReadEncryptedInt(br, dKey);
                        fp.Offset    = fs.Position;
                        fp.Key       = dKey.Current();
                        fs.Position += fp.Size;

                        FilePointers.Add(fp);
                    }
                }
            }
        }
コード例 #4
0
ファイル: RgssArchive.cs プロジェクト: qipa/RGSS-Decryptor
 public static Stream GetFile(RgssFilePointer fp)
 {
     return(new RgssFileStream(fp));
 }