Skip to content

Commit

Permalink
DIRECTOR: Fix RIFX files inside of EXE's
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops authored and sev- committed Aug 3, 2016
1 parent 8c252aa commit 50c52ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions engines/director/resource.cpp
Expand Up @@ -251,6 +251,8 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream) {
bool RIFXArchive::openStream(Common::SeekableReadStream *stream) {
close();

uint32 startPos = stream->pos();

uint32 tag = stream->readUint32BE();
bool isBigEndian;

Expand All @@ -261,19 +263,20 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream) {
else
return false;

Common::SeekableSubReadStreamEndian subStream(stream, 4, stream->size(), isBigEndian, DisposeAfterUse::NO);
Common::SeekableSubReadStreamEndian subStream(stream, startPos + 4, stream->size(), isBigEndian, DisposeAfterUse::NO);

subStream.readUint32(); // size

if (subStream.readUint32() != MKTAG('M', 'V', '9', '3'))
uint32 type = subStream.readUint32();
if (type != MKTAG('M', 'V', '9', '3') && type != MKTAG('A', 'P', 'P', 'L'))
return false;

if (subStream.readUint32() != MKTAG('i', 'm', 'a', 'p'))
return false;

subStream.readUint32(); // imap length
subStream.readUint32(); // unknown
uint32 mmapOffset = subStream.readUint32() - 4;
uint32 mmapOffset = subStream.readUint32() - startPos - 4;

subStream.seek(mmapOffset);

Expand All @@ -294,6 +297,8 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream) {
uint32 offset = subStream.readUint32();
subStream.skip(8); // always 0?

debug(0, "Found RIFX resource %d: '%s', %d @ 0x%08x", i, tag2str(tag), size, offset);

ResourceMap &resMap = _types[tag];
Resource &res = resMap[i]; // FIXME: What is the ID? Is this setup even viable?
res.offset = offset;
Expand Down

0 comments on commit 50c52ab

Please sign in to comment.