MPQBlockTableEntry

Struct MPQBlockTableEntry 

Source
pub struct MPQBlockTableEntry {
    pub offset: u32,
    pub archived_size: u32,
    pub size: u32,
    pub flags: u32,
}
Expand description

The block tables of the MPQ archive, they are stored sequentially and encrypted.

Fields§

§offset: u32

Block Offset, an offset of the beginning of the block, relative to the beginning of the archive header, this can be used in conjunction with fseek to start reading a specific block. In the case of this crate, since the contents are in memory already, it’s used as data[(archive_header_offset + self.offset)..]. This is because the first section of the archive may be the UserData section so the archive header offset must be known.

§archived_size: u32

Size of the block in the archive.

§size: u32

Size of the file data stored in the block. see MPQBlockTableEntry::parse_size for more information.

§flags: u32

Bit mask of the flags for the block, see MPQBlockTableEntry::parse_flags for more information.

Implementations§

Source§

impl MPQBlockTableEntry

Source

pub fn new(offset: u32, archived_size: u32, size: u32, flags: u32) -> Self

This method is not related to parsing but for testing, maybe we should consider further splitting this into a MPQBlockTableEntryParser, maybe overkill.

Source

pub fn parse(input: &[u8]) -> IResult<&[u8], Self>

Parses all the fields in the expected order

Source

pub fn parse_offset(input: &[u8]) -> IResult<&[u8], u32>

Offset 0x00: int32 BlockOffset

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

Source

pub fn parse_archived_size(input: &[u8]) -> IResult<&[u8], u32>

Offset 0x04: int32 BlockSize

Size of the block in the archive.

Source

pub fn parse_size(input: &[u8]) -> IResult<&[u8], u32>

Offset 0x08: int32 FileSize

Size of the file data stored in the block. Only valid if the block is a file; otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data.

Source

pub fn parse_flags(input: &[u8]) -> IResult<&[u8], u32>

Offset 0x0c: int32 Flags

Bit mask of the flags for the block. The following values are conclusively identified:

  • 0x80000000 Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.
  • 0x04000000 File has checksums for each sector (explained in the File Data section). Ignored if file is not compressed or imploded.
  • 0x02000000 File is a deletion marker, indicating that the file no longer exists. This is used to allow patch archives to delete files present in lower-priority archives in the search chain.
  • 0x01000000 File is stored as a single unit, rather than split into sectors.
  • 0x00020000 The file’s encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted.
  • 0x00010000 File is encrypted.
  • 0x00000200 File is compressed. File cannot be imploded.
  • 0x00000100 File is imploded. File cannot be compressed.

Trait Implementations§

Source§

impl Clone for MPQBlockTableEntry

Source§

fn clone(&self) -> MPQBlockTableEntry

Returns a duplicate 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 MPQBlockTableEntry

Source§

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

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

impl Default for MPQBlockTableEntry

Source§

fn default() -> MPQBlockTableEntry

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

impl PartialEq for MPQBlockTableEntry

Source§

fn eq(&self, other: &MPQBlockTableEntry) -> 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 StructuralPartialEq for MPQBlockTableEntry

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> 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> 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