COMMON: Rename PEResources::getNameList() to getIDList()
This commit is contained in:
parent
948c555ea6
commit
b8e94e1acd
5 changed files with 52 additions and 52 deletions
|
@ -151,7 +151,7 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level)
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
_curType = id;
|
_curType = id;
|
||||||
else if (level == 1)
|
else if (level == 1)
|
||||||
_curName = id;
|
_curID = id;
|
||||||
else if (level == 2)
|
else if (level == 2)
|
||||||
_curLang = id;
|
_curLang = id;
|
||||||
|
|
||||||
|
@ -166,9 +166,9 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level)
|
||||||
resource.size = _exe->readUint32LE();
|
resource.size = _exe->readUint32LE();
|
||||||
|
|
||||||
debug(4, "Found resource '%s' '%s' '%s' at %d of size %d", _curType.toString().c_str(),
|
debug(4, "Found resource '%s' '%s' '%s' at %d of size %d", _curType.toString().c_str(),
|
||||||
_curName.toString().c_str(), _curLang.toString().c_str(), resource.offset, resource.size);
|
_curID.toString().c_str(), _curLang.toString().c_str(), resource.offset, resource.size);
|
||||||
|
|
||||||
_resources[_curType][_curName][_curLang] = resource;
|
_resources[_curType][_curID][_curLang] = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exe->seek(lastOffset);
|
_exe->seek(lastOffset);
|
||||||
|
@ -187,32 +187,32 @@ const Array<WinResourceID> PEResources::getTypeList() const {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Array<WinResourceID> PEResources::getNameList(const WinResourceID &type) const {
|
const Array<WinResourceID> PEResources::getIDList(const WinResourceID &type) const {
|
||||||
Array<WinResourceID> array;
|
Array<WinResourceID> array;
|
||||||
|
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
for (NameMap::const_iterator it = nameMap.begin(); it != nameMap.end(); it++)
|
for (IDMap::const_iterator it = idMap.begin(); it != idMap.end(); it++)
|
||||||
array.push_back(it->_key);
|
array.push_back(it->_key);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, const WinResourceID &name) const {
|
const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, const WinResourceID &id) const {
|
||||||
Array<WinResourceID> array;
|
Array<WinResourceID> array;
|
||||||
|
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
if (!nameMap.contains(name))
|
if (!idMap.contains(id))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const LangMap &langMap = nameMap[name];
|
const LangMap &langMap = idMap[id];
|
||||||
|
|
||||||
for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); it++)
|
for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); it++)
|
||||||
array.push_back(it->_key);
|
array.push_back(it->_key);
|
||||||
|
@ -220,27 +220,27 @@ const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, c
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &name) {
|
SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &id) {
|
||||||
Array<WinResourceID> langList = getLangList(type, name);
|
Array<WinResourceID> langList = getLangList(type, id);
|
||||||
|
|
||||||
if (langList.empty())
|
if (langList.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const Resource &resource = _resources[type][name][langList[0]];
|
const Resource &resource = _resources[type][id][langList[0]];
|
||||||
_exe->seek(resource.offset);
|
_exe->seek(resource.offset);
|
||||||
return _exe->readStream(resource.size);
|
return _exe->readStream(resource.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang) {
|
SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) {
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
if (!nameMap.contains(name))
|
if (!idMap.contains(id))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const LangMap &langMap = nameMap[name];
|
const LangMap &langMap = idMap[id];
|
||||||
|
|
||||||
if (!langMap.contains(lang))
|
if (!langMap.contains(lang))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -54,17 +54,17 @@ public:
|
||||||
/** Return a list of resource types. */
|
/** Return a list of resource types. */
|
||||||
const Array<WinResourceID> getTypeList() const;
|
const Array<WinResourceID> getTypeList() const;
|
||||||
|
|
||||||
/** Return a list of names for a given type. */
|
/** Return a list of IDs for a given type. */
|
||||||
const Array<WinResourceID> getNameList(const WinResourceID &type) const;
|
const Array<WinResourceID> getIDList(const WinResourceID &type) const;
|
||||||
|
|
||||||
/** Return a list of languages for a given type and name. */
|
/** Return a list of languages for a given type and ID. */
|
||||||
const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &name) const;
|
const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const;
|
||||||
|
|
||||||
/** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */
|
/** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */
|
||||||
SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name);
|
SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id);
|
||||||
|
|
||||||
/** Return a stream to the specified resource (or 0 if non-existent). */
|
/** Return a stream to the specified resource (or 0 if non-existent). */
|
||||||
SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang);
|
SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Section {
|
struct Section {
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
SeekableReadStream *_exe;
|
SeekableReadStream *_exe;
|
||||||
|
|
||||||
void parseResourceLevel(Section §ion, uint32 offset, int level);
|
void parseResourceLevel(Section §ion, uint32 offset, int level);
|
||||||
WinResourceID _curType, _curName, _curLang;
|
WinResourceID _curType, _curID, _curLang;
|
||||||
|
|
||||||
struct Resource {
|
struct Resource {
|
||||||
uint32 offset;
|
uint32 offset;
|
||||||
|
@ -86,8 +86,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
|
typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
|
||||||
typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> NameMap;
|
typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> IDMap;
|
||||||
typedef HashMap<WinResourceID, NameMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
|
typedef HashMap<WinResourceID, IDMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
|
||||||
|
|
||||||
TypeMap _resources;
|
TypeMap _resources;
|
||||||
};
|
};
|
||||||
|
|
|
@ -151,7 +151,7 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level)
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
_curType = id;
|
_curType = id;
|
||||||
else if (level == 1)
|
else if (level == 1)
|
||||||
_curName = id;
|
_curID = id;
|
||||||
else if (level == 2)
|
else if (level == 2)
|
||||||
_curLang = id;
|
_curLang = id;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level)
|
||||||
resource.offset = _exe->readUint32LE() + section.offset - section.virtualAddress;
|
resource.offset = _exe->readUint32LE() + section.offset - section.virtualAddress;
|
||||||
resource.size = _exe->readUint32LE();
|
resource.size = _exe->readUint32LE();
|
||||||
|
|
||||||
_resources[_curType][_curName][_curLang] = resource;
|
_resources[_curType][_curID][_curLang] = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exe->seek(lastOffset);
|
_exe->seek(lastOffset);
|
||||||
|
@ -184,32 +184,32 @@ const Array<WinResourceID> PEResources::getTypeList() const {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Array<WinResourceID> PEResources::getNameList(const WinResourceID &type) const {
|
const Array<WinResourceID> PEResources::getIDList(const WinResourceID &type) const {
|
||||||
Array<WinResourceID> array;
|
Array<WinResourceID> array;
|
||||||
|
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
for (NameMap::const_iterator it = nameMap.begin(); it != nameMap.end(); it++)
|
for (IDMap::const_iterator it = idMap.begin(); it != idMap.end(); it++)
|
||||||
array.push_back(it->_key);
|
array.push_back(it->_key);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, const WinResourceID &name) const {
|
const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, const WinResourceID &id) const {
|
||||||
Array<WinResourceID> array;
|
Array<WinResourceID> array;
|
||||||
|
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
if (!nameMap.contains(name))
|
if (!idMap.contains(id))
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
const LangMap &langMap = nameMap[name];
|
const LangMap &langMap = idMap[id];
|
||||||
|
|
||||||
for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); it++)
|
for (LangMap::const_iterator it = langMap.begin(); it != langMap.end(); it++)
|
||||||
array.push_back(it->_key);
|
array.push_back(it->_key);
|
||||||
|
@ -217,13 +217,13 @@ const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, c
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
File *PEResources::getResource(const WinResourceID &type, const WinResourceID &name) {
|
File *PEResources::getResource(const WinResourceID &type, const WinResourceID &id) {
|
||||||
Array<WinResourceID> langList = getLangList(type, name);
|
Array<WinResourceID> langList = getLangList(type, id);
|
||||||
|
|
||||||
if (langList.empty())
|
if (langList.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const Resource &resource = _resources[type][name][langList[0]];
|
const Resource &resource = _resources[type][id][langList[0]];
|
||||||
byte *data = (byte *)malloc(resource.size);
|
byte *data = (byte *)malloc(resource.size);
|
||||||
_exe->seek(resource.offset);
|
_exe->seek(resource.offset);
|
||||||
_exe->read(data, resource.size);
|
_exe->read(data, resource.size);
|
||||||
|
@ -233,16 +233,16 @@ File *PEResources::getResource(const WinResourceID &type, const WinResourceID &n
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
File *PEResources::getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang) {
|
File *PEResources::getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) {
|
||||||
if (!_exe || !_resources.contains(type))
|
if (!_exe || !_resources.contains(type))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const NameMap &nameMap = _resources[type];
|
const IDMap &idMap = _resources[type];
|
||||||
|
|
||||||
if (!nameMap.contains(name))
|
if (!idMap.contains(id))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const LangMap &langMap = nameMap[name];
|
const LangMap &langMap = idMap[id];
|
||||||
|
|
||||||
if (!langMap.contains(lang))
|
if (!langMap.contains(lang))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,17 +54,17 @@ public:
|
||||||
/** Return a list of resource types. */
|
/** Return a list of resource types. */
|
||||||
const Array<WinResourceID> getTypeList() const;
|
const Array<WinResourceID> getTypeList() const;
|
||||||
|
|
||||||
/** Return a list of names for a given type. */
|
/** Return a list of IDs for a given type. */
|
||||||
const Array<WinResourceID> getNameList(const WinResourceID &type) const;
|
const Array<WinResourceID> getIDList(const WinResourceID &type) const;
|
||||||
|
|
||||||
/** Return a list of languages for a given type and name. */
|
/** Return a list of languages for a given type and ID. */
|
||||||
const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &name) const;
|
const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const;
|
||||||
|
|
||||||
/** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */
|
/** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */
|
||||||
File *getResource(const WinResourceID &type, const WinResourceID &name);
|
File *getResource(const WinResourceID &type, const WinResourceID &id);
|
||||||
|
|
||||||
/** Return a stream to the specified resource (or 0 if non-existent). */
|
/** Return a stream to the specified resource (or 0 if non-existent). */
|
||||||
File *getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang);
|
File *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang);
|
||||||
|
|
||||||
/** Returns true if the resources is empty */
|
/** Returns true if the resources is empty */
|
||||||
bool empty() const { return _sections.empty(); }
|
bool empty() const { return _sections.empty(); }
|
||||||
|
@ -80,7 +80,7 @@ private:
|
||||||
File *_exe;
|
File *_exe;
|
||||||
|
|
||||||
void parseResourceLevel(Section §ion, uint32 offset, int level);
|
void parseResourceLevel(Section §ion, uint32 offset, int level);
|
||||||
WinResourceID _curType, _curName, _curLang;
|
WinResourceID _curType, _curID, _curLang;
|
||||||
|
|
||||||
struct Resource {
|
struct Resource {
|
||||||
uint32 offset;
|
uint32 offset;
|
||||||
|
@ -88,8 +88,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
|
typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
|
||||||
typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> NameMap;
|
typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> IDMap;
|
||||||
typedef HashMap<WinResourceID, NameMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
|
typedef HashMap<WinResourceID, IDMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
|
||||||
|
|
||||||
TypeMap _resources;
|
TypeMap _resources;
|
||||||
};
|
};
|
||||||
|
|
|
@ -248,7 +248,7 @@ PECursorManager::PECursorManager(const Common::String &appName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::Array<Common::WinResourceID> cursorGroups = exe->getNameList(Common::kWinGroupCursor);
|
const Common::Array<Common::WinResourceID> cursorGroups = exe->getIDList(Common::kWinGroupCursor);
|
||||||
|
|
||||||
_cursors.resize(cursorGroups.size());
|
_cursors.resize(cursorGroups.size());
|
||||||
for (uint i = 0; i < cursorGroups.size(); i++) {
|
for (uint i = 0; i < cursorGroups.size(); i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue