From 3995610ce376e49208ba9489d2079c5f6beac1e3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 22 Feb 2011 11:14:38 -0500 Subject: COMMON: Add a convenience function to ignore the language field --- common/pe_exe.cpp | 11 +++++++++++ common/pe_exe.h | 3 +++ 2 files changed, 14 insertions(+) (limited to 'common') 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 PEResources::getLangList(const PEResourceID &type, con return array; } +SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PEResourceID &name) { + Array 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 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); -- cgit v1.2.3