diff options
-rw-r--r-- | common/pe_exe.cpp | 11 | ||||
-rw-r--r-- | common/pe_exe.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/common/pe_exe.cpp b/common/pe_exe.cpp index d4aa4bcf49..fc35c0fcb2 100644 --- a/common/pe_exe.cpp +++ b/common/pe_exe.cpp @@ -275,6 +275,17 @@ const Array<PEResourceID> PEResources::getLangList(const PEResourceID &type, con return array; } +SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PEResourceID &name) { + Array<PEResourceID> langList = getLangList(type, name); + + if (langList.empty()) + return 0; + + const Resource &resource = _resources[type][name][langList[0]]; + _exe->seek(resource.offset); + return _exe->readStream(resource.size); +} + SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PEResourceID &name, const PEResourceID &lang) { if (!_exe || !_resources.contains(type)) return 0; diff --git a/common/pe_exe.h b/common/pe_exe.h index ca33a2ca72..c86058fb4f 100644 --- a/common/pe_exe.h +++ b/common/pe_exe.h @@ -122,6 +122,9 @@ public: /** Return a list of languages for a given type and name. */ const Array<PEResourceID> getLangList(const PEResourceID &type, const PEResourceID &name) const; + /** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */ + SeekableReadStream *getResource(const PEResourceID &type, const PEResourceID &name); + /** Return a stream to the specified resource (or 0 if non-existent). */ SeekableReadStream *getResource(const PEResourceID &type, const PEResourceID &name, const PEResourceID &lang); |