Struct MPQFileHeader

Source
pub struct MPQFileHeader {
    pub header_size: u32,
    pub archive_size: u32,
    pub format_version: u16,
    pub sector_size_shift: u16,
    pub hash_table_offset: u32,
    pub block_table_offset: u32,
    pub hash_table_entries: u32,
    pub block_table_entries: u32,
    pub extended_file_header: Option<MPQFileHeaderExt>,
    pub offset: usize,
}
Expand description

The MPQ File Header

Fields§

§header_size: u32

Size of the archive header.

§archive_size: u32

Size of the whole archive, including the header.

§format_version: u16

MoPaQ format version.

§sector_size_shift: u16

Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive.

§hash_table_offset: u32

Offset to the beginning of the hash table, relative to the beginning of the archive header. To seek it we must add the MPQFileHeader::offset

§block_table_offset: u32

Offset to the beginning of the hash table, relative to the beginning of the archive header. To seek it we must add the MPQFileHeader::offset

§hash_table_entries: u32

Number of entries in the hash table.

§block_table_entries: u32

Number of entries in the block table.

§extended_file_header: Option<MPQFileHeaderExt>

Extended Block Table only present in Burning Crusade format and later:

§offset: usize

Store the offset at which the FileHeader was found. this is done because other offsets are relative to this one.

Implementations§

Source§

impl MPQFileHeader

Source

pub fn parse( input: &[u8], offset: usize, ) -> Result<(&[u8], MPQFileHeader), Err<Error<&[u8]>>>

Parses the internal fields in the expected order.

Source

pub fn parse_header_size( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset 0x04: int32 HeaderSize

Size of the archive header.

Source

pub fn parse_archive_size( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset: 0x08: int32 ArchiveSize

Size of the whole archive, including the header. Does not include the strong digital signature, if present. This size is used, among other things, for determining the region to hash in computing the digital signature. This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive is calculated as the size from the beginning of the archive to the end of the hash table, block table, or extended block table (whichever is largest).

Source

pub fn parse_format_version( input: &[u8], ) -> Result<(&[u8], u16), Err<Error<&[u8]>>>

Offset 0x0c: int16 FormatVersion

MoPaQ format version. MPQAPI will not open archives where this is negative. Known versions:

  • 0x0000 Original format. HeaderSize should be 0x20, and large archives are not supported.
  • 0x0001 Burning Crusade format. Header size should be 0x2c, and large archives are supported.
Source

pub fn parse_sector_size_shift( input: &[u8], ) -> Result<(&[u8], u16), Err<Error<&[u8]>>>

Offset 0x0e: int8 SectorSizeShift

Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive. The size of each logical sector in the archive is: 512 * 2^SectorSizeShift. Bugs in the Storm library dictate that this shouldalways be: 3 (4096 byte sectors).

Source

pub fn parse_hash_table_offset( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset 0x10: int32 HashTableOffset

Offset to the beginning of the hash table, relative to the beginning of the archive.

Source

pub fn parse_block_table_offset( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset 0x14: int32 BlockTableOffset

Offset to the beginning of the block table, relative to the beginning of the archive.

Source

pub fn parse_hash_table_entries( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset 0x18: int32 HashTableEntries

Number of entries in the hash table. Must be a power of two, and must be: less than 2^16 for the original MoPaQ format, or less than 2^20 for the Burning Crusade format.

Source

pub fn parse_block_table_entries( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>

Offset 0x1c: int32 BlockTableEntries

Number of entries in the block table.

Source

pub fn parse_extended_header_if_needed( input: &[u8], format_version: u16, ) -> Result<(&[u8], Option<MPQFileHeaderExt>), Err<Error<&[u8]>>>

Offset 0x20: ExtendedBlockTable

Extended Block Table only present in Burning Crusade format and later:

Trait Implementations§

Source§

impl Clone for MPQFileHeader

Source§

fn clone(&self) -> MPQFileHeader

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MPQFileHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for MPQFileHeader

Source§

fn default() -> MPQFileHeader

Returns the “default value” for a type. Read more
Source§

impl PartialEq for MPQFileHeader

Source§

fn eq(&self, other: &MPQFileHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for MPQFileHeader

Source§

impl StructuralPartialEq for MPQFileHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more