Example #1
0
        Stream OpenT5(EmeArchive arc, EmEntry entry)
        {
            var header = arc.File.View.ReadBytes(entry.Offset, 4);

            Decrypt(header, 0, 4, arc.Key);
            var input = arc.File.CreateStream(entry.Offset + 4, entry.Size - 4);

            return(new PrefixStream(header, input));
        }
Example #2
0
        Stream OpenScript(EmeArchive arc, EmEntry entry)
        {
            var header = arc.File.View.ReadBytes(entry.Offset, 12);

            Decrypt(header, 0, 12, arc.Key);
            if (0 == entry.LzssFrameSize)
            {
                var input = arc.File.CreateStream(entry.Offset + 12, entry.Size);
                return(new PrefixStream(header, input));
            }
            int unpacked_size = LittleEndian.ToInt32(header, 4);

            if (0 != unpacked_size)
            {
                uint packed_size = LittleEndian.ToUInt32(header, 0);
                int  part1_size  = (int)entry.UnpackedSize - unpacked_size;
                var  data        = new byte[entry.UnpackedSize];
                using (var input = arc.File.CreateStream(entry.Offset + 12 + packed_size, entry.Size))
                    using (var lzss = new LzssStream(input))
                    {
                        lzss.Config.FrameSize    = entry.LzssFrameSize;
                        lzss.Config.FrameInitPos = entry.LzssInitPos;
                        lzss.Read(data, 0, part1_size);
                    }
                using (var input = arc.File.CreateStream(entry.Offset + 12, packed_size))
                    using (var lzss = new LzssStream(input))
                    {
                        lzss.Config.FrameSize    = entry.LzssFrameSize;
                        lzss.Config.FrameInitPos = entry.LzssInitPos;
                        lzss.Read(data, part1_size, unpacked_size);
                    }
                return(new MemoryStream(data));
            }
            else
            {
                var input = arc.File.CreateStream(entry.Offset + 12, entry.Size);
                var lzss  = new LzssStream(input);
                lzss.Config.FrameSize    = entry.LzssFrameSize;
                lzss.Config.FrameInitPos = entry.LzssInitPos;
                return(lzss);
            }
        }
Example #3
0
        Stream OpenImage(EmeArchive arc, EmEntry entry)
        {
            var header = new byte[40];

            Encoding.ASCII.GetBytes("EMBM", 0, 4, header, 0);
            LittleEndian.Pack((ushort)entry.LzssFrameSize, header, 4);
            LittleEndian.Pack((ushort)entry.LzssInitPos, header, 6);
            arc.File.View.Read(entry.Offset, header, 8, 32);
            Decrypt(header, 8, 32, arc.Key);
            uint entry_size = entry.Size;
            uint colors     = LittleEndian.ToUInt16(header, 14);

            if (0 != colors && header[0] != 7)
            {
                entry_size += Math.Max(colors, 3u) * 4;
            }
            var input = arc.File.CreateStream(entry.Offset + 32, entry_size);

            return(new PrefixStream(header, input));
        }
Example #4
0
 Stream OpenT5(EmeArchive arc, EmEntry entry)
 {
     var header = arc.File.View.ReadBytes (entry.Offset, 4);
     Decrypt (header, 0, 4, arc.Key);
     var input = arc.File.CreateStream (entry.Offset+4, entry.Size-4);
     return new PrefixStream (header, input);
 }
Example #5
0
 Stream OpenScript(EmeArchive arc, EmEntry entry)
 {
     var header = arc.File.View.ReadBytes (entry.Offset, 12);
     Decrypt (header, 0, 12, arc.Key);
     if (0 == entry.LzssFrameSize)
     {
         var input = arc.File.CreateStream (entry.Offset+12, entry.Size);
         return new PrefixStream (header, input);
     }
     int unpacked_size = LittleEndian.ToInt32 (header, 4);
     if (0 != unpacked_size)
     {
         uint packed_size = LittleEndian.ToUInt32 (header, 0);
         int part1_size = (int)entry.UnpackedSize - unpacked_size;
         var data = new byte[entry.UnpackedSize];
         using (var input = arc.File.CreateStream (entry.Offset+12+packed_size, entry.Size))
         using (var lzss = new LzssStream (input))
         {
             lzss.Config.FrameSize = entry.LzssFrameSize;
             lzss.Config.FrameInitPos = entry.LzssInitPos;
             lzss.Read (data, 0, part1_size);
         }
         using (var input = arc.File.CreateStream (entry.Offset+12, packed_size))
         using (var lzss = new LzssStream (input))
         {
             lzss.Config.FrameSize = entry.LzssFrameSize;
             lzss.Config.FrameInitPos = entry.LzssInitPos;
             lzss.Read (data, part1_size, unpacked_size);
         }
         return new MemoryStream (data);
     }
     else
     {
         var input = arc.File.CreateStream (entry.Offset+12, entry.Size);
         var lzss = new LzssStream (input);
         lzss.Config.FrameSize = entry.LzssFrameSize;
         lzss.Config.FrameInitPos = entry.LzssInitPos;
         return lzss;
     }
 }
Example #6
0
 Stream OpenImage(EmeArchive arc, EmEntry entry)
 {
     var header = new byte[40];
     Encoding.ASCII.GetBytes ("EMBM", 0, 4, header, 0);
     LittleEndian.Pack ((ushort)entry.LzssFrameSize, header, 4);
     LittleEndian.Pack ((ushort)entry.LzssInitPos, header, 6);
     arc.File.View.Read (entry.Offset, header, 8, 32);
     Decrypt (header, 8, 32, arc.Key);
     uint entry_size = entry.Size;
     uint colors = LittleEndian.ToUInt16 (header, 14);
     if (0 != colors && header[0] != 7)
         entry_size += Math.Max (colors, 3u) * 4;
     var input = arc.File.CreateStream (entry.Offset+32, entry_size);
     return new PrefixStream (header, input);
 }