wc3lib  0.1.0
Classes | Typedefs | Enumerations | Functions | Variables
wc3lib::mpq Namespace Reference

MPQ module More...

Classes

class  Archive
 This class allows users to read, write and modify MPQ archives. MPQ (Mo'PaQ, short for Mike O'Brien Pack) is an archiving file format used in several of Blizzard Entertainment's games. More...
 
class  Attributes
 Class for MPQ's "(attributes)" file which stores extended file attributes such as time stamps and check sums. More...
 
class  Block
 Blocks are used to provide data for a file in an MPQ archive or empty or deletion regions in the archive which can be used for new blocks. More...
 
struct  BlockTableEntry
 
struct  DataInfo
 
struct  ExtendedAttributesHeader
 
struct  ExtendedBlockTableEntry
 
struct  ExtendedHeader
 MPQ format 2. More...
 
class  File
 Provides access to a file's data which is actually a combination of its block and hash entries as well as its path which is provided by the optional "(listfile)" file and its extended attributes provided by the optional "(attributes)" file. More...
 
struct  FILETIME
 
class  Hash
 Provides access to the hash entry of one single File of an archive. More...
 
class  HashData
 
struct  HashTableEntry
 
struct  Header
 The header structure of the MPQ 1 format. More...
 
class  Listfile
 
struct  MD5Checksum
 
class  Sector
 Blocks are divided into one or several sectors. More...
 
class  Signature
 

Typedefs

typedef int32 CRC32
 

Enumerations

enum  HashType : uint32 { HashType::TableOffset = 0x000, HashType::NameA = 0x100, HashType::NameB = 0x200, HashType::FileKey = 0x300 }
 

Functions

void InitializeCryptTable (uint32 dwCryptTable[cryptTableSize])
 The encryption and hashing functions use a number table in their procedures. This table must be initialized before the functions are called the first time. More...
 
void EncryptData (const uint32 dwCryptTable[cryptTableSize], void *lpbyBuffer, uint32 dwLength, uint32 dwKey)
 
void DecryptData (const uint32 dwCryptTable[cryptTableSize], void *lpbyBuffer, uint32 dwLength, uint32 dwKey)
 
uint32 HashString (const uint32 dwCryptTable[cryptTableSize], const char *lpszString, HashType hashType)
 Based on code from StormLib. More...
 
void compressPklib (char *outBuffer, int &outLength, char *const inBuffer, int inLength, int *, int)
 
void decompressPklib (char *outBuffer, int &outLength, char *const inBuffer, int inLength)
 
int compressWaveMono (short *const inBuffer, int inBufferLength, unsigned char *outBuffer, int &outBufferLength, int compressionLevel)
 
int decompressWaveMono (unsigned char *const inBuffer, int inBufferLength, unsigned char *outBuffer, int &outBufferLength)
 
int compressWaveStereo (short *const inBuffer, int inBufferLength, unsigned char *outBuffer, int &outBufferLength, int compressionLevel)
 
int decompressWaveStereo (unsigned char *const inBuffer, int inBufferLength, unsigned char *outBuffer, int &outBufferLength)
 
std::streamsize compressBzip2 (istream &istream, ostream &ostream)
 
std::streamsize decompressBzip2 (istream &istream, ostream &ostream, int bufferSize)
 
std::streamsize compressZlib (istream &istream, ostream &ostream)
 
std::streamsize decompressZlib (istream &istream, ostream &ostream, int bufferSize)
 
void compressHuffman (char *pbOutBuffer, int *pcbOutBuffer, char *pbInBuffer, int cbInBuffer, int *pCmpType, int)
 
int decompressHuffman (char *pbOutBuffer, int *pcbOutBuffer, char *pbInBuffer, int cbInBuffer)
 
MD5Checksum md5 (const byte *buffer, std::size_t bufferSize)
 
const char * pkglibError (int error)
 
constexpr bool operator& (Attributes::ExtendedAttributes x, Attributes::ExtendedAttributes y)
 
constexpr Attributes::ExtendedAttributes operator| (Attributes::ExtendedAttributes x, Attributes::ExtendedAttributes y)
 
constexpr bool operator& (Block::Flags x, Block::Flags y)
 
std::size_t hash_value (const HashData &hashData)
 
std::ostream & operator<< (std::ostream &out, const MD5Checksum &checksum)
 
constexpr bool operator& (Sector::Compression x, Sector::Compression y)
 
std::string flagsString (Block::Flags flags)
 
std::string compressionString (Sector::Compression compression)
 
std::string fileInfo (File &file, bool humanReadable, bool decimal)
 
std::string formatString (Archive::Format format)
 
std::string archiveInfo (Archive &archive, bool humanReadable, bool decimal)
 
template<typename T >
std::string sizeString (T size, bool humanReadable, bool decimal)
 

Variables

const std::size_t cryptTableSize = 0x500
 

Detailed Description

MPQ module

Typedef Documentation

Enumeration Type Documentation

These values need to be like they are since they're used directly in function HashString() for hash value calculation.

Enumerator
TableOffset 
NameA 
NameB 
FileKey 

Function Documentation

