Пример #1
0
        public byte[] Write()
        {
            MemoryStream       m  = new MemoryStream();
            EndianBinaryWriter er = new EndianBinaryWriter(m, Endianness.LittleEndian);

            Header.Write(er);
            long curpos = er.BaseStream.Position;

            er.BaseStream.Position = 0x18;
            er.Write((uint)curpos);
            er.BaseStream.Position = curpos;
            Info.Write(er);

            long length = er.BaseStream.Position - curpos;

            curpos = er.BaseStream.Position;
            er.BaseStream.Position = 0x1C;
            er.Write((uint)length);
            er.BaseStream.Position = 0x24;
            er.Write((uint)curpos);
            er.BaseStream.Position = curpos;
            if (Seek != null)
            {
                Seek.Write(er);
                length = er.BaseStream.Position - curpos;
                curpos = er.BaseStream.Position;
                er.BaseStream.Position = 0x28;
                er.Write((uint)length);
                er.BaseStream.Position = 0x30;
                er.Write((uint)curpos);
                er.BaseStream.Position = curpos;
                Data.Write(er);
                length = er.BaseStream.Position - curpos;
                curpos = er.BaseStream.Position;
                er.BaseStream.Position = 0x34;
                er.Write((uint)length);
                er.BaseStream.Position = curpos;
            }
            else
            {
                Data.Write(er);
                length = er.BaseStream.Position - curpos;
                curpos = er.BaseStream.Position;
                er.BaseStream.Position = 0x28;
                er.Write((uint)length);
                er.BaseStream.Position = curpos;
            }
            curpos = er.BaseStream.Position;
            er.BaseStream.Position = 0xC;
            er.Write((uint)curpos);
            byte[] result = m.ToArray();
            er.Close();
            return(result);
        }