Exemplo n.º 1
0
    private static Byte[] ReadUtfPacket(IBinaryStream reader)
    {
        var unknown = reader.ReadUInt32LE(); // 0x000000FF

        if (unknown != 0x00000FFU)
        {
            Console.WriteLine($"Unknown u32 {unknown} != 0x000000FF");
        }
        var size = reader.ReadInt64LE();

        if (size > int.MaxValue)
        {
            throw new InvalidDataException($"Too large UTF size {size}");
        }
        var utf = reader.ReadBytesExact((int)size);

        if (!utf.Take(4).SequenceEqual(UtfTag))
        {
            DecryptInPlace(utf);
        }
        return(utf);
    }