COMMON: Added VersionInfo parser to WinResources
This commit is contained in:
parent
4e0eec203d
commit
f534e11ccf
2 changed files with 60 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
|
#include "common/ustr.h"
|
||||||
#include "common/winexe.h"
|
#include "common/winexe.h"
|
||||||
#include "common/winexe_ne.h"
|
#include "common/winexe_ne.h"
|
||||||
#include "common/winexe_pe.h"
|
#include "common/winexe_pe.h"
|
||||||
|
@ -183,4 +184,59 @@ WinResources *WinResources::createFromEXE(const String &fileName) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WinResources::VersionHash *WinResources::parseVersionInfo(SeekableReadStream *res) {
|
||||||
|
VersionHash *versionMap = new VersionHash;
|
||||||
|
|
||||||
|
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 info;
|
||||||
|
while ((c = res->readUint16LE()) != 0 && !res->eos())
|
||||||
|
info += 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();
|
||||||
|
|
||||||
|
versionMap->setVal(info.encode(), value);
|
||||||
|
} else {
|
||||||
|
if (info == "VS_VERSION_INFO") {
|
||||||
|
uint16 pos2 = res->pos() + valLen;
|
||||||
|
|
||||||
|
res->readUint32LE();
|
||||||
|
res->readUint32LE();
|
||||||
|
uint16 fileB = res->readUint16LE();
|
||||||
|
uint16 fileA = res->readUint16LE();
|
||||||
|
uint16 fileD = res->readUint16LE();
|
||||||
|
uint16 fileC = res->readUint16LE();
|
||||||
|
uint16 prodB = res->readUint16LE();
|
||||||
|
uint16 prodA = res->readUint16LE();
|
||||||
|
uint16 prodD = res->readUint16LE();
|
||||||
|
uint16 prodC = res->readUint16LE();
|
||||||
|
|
||||||
|
versionMap->setVal("File:", Common::String::format("%d.%d.%d.%d", fileA, fileB, fileC, fileD));
|
||||||
|
versionMap->setVal("Prod:", Common::String::format("%d.%d.%d.%d", prodA, prodB, prodC, prodD));
|
||||||
|
|
||||||
|
while (res->pos() != pos2 && !res->eos())
|
||||||
|
res->readByte();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return versionMap;
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
|
@ -130,6 +130,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static WinResources *createFromEXE(const String &fileName);
|
static WinResources *createFromEXE(const String &fileName);
|
||||||
|
|
||||||
|
typedef Common::HashMap<Common::String, Common::U32String, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> VersionHash;
|
||||||
|
|
||||||
|
static VersionHash *parseVersionInfo(SeekableReadStream *stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue