public static MpqHeader FromReader(BinaryReader br) { uint id = br.ReadUInt32(); if (id != MpqId) { return(null); } MpqHeader header = new MpqHeader { ID = id, DataOffset = br.ReadUInt32(), ArchiveSize = br.ReadUInt32(), MpqVersion = br.ReadUInt16(), BlockSize = br.ReadUInt16(), HashTablePos = br.ReadUInt32(), BlockTablePos = br.ReadUInt32(), HashTableSize = br.ReadUInt32(), BlockTableSize = br.ReadUInt32(), }; if (header.MpqVersion == 1) { header.ExtendedBlockTableOffset = br.ReadInt64(); header.HashTableOffsetHigh = br.ReadInt16(); header.BlockTableOffsetHigh = br.ReadInt16(); } return(header); }
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); }
private bool LocateMpqHeader() { BinaryReader br = new BinaryReader(BaseStream); // 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 < BaseStream.Length - MpqHeader.Size; i += 0x200) { BaseStream.Seek(i, SeekOrigin.Begin); _mpqHeader = MpqHeader.FromReader(br); if (_mpqHeader != null) { _headerOffset = i; _mpqHeader.SetHeaderOffset(_headerOffset); return(true); } } return(false); }