コード例 #1
0
        private static bool TestBodyEncrypted(BinaryReader br, PsbHeader header)
        {
            //MARK: Not always works
            long pos = br.BaseStream.Position;

            switch (header.Version)
            {
            case 2:
            case 3:
            case 4:
                br.BaseStream.Seek(header.GetHeaderLength(), SeekOrigin.Begin);
                break;

            default:
                br.BaseStream.Seek(header.OffsetNames, SeekOrigin.Begin);
                break;
            }
            if (br.ReadByte() == 0x0E)                          //Type == ArrayN2
            {
                br.ReadBytes(2);                                //Array Length
                var entryLength = br.ReadByte();                //Entry Length
                if (entryLength == 0x0E || entryLength == 0x0D) //EntryLength == 1 || 2
                {
                    br.BaseStream.Seek(pos, SeekOrigin.Begin);
                    return(false);
                }
            }
            br.BaseStream.Seek(pos, SeekOrigin.Begin);
            return(true);
        }
コード例 #2
0
        public static bool TestBodyEncrypted(BinaryReader br, PsbHeader header)
        {
            //MARK: Not always works
            var pos = br.BaseStream.Position;

            switch (header.Version)
            {
            case 2:
            case 3:
            case 4:
                br.BaseStream.Seek(header.GetHeaderLength(), SeekOrigin.Begin);
                break;

            default:
                br.BaseStream.Seek(header.OffsetNames, SeekOrigin.Begin);
                break;
            }

            var        arrayType    = br.ReadByte();
            const byte arrayN0      = 0x0C;
            const byte arrayMaxSize = 4;
            const byte entryMaxSize = 4;

            if (arrayType > arrayN0 && arrayType <= arrayN0 + arrayMaxSize)         //ArrayN4 >= Type >= ArrayN1
            {
                br.ReadBytes(arrayType - arrayN0);                                  //Array Length
                var entryLength = br.ReadByte();                                    //Entry Length
                if (entryLength > arrayN0 && entryLength <= arrayN0 + entryMaxSize) //EntryLength == 1 || 2
                {
                    br.BaseStream.Seek(pos, SeekOrigin.Begin);
                    return(false);
                }
            }

            br.BaseStream.Seek(pos, SeekOrigin.Begin);
            return(true);
        }