96 std::sprintf(name,
"%08x",
_id);
122 if (!peOffset || peOffset >= (
uint32)exe.
size())
134 exe.
skip(optionalHeaderSize + 2);
137 for (
uint16 i = 0; i < sectionCount; i++) {
139 exe.
read(sectionName, 8);
164 exe.
seek(offset + 12);
169 for (
uint32 i = 0; i < entryCount; i++) {
174 if (value & 0x80000000) {
178 exe.
seek(section.
offset + (value & 0x7fffffff));
217 exe.
seek(lastOffset);
222 std::vector<PEResourceID> array;
225 array.push_back(it->first);
231 std::vector<PEResourceID> array;
238 for (NameMap::const_iterator it = nameMap.begin(); it != nameMap.end(); ++it)
239 array.push_back(it->first);
245 std::vector<PEResourceID> array;
252 if (nameMap.find(name) == nameMap.end())
255 const LangMap &langMap = nameMap.find(name)->second;
257 for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); ++it)
258 array.push_back(it->first);
264 std::vector<PEResourceID> langList =
getLangList(type, name);
266 if (langList.empty())
269 const Resource &resource =
_resources.find(type)->second.find(name)->second.find(langList[0])->second;
271 return _exe->readStream(resource.
size);
282 if (nameMap.find(name) == nameMap.end())
285 const LangMap &langMap = nameMap.find(name)->second;
287 if (langMap.find(lang) == langMap.end())
290 const Resource &resource = langMap.find(lang)->second;
292 return _exe->readStream(resource.
size);
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
const std::vector< PEResourceID > getTypeList() const
Return a list of resource types.
uint16 readUint16LE()
Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it...
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
A class holding an UTF-8 string.
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
const std::vector< PEResourceID > getNameList(const PEResourceID &type) const
Return a list of names for a given type.
PEResourceID & operator=(UString string)
bool equalsIgnoreCase(const UString &str) const
Implementing the reading stream interfaces for plain memory blocks.
ScopedPtr< SeekableReadStream > _exe
SeekableReadStream * getResource(const PEResourceID &type, const PEResourceID &name)
Return a stream to the specified resource, taking the first language found (or 0 if non-existent)...
UTF-16 LE (little endian).
bool operator==(const UString &x) const
bool operator<(const PEResourceID &x) const
UString getString() const
uint16 readUint16BE()
Read an unsigned 16-bit word stored in big endian (MSB first) order from the stream and return it...
std::map< UString, Section > _sections
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
PEResources(SeekableReadStream *exe)
virtual size_t read(void *dataPtr, size_t dataSize)=0
Read data from the stream.
Utility functions for working with differing string encodings.
UString _name
The resource's string ID.
bool loadFromEXE(SeekableReadStream &exe)
const std::vector< PEResourceID > getLangList(const PEResourceID &type, const PEResourceID &name) const
Return a list of languages for a given type and name.
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
std::map< PEResourceID, Resource > LangMap
virtual size_t pos() const =0
Obtains the current value of the stream position indicator of the stream.
uint32 readUint32BE()
Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it...
Portable executable parsing.
enum Common::PEResourceID::IDType _idType
#define MKTAG_16(a0, a1)
A wrapper macro used around two character constants, like 'MZ'.
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
void parseResourceLevel(SeekableReadStream &exe, Section §ion, uint32 offset, int level)
std::map< PEResourceID, LangMap > NameMap
Interface for a seekable & readable data stream.
uint32 _id
The resource's numerical ID.