xoreos
0.0.5
|
Class to hold resource data of an ERF archive file. More...
#include <erffile.h>
Classes | |
struct | ERFHeader |
The header of an ERF file. More... | |
struct | IResource |
Internal resource information. More... | |
Public Member Functions | |
ERFFile (Common::SeekableReadStream *erf, const std::vector< byte > &password=std::vector< byte >()) | |
Take over this stream and read an ERF file out of it. More... | |
~ERFFile () | |
const ResourceList & | getResources () const |
Return the list of resources. More... | |
uint32 | getResourceSize (uint32 index) const |
Return the size of a resource. More... | |
Common::SeekableReadStream * | getResource (uint32 index, bool tryNoCopy=false) const |
Return a stream of the resource's contents. More... | |
uint32 | getBuildYear () const |
Return the year the ERF was built. More... | |
uint32 | getBuildDay () const |
Return the day of year the ERF was built. More... | |
const LocString & | getDescription () const |
Return the description. More... | |
Common::HashAlgo | getNameHashAlgo () const |
Return with which algorithm the name is hashed. More... | |
Public Member Functions inherited from Aurora::Archive | |
Archive () | |
virtual | ~Archive () |
uint32 | findResource (uint64 hash) const |
Return the index of the resource matching the hash, or 0xFFFFFFFF if not found. More... | |
uint32 | findResource (const Common::UString &name, FileType type) const |
Return the index of the resource matching the name and type, or 0xFFFFFFFF if not found. More... | |
Public Member Functions inherited from Aurora::AuroraFile | |
AuroraFile () | |
void | clear () |
uint32 | getID () const |
Return the file's ID. More... | |
uint32 | getVersion () const |
Return the file's version. More... | |
bool | isUTF16LE () const |
Were the ID and version encoded in little-endian UTF-16 in the file? More... | |
Static Public Member Functions | |
static LocString | getDescription (Common::SeekableReadStream &erf) |
static LocString | getDescription (const Common::UString &fileName) |
Static Public Member Functions inherited from Aurora::AuroraFile | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le) |
Read the header out of a stream. More... | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version) |
Read the ID and version out of a stream. More... | |
static uint32 | readHeaderID (Common::ReadStream &stream) |
Read the ID out of a stream. More... | |
Private Types | |
enum | Encryption { kEncryptionNone = 0, kEncryptionXOR = 1, kEncryptionBlowfishDAO = 2, kEncryptionBlowfishDA2 = 3, kEncryptionBlowfishNWN = 16 } |
enum | Compression { kCompressionNone = 0, kCompressionBioWareZlib = 1, kCompressionHeaderlessZlib = 7, kCompressionStandardZlib = 8 } |
typedef std::vector< IResource > | IResourceList |
Static Private Member Functions | |
static void | verifyVersion (uint32 id, uint32 version, bool utf16le) |
static void | readERFHeader (Common::SeekableReadStream &erf, ERFHeader &header, uint32 version, std::vector< byte > &password) |
static void | readDescription (LocString &description, Common::SeekableReadStream &erf, const ERFHeader &header) |
static void | readV10Header (Common::SeekableReadStream &erf, ERFHeader &header) |
static void | readV11Header (Common::SeekableReadStream &erf, ERFHeader &header) |
static void | readV20Header (Common::SeekableReadStream &erf, ERFHeader &header) |
static void | readV21Header (Common::SeekableReadStream &erf, ERFHeader &header) |
static void | readV22Header (Common::SeekableReadStream &erf, ERFHeader &header, uint32 &flags) |
static void | readV30Header (Common::SeekableReadStream &erf, ERFHeader &header, uint32 &flags) |
static Common::MemoryReadStream * | decrypt (Common::SeekableReadStream &cryptStream, Encryption encryption, const std::vector< byte > &password) |
static Common::MemoryReadStream * | decrypt (Common::SeekableReadStream *cryptStream, Encryption encryption, const std::vector< byte > &password) |
static Common::SeekableReadStream * | decrypt (Common::SeekableReadStream &erf, size_t pos, size_t size, Encryption encryption, const std::vector< byte > &password) |
static Common::SeekableReadStream * | decrypt (Common::SeekableReadStream &erf, size_t size, Encryption encryption, const std::vector< byte > &password) |
static bool | decryptNWNPremiumHeader (Common::SeekableReadStream &erf, ERFHeader &header, const std::vector< byte > &password) |
static bool | findNWNPremiumKey (Common::SeekableReadStream &erf, ERFHeader &header, const std::vector< byte > &md5, std::vector< byte > &password) |
static void | readNWNPremiumHeader (Common::SeekableReadStream &erf, ERFHeader &header, std::vector< byte > &password) |
Private Attributes | |
Common::ScopedPtr< Common::SeekableReadStream > | _erf |
ERFHeader | _header |
LocString | _description |
The ERF's description. More... | |
ResourceList | _resources |
External list of resource names and types. More... | |
IResourceList | _iResources |
Internal list of resource offsets and sizes. More... | |
std::vector< byte > | _password |
The password we were given, if any. More... | |
Additional Inherited Members | |
Public Types inherited from Aurora::Archive | |
typedef std::list< Resource > | ResourceList |
Protected Member Functions inherited from Aurora::AuroraFile | |
void | readHeader (Common::ReadStream &stream) |
Static Protected Member Functions inherited from Aurora::AuroraFile | |
static uint32 | convertUTF16LE (uint32 x1, uint32 x2) |
Protected Attributes inherited from Aurora::AuroraFile | |
uint32 | _id |
The file's ID. More... | |
uint32 | _version |
The file's version. More... | |
bool | _utf16le |
The file's ID and version are in little-endian UTF-16. More... | |
Class to hold resource data of an ERF archive file.
The ERF file is, together with KEY and BIF files, the most basic and widespread archive archive format used in Aurora engine games. There are several versions with different features.
Supported versions:
Known unsupported features:
ERF files can have several different file extensions:
|
private |
|
private |
|
private |
Aurora::ERFFile::ERFFile | ( | Common::SeekableReadStream * | erf, |
const std::vector< byte > & | password = std::vector<byte>() |
||
) |
Take over this stream and read an ERF file out of it.
When the ERF is encrypted, use this password to decrypt it.
In Dragon Age: Origins and Dragon Age II, each DLC can have a unique password with which many of the DLC's ERF archive are encrypted. This password is used to directly decrypt the archive.
In Neverwinter Nights, each premium module consists of an unencrypted .nwm file and an encrypted .hak file, both of which are ERF archives. In this case, the password is the MD5 of the .nwm file. It is then used to calculate the key to decrypt the .hak file.
Definition at line 150 of file erffile.cpp.
Aurora::ERFFile::~ERFFile | ( | ) |
Definition at line 158 of file erffile.cpp.
|
private |
Definition at line 766 of file erffile.cpp.
References _header, Aurora::ERFFile::ERFHeader::compression, decompressBiowareZlib(), decompressHeaderlessZlib(), decompressStandardZlib(), kCompressionBioWareZlib, kCompressionHeaderlessZlib, kCompressionNone, kCompressionStandardZlib, Common::ScopedPtrBase< T, Deallocator >::release(), and Common::MemoryReadStream::size().
Referenced by getResource().
|
private |
Definition at line 794 of file erffile.cpp.
References decompressZlib(), Common::MemoryReadStream::getData(), and Common::MemoryReadStream::size().
Referenced by decompress().
|
private |
Definition at line 809 of file erffile.cpp.
References decompressZlib(), Common::MemoryReadStream::getData(), Common::kWindowBitsMax, and Common::MemoryReadStream::size().
Referenced by decompress().
|
private |
Definition at line 824 of file erffile.cpp.
References decompressZlib(), Common::MemoryReadStream::getData(), Common::kWindowBitsMax, and Common::MemoryReadStream::size().
Referenced by decompress().
|
private |
Definition at line 839 of file erffile.cpp.
References Common::decompressDeflate().
Referenced by decompressBiowareZlib(), decompressHeaderlessZlib(), and decompressStandardZlib().
|
staticprivate |
Definition at line 731 of file erffile.cpp.
References Common::decryptBlowfishEBC(), kEncryptionBlowfishDA2, kEncryptionBlowfishDAO, and kEncryptionBlowfishNWN.
Referenced by decrypt(), decryptNWNPremium(), decryptNWNPremiumHeader(), and getResource().
|
staticprivate |
Definition at line 744 of file erffile.cpp.
References decrypt().
|
staticprivate |
Definition at line 754 of file erffile.cpp.
References decrypt().
|
staticprivate |
Definition at line 760 of file erffile.cpp.
References decrypt(), and Common::SeekableReadStream::pos().
|
private |
Definition at line 302 of file erffile.cpp.
References _erf, _header, _password, decrypt(), Aurora::ERFFile::ERFHeader::encryption, kEncryptionBlowfishNWN, kEncryptionNone, and Common::ScopedPtrBase< T, Deallocator >::reset().
Referenced by load().
|
staticprivate |
Definition at line 225 of file erffile.cpp.
References decrypt(), Aurora::ERFFile::ERFHeader::isSensible(), kEncryptionBlowfishNWN, Common::SeekableReadStream::pos(), readV11Header(), and Common::SeekableReadStream::size().
Referenced by findNWNPremiumKey().
|
staticprivate |
Definition at line 236 of file erffile.cpp.
References ARRAYSIZE, decryptNWNPremiumHeader(), Common::kMD5Length, Aurora::kNWNPremiumKeyLength, Aurora::kNWNPremiumKeys, Common::SeekableReadStream::pos(), and Common::SeekableReadStream::seek().
Referenced by readNWNPremiumHeader().
uint32 Aurora::ERFFile::getBuildDay | ( | ) | const |
Return the day of year the ERF was built.
Definition at line 689 of file erffile.cpp.
References _header, and Aurora::ERFFile::ERFHeader::buildDay.
uint32 Aurora::ERFFile::getBuildYear | ( | ) | const |
Return the year the ERF was built.
Definition at line 685 of file erffile.cpp.
References _header, and Aurora::ERFFile::ERFHeader::buildYear.
const LocString & Aurora::ERFFile::getDescription | ( | ) | const |
Return the description.
Definition at line 693 of file erffile.cpp.
References _description.
Referenced by getDescription(), Engines::NWN::Module::getDescriptionCampaign(), and Engines::NWN::Module::getDescriptionExtra().
|
static |
Definition at line 853 of file erffile.cpp.
References readDescription(), readERFHeader(), Aurora::AuroraFile::readHeader(), and verifyVersion().
|
static |
Definition at line 875 of file erffile.cpp.
References getDescription().
|
private |
Definition at line 701 of file erffile.cpp.
References _iResources.
Referenced by getResource(), and getResourceSize().
|
virtual |
Return with which algorithm the name is hashed.
Reimplemented from Aurora::Archive.
Definition at line 848 of file erffile.cpp.
References Aurora::AuroraFile::_version, Common::kHashFNV64, Common::kHashNone, and kVersion30.
|
virtual |
Return a stream of the resource's contents.
Implements Aurora::Archive.
Definition at line 712 of file erffile.cpp.
References _erf, _header, _password, Aurora::ERFFile::ERFHeader::compression, decompress(), decrypt(), Aurora::ERFFile::ERFHeader::encryption, Common::ScopedPtrBase< T, Deallocator >::get(), getIResource(), kCompressionNone, kEncryptionNone, Aurora::ERFFile::IResource::offset, Aurora::ERFFile::IResource::packedSize, and Aurora::ERFFile::IResource::unpackedSize.
Referenced by Engines::KotOR::SavedGame::fillFromModuleSAV(), Engines::KotOR::SavedGame::fillFromSAV(), Engines::Witcher::Module::getDescription(), and Engines::Witcher::Module::getName().
|
virtual |
Return the list of resources.
Implements Aurora::Archive.
Definition at line 697 of file erffile.cpp.
References _resources.
Referenced by Engines::KotOR::SavedGame::fillFromModuleSAV(), and Engines::KotOR::SavedGame::fillFromSAV().
Return the size of a resource.
Reimplemented from Aurora::Archive.
Definition at line 708 of file erffile.cpp.
References getIResource(), and Aurora::ERFFile::IResource::unpackedSize.
|
private |
Definition at line 275 of file erffile.cpp.
References _description, _erf, _header, Aurora::AuroraFile::_id, _password, Aurora::AuroraFile::_utf16le, Aurora::AuroraFile::_version, Common::StackException::add(), Aurora::ERFFile::ERFHeader::clearStringTable(), decryptNWNPremium(), Aurora::ERFFile::ERFHeader::encryption, kEncryptionBlowfishNWN, readDescription(), readERFHeader(), Aurora::AuroraFile::readHeader(), readResources(), verifyPasswordDigest(), and verifyVersion().
Referenced by ERFFile().
|
staticprivate |
Definition at line 499 of file erffile.cpp.
References Aurora::LocString::clear(), Aurora::ERFFile::ERFHeader::descriptionID, Aurora::ERFFile::ERFHeader::encryption, kEncryptionBlowfishNWN, Aurora::ERFFile::ERFHeader::langCount, Aurora::ERFFile::ERFHeader::offDescription, Aurora::LocString::readLocString(), and Common::SeekableReadStream::seek().
Referenced by getDescription(), and load().
|
staticprivate |
Definition at line 434 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::clear(), Aurora::ERFFile::ERFHeader::encryption, kEncryptionBlowfishNWN, Aurora::kVersion10, kVersion11, kVersion20, kVersion21, kVersion22, kVersion30, Common::SeekableReadStream::pos(), readNWNPremiumHeader(), readV10Header(), readV11Header(), readV20Header(), readV21Header(), readV22Header(), readV30Header(), and Common::SeekableReadStream::seek().
Referenced by getDescription(), and load().
|
staticprivate |
Definition at line 257 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::encryption, findNWNPremiumKey(), Aurora::ERFFile::ERFHeader::isNWNPremium, kEncryptionBlowfishNWN, and Common::kMD5Length.
Referenced by readERFHeader().
|
private |
Definition at line 513 of file erffile.cpp.
References _iResources, _resources, Aurora::AuroraFile::_version, Aurora::ERFFile::ERFHeader::isNWNPremium, Aurora::kVersion10, kVersion11, kVersion20, kVersion21, kVersion22, kVersion30, readV10KeyList(), readV10ResList(), readV11KeyList(), readV20ResList(), readV21ResList(), readV22ResList(), readV30ResList(), and Aurora::ERFFile::ERFHeader::resCount.
Referenced by load().
|
staticprivate |
Definition at line 312 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::buildDay, Aurora::ERFFile::ERFHeader::buildYear, Aurora::ERFFile::ERFHeader::descriptionID, Aurora::ERFFile::ERFHeader::descriptionSize, Aurora::ERFFile::ERFHeader::langCount, Aurora::ERFFile::ERFHeader::offDescription, Aurora::ERFFile::ERFHeader::offKeyList, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, and Common::SeekableReadStream::skip().
Referenced by readERFHeader().
|
private |
Definition at line 556 of file erffile.cpp.
References _resources, Common::kEncodingASCII, Aurora::ERFFile::ERFHeader::offKeyList, Common::readStringFixed(), Common::ReadStream::readUint16LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::skip().
Referenced by readResources().
|
private |
Definition at line 582 of file erffile.cpp.
References _iResources, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::seek().
Referenced by readResources().
|
staticprivate |
Definition at line 329 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::buildDay, Aurora::ERFFile::ERFHeader::buildYear, Aurora::ERFFile::ERFHeader::descriptionID, Aurora::ERFFile::ERFHeader::descriptionSize, Aurora::ERFFile::ERFHeader::encryption, Aurora::ERFFile::ERFHeader::isNWNPremium, Aurora::ERFFile::ERFHeader::isSensible(), kEncryptionBlowfishNWN, Aurora::ERFFile::ERFHeader::langCount, Aurora::ERFFile::ERFHeader::offDescription, Aurora::ERFFile::ERFHeader::offKeyList, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, and Common::SeekableReadStream::skip().
Referenced by decryptNWNPremiumHeader(), and readERFHeader().
|
private |
Definition at line 569 of file erffile.cpp.
References _resources, Common::kEncodingASCII, Aurora::ERFFile::ERFHeader::offKeyList, Common::readStringFixed(), Common::ReadStream::readUint16LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::skip().
Referenced by readResources().
|
staticprivate |
Definition at line 359 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::buildDay, Aurora::ERFFile::ERFHeader::buildYear, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, and Common::SeekableReadStream::skip().
Referenced by readERFHeader().
|
private |
Definition at line 591 of file erffile.cpp.
References _iResources, _resources, Common::kEncodingUTF16LE, Aurora::kFileTypeNone, Aurora::ERFFile::ERFHeader::offResList, Common::readStringFixed(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), and TypeMan.
Referenced by readResources().
|
staticprivate |
Definition at line 370 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::buildDay, Aurora::ERFFile::ERFHeader::buildYear, Aurora::ERFFile::ERFHeader::compression, kCompressionStandardZlib, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readUint16LE(), Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, and Common::SeekableReadStream::skip().
Referenced by readERFHeader().
|
private |
Definition at line 610 of file erffile.cpp.
References _iResources, _resources, Common::kEncodingASCII, Aurora::kFileTypeNone, Aurora::ERFFile::ERFHeader::offResList, Common::readStringFixed(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), and TypeMan.
Referenced by readResources().
|
staticprivate |
Definition at line 387 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::buildDay, Aurora::ERFFile::ERFHeader::buildYear, Aurora::ERFFile::ERFHeader::compression, Aurora::ERFFile::ERFHeader::encryption, Common::kMD5Length, Common::kReadError, Aurora::ERFFile::ERFHeader::moduleID, Aurora::ERFFile::ERFHeader::offResList, Aurora::ERFFile::ERFHeader::passwordDigest, Common::ReadStream::read(), Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, and Common::SeekableReadStream::skip().
Referenced by readERFHeader().
|
private |
Definition at line 630 of file erffile.cpp.
References _iResources, _resources, Common::kEncodingUTF16LE, Aurora::kFileTypeNone, Aurora::ERFFile::ERFHeader::offResList, Common::readStringFixed(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), and TypeMan.
Referenced by readResources().
|
staticprivate |
Definition at line 409 of file erffile.cpp.
References Aurora::ERFFile::ERFHeader::clearStringTable(), Aurora::ERFFile::ERFHeader::compression, Aurora::ERFFile::ERFHeader::encryption, Common::ScopedPtrBase< T, Deallocator >::get(), Common::kMD5Length, Common::kReadError, Aurora::ERFFile::ERFHeader::moduleID, Aurora::ERFFile::ERFHeader::offResList, Aurora::ERFFile::ERFHeader::passwordDigest, Common::ReadStream::read(), Common::ReadStream::readUint32LE(), Aurora::ERFFile::ERFHeader::resCount, Common::ScopedPtrBase< T, Deallocator >::reset(), Aurora::ERFFile::ERFHeader::stringTable, and Aurora::ERFFile::ERFHeader::stringTableSize.
Referenced by readERFHeader().
|
private |
Definition at line 650 of file erffile.cpp.
References _iResources, _resources, Common::ScopedPtrBase< T, Deallocator >::get(), Aurora::kFileTypeNone, Common::kHashFNV32, Aurora::ERFFile::ERFHeader::offResList, Common::ReadStream::readSint32LE(), Common::ReadStream::readUint32LE(), Common::ReadStream::readUint64LE(), Common::SeekableReadStream::seek(), Aurora::ERFFile::ERFHeader::stringTable, Aurora::ERFFile::ERFHeader::stringTableSize, and TypeMan.
Referenced by readResources().
|
private |
Definition at line 174 of file erffile.cpp.
References _header, _password, Common::compareMD5Digest(), Common::encryptBlowfishEBC(), Aurora::ERFFile::ERFHeader::encryption, kEncryptionBlowfishDA2, kEncryptionBlowfishDAO, kEncryptionBlowfishNWN, kEncryptionNone, kEncryptionXOR, Common::parseString(), and Aurora::ERFFile::ERFHeader::passwordDigest.
Referenced by load().
Definition at line 161 of file erffile.cpp.
References Common::debugTag(), kERFID, kHAKID, kMODID, kSAVID, Aurora::kVersion10, kVersion11, kVersion20, kVersion21, kVersion22, and kVersion30.
Referenced by getDescription(), and load().
|
private |
The ERF's description.
Definition at line 214 of file erffile.h.
Referenced by getDescription(), and load().
|
private |
Definition at line 209 of file erffile.h.
Referenced by decryptNWNPremium(), ERFFile(), getResource(), and load().
|
private |
Definition at line 211 of file erffile.h.
Referenced by decompress(), decryptNWNPremium(), getBuildDay(), getBuildYear(), getResource(), load(), and verifyPasswordDigest().
|
private |
Internal list of resource offsets and sizes.
Definition at line 220 of file erffile.h.
Referenced by getIResource(), readResources(), readV10ResList(), readV20ResList(), readV21ResList(), readV22ResList(), and readV30ResList().
|
private |
The password we were given, if any.
Definition at line 223 of file erffile.h.
Referenced by decryptNWNPremium(), getResource(), load(), and verifyPasswordDigest().
|
private |
External list of resource names and types.
Definition at line 217 of file erffile.h.
Referenced by getResources(), readResources(), readV10KeyList(), readV11KeyList(), readV20ResList(), readV21ResList(), readV22ResList(), and readV30ResList().