Ejemplo n.º 1
0
        private bool LocateMpqHeader()
        {
            BinaryReader br = new BinaryReader(mStream);

            // In .mpq files the header will be at the start of the file
            // In .exe files, it will be at a multiple of 0x200
            for (long i = 0; i < mStream.Length - MpqHeader.Size; i += 0x200)
            {
                mStream.Seek(i, SeekOrigin.Begin);
                mHeader = new MpqHeader(br);

                if (mHeader.ID == MpqHeader.MpqId)
                {
                    mHeaderOffset          = i;
                    mHeader.HashTablePos  += (uint)mHeaderOffset;
                    mHeader.BlockTablePos += (uint)mHeaderOffset;
                    if (mHeader.DataOffset == 0x6d9e4b86)
                    {
                        // then this is a protected archive
                        mHeader.DataOffset = (uint)(MpqHeader.Size + i);
                    }
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        private bool LocateMpqHeader()
        {
            var br = new BinaryReader(mStream);

            // In .mpq files the header will be at the start of the file
            // In .exe files, it will be at a multiple of 0x200
            for (long i = 0; i < mStream.Length - MpqHeader.Size; i += 0x200)
            {
                mStream.Seek(i, SeekOrigin.Begin);
                mHeader = new MpqHeader(br);

                if (mHeader.ID == MpqHeader.MpqId)
                {
                    mHeaderOffset = i;
                    mHeader.HashTablePos += (uint)mHeaderOffset;
                    mHeader.BlockTablePos += (uint)mHeaderOffset;
                    if (mHeader.DataOffset == 0x6d9e4b86)
                    {
                        // then this is a protected archive
                        mHeader.DataOffset = (uint)(MpqHeader.Size + i);
                    }
                    return true;
                }
            }
            return false;
        }