Exemplo n.º 1
0
        public MemoryStream ToShell(Stream stream, Dictionary <string, object> context = null)
        {
            bool fast = true; //mdf use fast mode by default

            if (context != null && context.ContainsKey(Context_PsbZlibFastCompress))
            {
                fast = (bool)context[Context_PsbZlibFastCompress];
            }

            var ms = MdfFile.CompressPsbToMdfStream(stream, fast) as MemoryStream;

            if (context != null && context.ContainsKey(Context_MdfKey))
            {
                uint?keyLength;
                if (context.ContainsKey(Context_MdfKeyLength))
                {
                    keyLength = Convert.ToUInt32(context[Context_MdfKeyLength]);
                }
                else
                {
                    keyLength = (uint?)null;
                }

                ms = EncodeMdf(ms, (string)context[Context_MdfKey], keyLength);
            }

            return(ms);
        }
Exemplo n.º 2
0
        public MemoryStream ToShell(Stream stream, Dictionary <string, object> context = null)
        {
            bool fast = true; //mdf use fast mode by default

            if (context != null && context.ContainsKey(FreeMount.PsbZlibFastCompress))
            {
                fast = (bool)context[FreeMount.PsbZlibFastCompress];
            }

            var ms = MdfFile.CompressPsbToMdfStream(stream, fast) as MemoryStream;

            if (context != null && context.ContainsKey(MdfKey))
            {
                uint?keyLength = context.ContainsKey(MdfKeyLength) ? (uint)context[MdfKeyLength] : (uint?)null;
                ms = EncodeMdf(ms, (string)context[MdfKey], keyLength);
            }

            return(ms);
        }
Exemplo n.º 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");
                    }
                }
            }
        }