[Scummvm-git-logs] scummvm master -> 4736b0ed99427ffc6d0ce13b243b2de3f70eb039
sev-
sev at scummvm.org
Thu Jul 15 11:55:40 UTC 2021
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
54b8ee6d41 DIRECTOR: Recognise files with "PJ01" version tags
a7d61eb365 COMMON: Allow loading EXE files from an existing stream
bf4ae50a3f COMMON: Add a helper function for loading version resources
be5452fccc DIRECTOR: Use the executable version info for fallback detection
4736b0ed99 COMMON: Fix loading version information from 16-bit executables
Commit: 54b8ee6d41fd78df94ec3f737ea2384875f7380a
https://github.com/scummvm/scummvm/commit/54b8ee6d41fd78df94ec3f737ea2384875f7380a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-07-15T13:55:33+02:00
Commit Message:
DIRECTOR: Recognise files with "PJ01" version tags
Changed paths:
engines/director/detection.cpp
engines/director/resource.cpp
diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp
index 81c4fe30f2..5c34f624d0 100644
--- a/engines/director/detection.cpp
+++ b/engines/director/detection.cpp
@@ -214,6 +214,9 @@ ADDetectedGame DirectorMetaEngineDetection::fallbackDetect(const FileMap &allFil
case MKTAG('P', 'J', '0', '0'):
desc->version = 700;
break;
+ case MKTAG('P', 'J', '0', '1'):
+ desc->version = 800;
+ break;
default:
// Prior to version 4, there was no tag here. So we'll use a bit of a
// heuristic to detect. The first field is the entry count, of which
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index f27b807d6f..49acde5c17 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -292,8 +292,10 @@ void Window::loadEXEv3(Common::SeekableReadStream *stream) {
}
void Window::loadEXEv4(Common::SeekableReadStream *stream) {
- if (stream->readUint32BE() != MKTAG('P', 'J', '9', '3'))
- error("Invalid projector tag found in v4 EXE");
+ uint32 ver = stream->readUint32BE();
+
+ if (ver != MKTAG('P', 'J', '9', '3'))
+ error("Invalid projector tag found in v4 EXE [%s]", tag2str(ver));
uint32 rifxOffset = stream->readUint32LE();
/* uint32 fontMapOffset = */ stream->readUint32LE();
@@ -332,8 +334,10 @@ void Window::loadEXEv5(Common::SeekableReadStream *stream) {
}
void Window::loadEXEv7(Common::SeekableReadStream *stream) {
- if (stream->readUint32LE() != MKTAG('P', 'J', '0', '0'))
- error("Invalid projector tag found in v7 EXE");
+ uint32 ver = stream->readUint32LE();
+
+ if (ver != MKTAG('P', 'J', '0', '0') && ver != MKTAG('P', 'J', '0', '1'))
+ error("Invalid projector tag found in v7 EXE [%s]", tag2str(ver));
uint32 rifxOffset = stream->readUint32LE();
stream->readUint32LE(); // unknown
Commit: a7d61eb3651363d24ee3cb6b74628be83a9e0062
https://github.com/scummvm/scummvm/commit/a7d61eb3651363d24ee3cb6b74628be83a9e0062
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-07-15T13:55:33+02:00
Commit Message:
COMMON: Allow loading EXE files from an existing stream
Changed paths:
common/winexe.cpp
common/winexe.h
common/winexe_ne.cpp
common/winexe_ne.h
common/winexe_pe.cpp
common/winexe_pe.h
diff --git a/common/winexe.cpp b/common/winexe.cpp
index 70de929245..78510a8b9d 100644
--- a/common/winexe.cpp
+++ b/common/winexe.cpp
@@ -184,6 +184,28 @@ WinResources *WinResources::createFromEXE(const String &fileName) {
return nullptr;
}
+WinResources *WinResources::createFromEXE(SeekableReadStream *stream) {
+ WinResources *exe;
+
+ // First try loading via the NE code
+ stream->seek(0);
+ exe = new Common::NEResources();
+ if (exe->loadFromEXE(stream, DisposeAfterUse::NO)) {
+ return exe;
+ }
+ delete exe;
+
+ // Then try loading via the PE code
+ stream->seek(0);
+ exe = new Common::PEResources();
+ if (exe->loadFromEXE(stream, DisposeAfterUse::NO)) {
+ return exe;
+ }
+ delete exe;
+
+ return nullptr;
+}
+
WinResources::VersionInfo *WinResources::parseVersionInfo(SeekableReadStream *res) {
VersionInfo *info = new VersionInfo;
diff --git a/common/winexe.h b/common/winexe.h
index c44a6b755e..19fb7599c4 100644
--- a/common/winexe.h
+++ b/common/winexe.h
@@ -25,6 +25,7 @@
#include "common/hash-str.h"
#include "common/str.h"
+#include "common/types.h"
namespace Common {
@@ -119,7 +120,7 @@ public:
virtual bool loadFromCompressedEXE(const String &fileName);
/** Load from a stream. */
- virtual bool loadFromEXE(SeekableReadStream *stream) = 0;
+ virtual bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES) = 0;
/** Return a list of IDs for a given type. */
virtual const Array<WinResourceID> getIDList(const WinResourceID &type) const = 0;
@@ -139,6 +140,7 @@ public:
}
static WinResources *createFromEXE(const String &fileName);
+ static WinResources *createFromEXE(SeekableReadStream *stream);
typedef Common::HashMap<Common::String, Common::U32String, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> VersionHash;
diff --git a/common/winexe_ne.cpp b/common/winexe_ne.cpp
index b442b41960..f3e2c307df 100644
--- a/common/winexe_ne.cpp
+++ b/common/winexe_ne.cpp
@@ -37,14 +37,15 @@ NEResources::~NEResources() {
void NEResources::clear() {
if (_exe) {
- delete _exe;
+ if (_disposeFileHandle == DisposeAfterUse::YES)
+ delete _exe;
_exe = nullptr;
}
_resources.clear();
}
-bool NEResources::loadFromEXE(SeekableReadStream *stream) {
+bool NEResources::loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
clear();
if (!stream)
diff --git a/common/winexe_ne.h b/common/winexe_ne.h
index 1dfb967816..914be4c057 100644
--- a/common/winexe_ne.h
+++ b/common/winexe_ne.h
@@ -59,7 +59,7 @@ public:
using WinResources::loadFromEXE;
/** Load from a stream. */
- bool loadFromEXE(SeekableReadStream *stream);
+ bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES);
/** Return a list of resources for a given type. */
const Array<WinResourceID> getIDList(const WinResourceID &type) const;
@@ -86,6 +86,7 @@ private:
};
SeekableReadStream *_exe; ///< Current file.
+ DisposeAfterUse::Flag _disposeFileHandle;
/** All resources. */
List<Resource> _resources;
diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp
index 255aef25db..7db745de7f 100644
--- a/common/winexe_pe.cpp
+++ b/common/winexe_pe.cpp
@@ -40,10 +40,12 @@ PEResources::~PEResources() {
void PEResources::clear() {
_sections.clear();
_resources.clear();
- delete _exe; _exe = nullptr;
+ if (_disposeFileHandle == DisposeAfterUse::YES)
+ delete _exe;
+ _exe = nullptr;
}
-bool PEResources::loadFromEXE(SeekableReadStream *stream) {
+bool PEResources::loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
clear();
if (!stream)
diff --git a/common/winexe_pe.h b/common/winexe_pe.h
index 0af52fb2e6..d09000f697 100644
--- a/common/winexe_pe.h
+++ b/common/winexe_pe.h
@@ -58,7 +58,7 @@ public:
using WinResources::loadFromEXE;
/** Load from a stream. */
- bool loadFromEXE(SeekableReadStream *stream);
+ bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES);
/** Return a list of resource types. */
const Array<WinResourceID> getTypeList() const;
@@ -88,6 +88,7 @@ private:
HashMap<String, Section, IgnoreCase_Hash, IgnoreCase_EqualTo> _sections;
SeekableReadStream *_exe;
+ DisposeAfterUse::Flag _disposeFileHandle;
void parseResourceLevel(Section §ion, uint32 offset, int level);
WinResourceID _curType, _curID, _curLang;
Commit: bf4ae50a3f8f58bf63896411765f3eef5b634a36
https://github.com/scummvm/scummvm/commit/bf4ae50a3f8f58bf63896411765f3eef5b634a36
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-07-15T13:55:33+02:00
Commit Message:
COMMON: Add a helper function for loading version resources
Changed paths:
common/winexe.cpp
common/winexe.h
engines/buried/buried.cpp
engines/director/resource.cpp
diff --git a/common/winexe.cpp b/common/winexe.cpp
index 78510a8b9d..7e990281aa 100644
--- a/common/winexe.cpp
+++ b/common/winexe.cpp
@@ -206,6 +206,18 @@ WinResources *WinResources::createFromEXE(SeekableReadStream *stream) {
return nullptr;
}
+WinResources::VersionInfo *WinResources::getVersionResource(const WinResourceID &id) {
+ VersionInfo *info = nullptr;
+
+ SeekableReadStream *res = getResource(kWinVersion, id);
+ if (res) {
+ info = parseVersionInfo(res);
+ delete res;
+ }
+
+ return info;
+}
+
WinResources::VersionInfo *WinResources::parseVersionInfo(SeekableReadStream *res) {
VersionInfo *info = new VersionInfo;
diff --git a/common/winexe.h b/common/winexe.h
index 19fb7599c4..6cbc9a9d1c 100644
--- a/common/winexe.h
+++ b/common/winexe.h
@@ -162,6 +162,8 @@ public:
static VersionInfo *parseVersionInfo(SeekableReadStream *stream);
+ VersionInfo *getVersionResource(const WinResourceID &id);
+
/** Get a string from a string resource. */
virtual String loadString(uint32 stringID) = 0;
};
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index 1589079c14..ab23ae2f73 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -476,12 +476,9 @@ uint32 BuriedEngine::getVersion() {
return MAKEVERSION(1, 1, 0, 0);
}
- Common::SeekableReadStream *res = _mainEXE->getResource(Common::kWinVersion, 1);
- Common::WinResources::VersionInfo *versionInfo = _mainEXE->parseVersionInfo(res);
-
+ Common::WinResources::VersionInfo *versionInfo = _mainEXE->getVersionResource(1);
uint32 result = MAKEVERSION(versionInfo->fileVersion[0], versionInfo->fileVersion[1], versionInfo->fileVersion[2], versionInfo->fileVersion[3]);
delete versionInfo;
- delete res;
return result;
}
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 49acde5c17..02396c2094 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -205,15 +205,12 @@ void Window::loadEXE(const Common::String movie) {
const Common::Array<Common::WinResourceID> versions = exe->getIDList(Common::kWinVersion);
for (uint i = 0; i < versions.size(); i++) {
- Common::SeekableReadStream *res = exe->getResource(Common::kWinVersion, versions[i]);
-
- Common::WinResources::VersionInfo *info = Common::WinResources::parseVersionInfo(res);
+ Common::WinResources::VersionInfo *info = exe->getVersionResource(versions[i]);
for (Common::WinResources::VersionHash::const_iterator it = info->hash.begin(); it != info->hash.end(); ++it)
warning("info <%s>: <%s>", it->_key.c_str(), it->_value.encode().c_str());
delete info;
- delete res;
}
delete exe;
Commit: be5452fccce5c6d1c07041a68303a79a4254beab
https://github.com/scummvm/scummvm/commit/be5452fccce5c6d1c07041a68303a79a4254beab
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-07-15T13:55:33+02:00
Commit Message:
DIRECTOR: Use the executable version info for fallback detection
Changed paths:
engines/director/detection.cpp
diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp
index 5c34f624d0..bbf4e106f0 100644
--- a/engines/director/detection.cpp
+++ b/engines/director/detection.cpp
@@ -25,6 +25,7 @@
#include "engines/advancedDetector.h"
#include "common/file.h"
+#include "common/winexe.h"
#include "director/detection.h"
#include "director/director.h"
@@ -255,7 +256,19 @@ ADDetectedGame DirectorMetaEngineDetection::fallbackDetect(const FileMap &allFil
s_fallbackFileNameBuffer[50] = '\0';
desc->desc.filesDescriptions[0].fileName = s_fallbackFileNameBuffer;
- Common::String extra = Common::String::format("v%d.%02d", desc->version / 100, desc->version % 100);
+ Common::String extra;
+ Common::WinResources *exe = Common::WinResources::createFromEXE(&f);
+ if (exe) {
+ Common::WinResources::VersionInfo *versionInfo = exe->getVersionResource(1);
+ if (versionInfo) {
+ extra = Common::String::format("v%d.%d.%dr%d", versionInfo->fileVersion[0], versionInfo->fileVersion[1], versionInfo->fileVersion[2], versionInfo->fileVersion[3]);
+ delete versionInfo;
+ }
+ delete exe;
+ }
+ if (extra.empty()) {
+ extra = Common::String::format("v%d.%02d", desc->version / 100, desc->version % 100);
+ }
Common::strlcpy(s_fallbackExtraBuf, extra.c_str(), sizeof(s_fallbackExtraBuf) - 1);
desc->desc.extra = s_fallbackExtraBuf;
Commit: 4736b0ed99427ffc6d0ce13b243b2de3f70eb039
https://github.com/scummvm/scummvm/commit/4736b0ed99427ffc6d0ce13b243b2de3f70eb039
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-07-15T13:55:33+02:00
Commit Message:
COMMON: Fix loading version information from 16-bit executables
Changed paths:
common/winexe.cpp
common/winexe.h
common/winexe_ne.cpp
common/winexe_ne.h
common/winexe_pe.cpp
common/winexe_pe.h
diff --git a/common/winexe.cpp b/common/winexe.cpp
index 7e990281aa..31750c7f5c 100644
--- a/common/winexe.cpp
+++ b/common/winexe.cpp
@@ -218,69 +218,6 @@ WinResources::VersionInfo *WinResources::getVersionResource(const WinResourceID
return info;
}
-WinResources::VersionInfo *WinResources::parseVersionInfo(SeekableReadStream *res) {
- VersionInfo *info = new VersionInfo;
-
- while (res->pos() < res->size() && !res->eos()) {
- while (res->pos() % 4 && !res->eos()) // Pad to 4
- res->readByte();
-
- /* uint16 len = */ res->readUint16LE();
- uint16 valLen = res->readUint16LE();
- uint16 type = res->readUint16LE();
- uint16 c;
-
- Common::U32String key;
- while ((c = res->readUint16LE()) != 0 && !res->eos())
- key += c;
-
- while (res->pos() % 4 && !res->eos()) // Pad to 4
- res->readByte();
-
- if (res->eos())
- break;
-
- if (type != 0) { // text
- Common::U32String value;
- for (int j = 0; j < valLen; j++)
- value += res->readUint16LE();
-
- info->hash.setVal(key.encode(), value);
- } else {
- if (key == "VS_VERSION_INFO") {
- // Signature check
- if (res->readUint32LE() != 0xFEEF04BD)
- return info;
-
- res->readUint32LE(); // struct version
-
- // The versions are stored a bit weird
- info->fileVersion[1] = res->readUint16LE();
- info->fileVersion[0] = res->readUint16LE();
- info->fileVersion[3] = res->readUint16LE();
- info->fileVersion[2] = res->readUint16LE();
- info->productVersion[1] = res->readUint16LE();
- info->productVersion[0] = res->readUint16LE();
- info->productVersion[3] = res->readUint16LE();
- info->productVersion[2] = res->readUint16LE();
-
- info->fileFlagsMask = res->readUint32LE();
- info->fileFlags = res->readUint32LE();
- info->fileOS = res->readUint32LE();
- info->fileType = res->readUint32LE();
- info->fileSubtype = res->readUint32LE();
- info->fileDate[0] = res->readUint32LE();
- info->fileDate[1] = res->readUint32LE();
-
- info->hash.setVal("File:", Common::String::format("%d.%d.%d.%d", info->fileVersion[0], info->fileVersion[1], info->fileVersion[2], info->fileVersion[3]));
- info->hash.setVal("Prod:", Common::String::format("%d.%d.%d.%d", info->productVersion[0], info->productVersion[1], info->productVersion[2], info->productVersion[3]));
- }
- }
- }
-
- return info;
-}
-
WinResources::VersionInfo::VersionInfo() {
fileVersion[0] = fileVersion[1] = fileVersion[2] = fileVersion[3] = 0;
productVersion[0] = productVersion[1] = productVersion[2] = productVersion[3] = 0;
@@ -292,4 +229,36 @@ WinResources::VersionInfo::VersionInfo() {
fileDate[0] = fileDate[1] = 0;
}
+
+bool WinResources::VersionInfo::readVSVersionInfo(SeekableReadStream *res) {
+ // Signature check
+ if (res->readUint32LE() != 0xFEEF04BD)
+ return false;
+
+ res->readUint32LE(); // struct version
+
+ // The versions are stored a bit weird
+ fileVersion[1] = res->readUint16LE();
+ fileVersion[0] = res->readUint16LE();
+ fileVersion[3] = res->readUint16LE();
+ fileVersion[2] = res->readUint16LE();
+ productVersion[1] = res->readUint16LE();
+ productVersion[0] = res->readUint16LE();
+ productVersion[3] = res->readUint16LE();
+ productVersion[2] = res->readUint16LE();
+
+ fileFlagsMask = res->readUint32LE();
+ fileFlags = res->readUint32LE();
+ fileOS = res->readUint32LE();
+ fileType = res->readUint32LE();
+ fileSubtype = res->readUint32LE();
+ fileDate[0] = res->readUint32LE();
+ fileDate[1] = res->readUint32LE();
+
+ hash.setVal("File:", Common::U32String::format("%d.%d.%d.%d", fileVersion[0], fileVersion[1], fileVersion[2], fileVersion[3]));
+ hash.setVal("Prod:", Common::U32String::format("%d.%d.%d.%d", productVersion[0], productVersion[1], productVersion[2], productVersion[3]));
+
+ return true;
+}
+
} // End of namespace Common
diff --git a/common/winexe.h b/common/winexe.h
index 6cbc9a9d1c..af4d8a30fa 100644
--- a/common/winexe.h
+++ b/common/winexe.h
@@ -158,14 +158,17 @@ public:
uint32 fileDate[2];
VersionHash hash;
- };
- static VersionInfo *parseVersionInfo(SeekableReadStream *stream);
+ bool readVSVersionInfo(SeekableReadStream *res);
+ };
VersionInfo *getVersionResource(const WinResourceID &id);
/** Get a string from a string resource. */
virtual String loadString(uint32 stringID) = 0;
+
+protected:
+ virtual VersionInfo *parseVersionInfo(SeekableReadStream *stream) = 0;
};
/** @} */
diff --git a/common/winexe_ne.cpp b/common/winexe_ne.cpp
index f3e2c307df..c81b16c76e 100644
--- a/common/winexe_ne.cpp
+++ b/common/winexe_ne.cpp
@@ -234,4 +234,34 @@ String NEResources::loadString(uint32 stringID) {
return string;
}
+WinResources::VersionInfo *NEResources::parseVersionInfo(SeekableReadStream *res) {
+ VersionInfo *info = new VersionInfo;
+
+ while (res->pos() < res->size() && !res->eos()) {
+ while (res->pos() % 4 && !res->eos()) // Pad to 4
+ res->readByte();
+
+ /* uint16 len = */ res->readUint16LE();
+ /* uint16 valLen = */ res->readUint16LE();
+ uint16 c;
+
+ Common::String key;
+ while ((c = res->readByte()) != 0 && !res->eos())
+ key += c;
+
+ while (res->pos() % 4 && !res->eos()) // Pad to 4
+ res->readByte();
+
+ if (res->eos())
+ break;
+
+ if (key == "VS_VERSION_INFO") {
+ if (!info->readVSVersionInfo(res))
+ return info;
+ }
+ }
+
+ return info;
+}
+
} // End of namespace Common
diff --git a/common/winexe_ne.h b/common/winexe_ne.h
index 914be4c057..59eaa2e46c 100644
--- a/common/winexe_ne.h
+++ b/common/winexe_ne.h
@@ -70,6 +70,9 @@ public:
/** Get a string from a string resource. */
String loadString(uint32 stringID);
+protected:
+ VersionInfo *parseVersionInfo(SeekableReadStream *stream);
+
private:
/** A resource. */
struct Resource {
diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp
index 7db745de7f..48989694de 100644
--- a/common/winexe_pe.cpp
+++ b/common/winexe_pe.cpp
@@ -259,4 +259,43 @@ String PEResources::loadString(uint32 stringID) {
return string;
}
+WinResources::VersionInfo *PEResources::parseVersionInfo(SeekableReadStream *res) {
+ VersionInfo *info = new VersionInfo;
+
+ while (res->pos() < res->size() && !res->eos()) {
+ while (res->pos() % 4 && !res->eos()) // Pad to 4
+ res->readByte();
+
+ /* uint16 len = */ res->readUint16LE();
+ uint16 valLen = res->readUint16LE();
+ uint16 type = res->readUint16LE();
+ uint16 c;
+
+ Common::U32String key;
+ while ((c = res->readUint16LE()) != 0 && !res->eos())
+ key += c;
+
+ while (res->pos() % 4 && !res->eos()) // Pad to 4
+ res->readByte();
+
+ if (res->eos())
+ break;
+
+ if (type != 0) { // text
+ Common::U32String value;
+ for (int j = 0; j < valLen; j++)
+ value += res->readUint16LE();
+
+ info->hash.setVal(key.encode(), value);
+ } else {
+ if (key == "VS_VERSION_INFO") {
+ if (!info->readVSVersionInfo(res))
+ return info;
+ }
+ }
+ }
+
+ return info;
+}
+
} // End of namespace Common
diff --git a/common/winexe_pe.h b/common/winexe_pe.h
index d09000f697..e0d41b9e3b 100644
--- a/common/winexe_pe.h
+++ b/common/winexe_pe.h
@@ -78,6 +78,9 @@ public:
/** Get a string from a string resource. */
String loadString(uint32 stringID);
+protected:
+ VersionInfo *parseVersionInfo(SeekableReadStream *stream);
+
private:
struct Section {
uint32 virtualAddress;
More information about the Scummvm-git-logs
mailing list