std::string wc3lib::mpq::archiveInfo ( Archive archive,
bool  humanReadable,
bool  decimal 
)
std::streamsize wc3lib::mpq::compressBzip2 ( istream istream,
ostream ostream 
)
Exceptions
boost::iostreams::bzip2_errorThrows an exception if a compression error occurs.
void wc3lib::mpq::compressHuffman ( char *  pbOutBuffer,
int *  pcbOutBuffer,
char *  pbInBuffer,
int  cbInBuffer,
int *  pCmpType,
int   
)
std::string wc3lib::mpq::compressionString ( Sector::Compression  compression)
void wc3lib::mpq::compressPklib ( char *  outBuffer,
int &  outLength,
char *const  inBuffer,
int  inLength,
int *  ,
int   
)
Exceptions
ExceptionThrows an exception if an error occurs on compression.
int wc3lib::mpq::compressWaveMono ( short *const  inBuffer,
int  inBufferLength,
unsigned char *  outBuffer,
int &  outBufferLength,
int  compressionLevel 
)
See also
compressWaveMono, decompressWaveMono, compressWaveStereo, decompressWaveStereo Wrapper of StormLib functions.
Parameters
inBufferBuffer which is read from.
inBufferLengthBuffer length which should be set to amount of bytes which should be read from buffer.
outBufferBuffer which is read into.
outBufferBuffer length which should have the initial size of buffer outBuffer. If the buffer is empty this value should be 0.
Returns
Returns witten bytes.
int wc3lib::mpq::compressWaveStereo ( short *const  inBuffer,
int  inBufferLength,
unsigned char *  outBuffer,
int &  outBufferLength,
int  compressionLevel 
)
std::streamsize wc3lib::mpq::compressZlib ( istream istream,
ostream ostream 
)

Compresses all data from istream into ostream.

Exceptions
boost::iostreams::zlib_errorThrows an exception if a compression error occurs.
std::streamsize wc3lib::mpq::decompressBzip2 ( istream istream,
ostream ostream,
int  bufferSize 
)
Parameters
bufferSizeTo optimize the decompression you can set this value to the MPQ archive's sector size. If unsure use boost::iostreams::default_device_buffer_size.
Exceptions
boost::iostreams::bzip2_errorThrows an exception if a decompression error occurs.
int wc3lib::mpq::decompressHuffman ( char *  pbOutBuffer,
int *  pcbOutBuffer,
char *  pbInBuffer,
int  cbInBuffer 
)
void wc3lib::mpq::decompressPklib ( char *  outBuffer,
int &  outLength,
char *const  inBuffer,
int  inLength 
)
Exceptions
ExceptionThrows an exception if an error occurs on decompression.
int wc3lib::mpq::decompressWaveMono ( unsigned char *const  inBuffer,
int  inBufferLength,
unsigned char *  outBuffer,
int &  outBufferLength 
)
int wc3lib::mpq::decompressWaveStereo ( unsigned char *const  inBuffer,
int  inBufferLength,
unsigned char *  outBuffer,
int &  outBufferLength 
)
std::streamsize wc3lib::mpq::decompressZlib ( istream istream,
ostream ostream,
int  bufferSize 
)
Parameters
bufferSizeTo optimize the decompression you can set this value to the MPQ archive's sector size. If unsure use boost::iostreams::default_device_buffer_size.
Exceptions
boost::iostreams::zlib_errorThrows an exception if a decompression error occurs.
void wc3lib::mpq::DecryptData ( const uint32  dwCryptTable[cryptTableSize],
void *  lpbyBuffer,
uint32  dwLength,
uint32  dwKey 
)
void wc3lib::mpq::EncryptData ( const uint32  dwCryptTable[cryptTableSize],
void *  lpbyBuffer,
uint32  dwLength,
uint32  dwKey 
)
std::string wc3lib::mpq::fileInfo ( File file,
bool  humanReadable,
bool  decimal 
)
std::string wc3lib::mpq::flagsString ( Block::Flags  flags)
std::string wc3lib::mpq::formatString ( Archive::Format  format)
std::size_t wc3lib::mpq::hash_value ( const HashData hashData)
inline
uint32 wc3lib::mpq::HashString ( const uint32  dwCryptTable[cryptTableSize],
const char *  lpszString,
HashType  hashType 
)

Based on code from StormLib.

void wc3lib::mpq::InitializeCryptTable ( uint32  dwCryptTable[cryptTableSize])

The encryption and hashing functions use a number table in their procedures. This table must be initialized before the functions are called the first time.

MD5Checksum wc3lib::mpq::md5 ( const byte buffer,
std::size_t  bufferSize 
)
constexpr bool wc3lib::mpq::operator& ( Attributes::ExtendedAttributes  x,
Attributes::ExtendedAttributes  y 
)
inline
constexpr bool wc3lib::mpq::operator& ( Block::Flags  x,
Block::Flags  y 
)
inline
constexpr bool wc3lib::mpq::operator& ( Sector::Compression  x,
Sector::Compression  y 
)
inline
std::ostream& wc3lib::mpq::operator<< ( std::ostream &  out,
const MD5Checksum checksum 
)
inline
const char* wc3lib::mpq::pkglibError ( int  error)
inline
template<typename T >
std::string wc3lib::mpq::sizeString ( size,
bool  humanReadable,
bool  decimal 
)

Variable Documentation

const std::size_t wc3lib::mpq::cryptTableSize = 0x500