Ejemplo n.º 1
0
        public static Sl2UserData ReadSl2UserData(Stream inputStream, byte[] key, int size, string name)
        {
            Sl2UserData sl2UserData = new Sl2UserData(key);

            sl2UserData.Name = name;
            sl2UserData.Read(inputStream, size);
            return(sl2UserData);
        }
Ejemplo n.º 2
0
        public void Read(Stream inputStream)
        {
            BinaryReader reader        = new BinaryReader(inputStream, Encoding.UTF8, true);
            BinaryReader unicodeReader = new BinaryReader(inputStream, Encoding.Unicode, true);
            string       signature     = reader.ReadString(4);

            if (signature != Sl2Signature)
            {
                throw new Exception("Unknown signature");
            }
            reader.Skip(8);
            int userDataCount = reader.ReadInt32();

            reader.Skip(8);
            string version            = reader.ReadString(8);
            int    directoryEntrySize = reader.ReadInt32();

            reader.Skip(4);
            int dataOffset = reader.ReadInt32();

            reader.Skip(20);

            // Directory section
            for (int i = 0; i < userDataCount; i++)
            {
                reader.Skip(8);
                int userDataSize = reader.ReadInt32();
                reader.Skip(4);

                int userDataOffset     = reader.ReadInt32();
                int userDataNameOffset = reader.ReadInt32();
                reader.Skip(8);


                long   position = reader.GetPosition();
                string fileName = "";
                if (userDataNameOffset > 0)
                {
                    reader.Seek(userDataNameOffset);
                    fileName = unicodeReader.ReadNullTerminatedString();
                }
                reader.Seek(userDataOffset);
                _userData.Add(Sl2UserData.ReadSl2UserData(inputStream, _key, userDataSize, fileName));
                reader.Seek(position);
            }
        }