Пример #1
0
        public MemoryStream ToPsb(Stream stream, Dictionary <string, object> context = null)
        {
            int size = 0;

            if (context != null)
            {
                if (context.ContainsKey(Context_MdfKey))
                {
                    uint?keyLength = context.ContainsKey(Context_MdfKeyLength)
                        ? Convert.ToUInt32(context[Context_MdfKeyLength])
                        : (uint?)null;
                    stream = EncodeMdf(stream, (string)context[Context_MdfKey], keyLength);
                }

                var pos = stream.Position;
                stream.Seek(4, SeekOrigin.Current);
                var bytes = new byte[4];
                stream.Read(bytes, 0, 4);
                if (FastMode)
                {
                    size = BitConverter.ToInt32(bytes, 0);
                }
                stream.Seek(1, SeekOrigin.Current);
                context[Context_PsbZlibFastCompress] = stream.ReadByte() == (byte)0x9C;
                stream.Position = pos;
            }

            return(MdfFile.DecompressToPsbStream(stream, size) as MemoryStream);
        }
Пример #2
0
        public MemoryStream ToPsb(Stream stream, Dictionary <string, object> context = null)
        {
            if (context != null)
            {
                if (context.ContainsKey(MdfKey))
                {
                    uint?keyLength = context.ContainsKey(MdfKeyLength) ? (uint)context[MdfKeyLength] : (uint?)null;
                    stream = EncodeMdf(stream, (string)context[MdfKey], keyLength);
                }

                var pos = stream.Position;
                stream.Seek(9, SeekOrigin.Current);
                context[FreeMount.PsbZlibFastCompress] = stream.ReadByte() == (byte)0x9C;
                stream.Position = pos;
            }

            return(MdfFile.DecompressToPsbStream(stream) as MemoryStream);
        }
Пример #3
0
        public void TestMdf()
        {
            var resPath = Path.Combine(Environment.CurrentDirectory, @"..\..\Res");
            var path    = Path.Combine(resPath, "e-mote38_free.mmo");
            //var path = Path.Combine(resPath, "e-mote38_free.mmo-repack.mmo");
            var path2 = Path.Combine(resPath, "emote38-pure.mmo");

            MdfFile.CompressPsbToMdfStream(File.OpenRead(path2)).CopyTo(File.Create(path + "-repack.mmo"));

            using (var mdfStream = File.OpenRead(path))
            {
                using (var psbStream = MdfFile.DecompressToPsbStream(mdfStream))
                {
                    //using (var pureStream = new MemoryStream((int)psbStream.Length))
                    {
                        //PsbFile.Encode(key, EncodeMode.Decrypt, EncodePosition.Auto, psbStream, pureStream);
                        PSB psb = new PSB(psbStream);
                        psb.SaveAsMdfFile(path + "-build.mmo");
                    }
                }
            }
        }