-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathctflanguage.cpp
53 lines (42 loc) · 1.8 KB
/
ctflanguage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "defs.h"
#include "ctflanguage.h"
CTFLanguage::CTFLanguage(QObject *parent) : QObject(parent)
{
}
CTFLanguage * CTFLanguage::readCTFLanguage(QFile * cff, long baseAddress, int32_t headerSize, QObject * parent)
{
auto data = new CTFLanguage(parent);
data->readCFFData(cff, baseAddress, headerSize);
return data;
}
void CTFLanguage::readCFFData(QFile * cff, long baseAddress, int32_t headerSize)
{
this->m_BaseAddress = baseAddress;
cff->seek(this->m_BaseAddress);
ushort tmp = 0;
cff->read((char*)&tmp, 2);
ulong languageEntryBitflags = tmp;
this->setQualifier(CFFUtils::ReadBitflagString(languageEntryBitflags, cff, baseAddress));
ushort LanguageIndex = ReadBitflag2Byte(LanguageIndex, languageEntryBitflags, cff);
this->setLanguageIndex(LanguageIndex);
this->m_StringPoolSize = ReadBitflag4Byte(this->m_StringPoolSize, languageEntryBitflags, cff);
this->m_MaybeOffsetFromStringPoolBase = ReadBitflag4Byte(this->m_MaybeOffsetFromStringPoolBase, languageEntryBitflags, cff);
this->m_StringCount = ReadBitflag4Byte(this->m_StringCount, languageEntryBitflags, cff);
this->loadStrings(cff, headerSize);
}
void CTFLanguage::loadStrings(QFile * cff, int32_t headerSize)
{
QStringList StringEntries;
int caesarStringTableOffset = headerSize + 0x410 + 4; // header.CffHeaderSize; strange that this has to be manually computed
for (int i = 0; i < this->m_StringCount; i++)
{
cff->seek(caesarStringTableOffset + (i * 4));
int32_t stringOffset = 0;
cff->read((char*)&stringOffset, 4);
cff->seek(caesarStringTableOffset + stringOffset);
auto result = CFFUtils::ReadString(cff);
qDbg() << "String loaded: " << result;
StringEntries.append(result);
}
this->setStringEntries(StringEntries);
}