예제 #1
0
        public static long HashWAR(string s)
        {
            uint ph = 0;
            uint sh = 0;

            MYP.HashWAR(s, 3735928559U, out ph, out sh);
            return(((long)ph << 32) + (long)sh);
        }
예제 #2
0
        public byte[] ReadFile(string name)
        {
            long key = MYP.HashWAR(name);

            if (this.Enteries.ContainsKey(key))
            {
                return(this.ReadFile(this.Enteries[key]));
            }
            return((byte[])null);
        }
예제 #3
0
 public void Load(MYP archive, BinaryReader reader, int index)
 {
     this.Archive          = archive;
     this.MFTEntryOffset   = reader.BaseStream.Position;
     this.MFTEntryIndex    = index;
     this.Offset           = reader.ReadUInt64();
     this.HeaderSize       = reader.ReadUInt32();
     this.CompressedSize   = reader.ReadUInt32();
     this.UnCompressedSize = reader.ReadUInt32();
     this.Hash             = reader.ReadInt64();
     this.CRC32            = reader.ReadUInt32();
     this.Compressed       = reader.ReadByte();
     this.Unk1             = reader.ReadByte();
 }
예제 #4
0
        public Stream GetAssetStream(string assetName)
        {
            long hash = MYP.HashWAR(assetName);

            foreach (var myp in Archives.Values)
            {
                if (myp.Enteries.ContainsKey(hash))
                {
                    return(new MemoryStream(GetAsset(myp.Enteries[hash])));
                }
            }

            return(null);
        }
예제 #5
0
        public bool HasAsset(string assetName)
        {
            long hash = MYP.HashWAR(assetName);

            foreach (var myp in Archives.Values)
            {
                if (myp.Enteries.ContainsKey(hash))
                {
                    return(true);
                }
            }

            return(false);
        }
            public void Load(MYP archive, BinaryReader reader, int index)
            {
                Archive        = archive;
                MFTEntryOffset = reader.BaseStream.Position;
                MFTEntryIndex  = index;

                Offset           = reader.ReadUInt64();
                HeaderSize       = reader.ReadUInt32();
                CompressedSize   = reader.ReadUInt32();
                UnCompressedSize = reader.ReadUInt32();
                Hash             = reader.ReadInt64();
                CRC32            = reader.ReadUInt32();
                Compressed       = reader.ReadByte();
                Unk1             = reader.ReadByte();
            }
예제 #7
0
        public MYPManager(string folder)
        {
            foreach (string file in Directory.GetFiles(folder, "*.myp"))
            {
                string name = Path.GetFileNameWithoutExtension(file).ToUpper();


                MythicPackage package = MythicPackage.ART;

                if (Enum.TryParse(name, out package))
                {
                    var stream = File.Open(file, FileMode.Open, FileAccess.Read);
                    Archives[package] = new MYP(package, stream);
                }
            }
        }
예제 #8
0
        public void AddEntries(List <Tuple <string, byte[]> > files)
        {
            this._stream.Position = 24L;
            BinaryWriter binaryWriter = new BinaryWriter(this._stream);

            binaryWriter.Write((long)(uint)this.Enteries.Count + (long)files.Count);
            if (this.MFTTables.Count > 0)
            {
                this._stream.Position = this.MFTTables.Last <MYP.MFTHeader>().Offset + 4L;
                binaryWriter.Write((ulong)binaryWriter.BaseStream.Length);
            }
            binaryWriter.BaseStream.Position = binaryWriter.BaseStream.Length;
            int index1 = 0;
            List <MYP.MFTEntry> mftEntryList = new List <MYP.MFTEntry>();
            int  count = files.Count;
            long num1  = 0;

            while (count > 0)
            {
                binaryWriter.Write(1000U);
                if (files.Count - index1 > 1000)
                {
                    num1 = this._stream.Position;
                    binaryWriter.Write(0L);
                }
                else
                {
                    binaryWriter.Write(0L);
                }
                for (int index2 = 0; index2 < 1000; ++index2)
                {
                    if (index1 < files.Count)
                    {
                        --count;
                        MYP.MFTEntry mftEntry     = new MYP.MFTEntry();
                        MemoryStream memoryStream = new MemoryStream();
                        using (DeflateStream deflateStream = new DeflateStream((Stream)memoryStream, CompressionMode.Compress, true))
                            deflateStream.Write(files[index1].Item2, 0, files[index1].Item2.Length);
                        mftEntry.Data    = new byte[memoryStream.Length + 2L];
                        mftEntry.Data[0] = (byte)120;
                        mftEntry.Data[1] = (byte)156;
                        Buffer.BlockCopy((Array)memoryStream.ToArray(), 0, (Array)mftEntry.Data, 2, (int)memoryStream.Length);
                        mftEntry.CompressedSize   = (uint)mftEntry.Data.Length;
                        mftEntry.Hash             = MYP.HashWAR(files[index1].Item1);
                        mftEntry.CRC32            = CRC32.ComputeChecksum(files[index1].Item2);
                        mftEntry.Compressed       = (byte)1;
                        mftEntry.UnCompressedSize = (uint)files[index1].Item2.Length;
                        mftEntry.MFTEntryOffset   = this._stream.Position;
                        binaryWriter.Write(0L);
                        binaryWriter.Write(mftEntry.HeaderSize);
                        binaryWriter.Write(mftEntry.CompressedSize);
                        binaryWriter.Write(mftEntry.UnCompressedSize);
                        binaryWriter.Write(mftEntry.Hash);
                        binaryWriter.Write(mftEntry.CRC32);
                        binaryWriter.Write(mftEntry.Compressed);
                        binaryWriter.Write((byte)0);
                        mftEntryList.Add(mftEntry);
                        ++index1;
                    }
                    else
                    {
                        binaryWriter.Write(0L);
                        binaryWriter.Write(0U);
                        binaryWriter.Write(0U);
                        binaryWriter.Write(0U);
                        binaryWriter.Write(0L);
                        binaryWriter.Write(0U);
                        binaryWriter.Write((byte)0);
                        binaryWriter.Write((byte)0);
                    }
                }
                int num2 = 0;
                foreach (MYP.MFTEntry mftEntry in mftEntryList)
                {
                    long position = this._stream.Position;
                    this._stream.Position = mftEntry.MFTEntryOffset;
                    binaryWriter.Write(position);
                    this._stream.Position = position;
                    byte[] data = mftEntry.Data;
                    this._stream.Write(data, 0, data.Length);
                    if ((int)mftEntry.Compressed == 1)
                    {
                        byte[]       buffer       = new byte[(int)mftEntry.UnCompressedSize];
                        MemoryStream memoryStream = new MemoryStream(data);
                        memoryStream.Position = (long)(mftEntry.HeaderSize + 2U);
                        using (DeflateStream deflateStream = new DeflateStream((Stream)memoryStream, CompressionMode.Decompress, true))
                            deflateStream.Read(buffer, 0, buffer.Length);
                    }
                    ++num2;
                }
                if (index1 < files.Count)
                {
                    long position = this._stream.Position;
                    this._stream.Position = num1;
                    binaryWriter.Write(position);
                    this._stream.Position = position;
                }
                mftEntryList.Clear();
            }
        }
예제 #9
0
 public void UpdateFile(string name, byte[] data)
 {
     this.UpdateFile(MYP.HashWAR(name), data);
 }