[XML2SDB] Add support for DATA in Layers.

This commit is contained in:
Mark Jansen 2018-04-10 22:39:29 +02:00
parent 083c3d992b
commit 767fc4a6ad
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 84 additions and 1 deletions

View file

@ -14,7 +14,7 @@
using tinyxml2::XMLText;
static const GUID GUID_NULL = { 0 };
static const char szCompilerVersion[] = "1.7.0.0";
static const char szCompilerVersion[] = "1.7.0.1";
#if !defined(C_ASSERT)
#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
@ -398,6 +398,69 @@ bool Flag::toSdb(PDB pdb, Database& db)
}
/***********************************************************************
* Data
*/
#ifndef REG_SZ
#define REG_SZ 1
//#define REG_BINARY 3
#define REG_DWORD 4
#define REG_QWORD 11
#endif
bool Data::fromXml(XMLHandle dbNode)
{
Name = ReadStringNode(dbNode, "NAME");
StringData = ReadStringNode(dbNode, "DATA_STRING");
if (!StringData.empty())
{
DataType = REG_SZ;
return !Name.empty();
}
DWordData = ReadDWordNode(dbNode, "DATA_DWORD");
if (DWordData)
{
DataType = REG_DWORD;
return !Name.empty();
}
QWordData = ReadQWordNode(dbNode, "DATA_QWORD");
if (QWordData)
{
DataType = REG_QWORD;
return !Name.empty();
}
SHIM_ERR("Data node (%s) without value!\n", Name.c_str());
return false;
}
bool Data::toSdb(PDB pdb, Database& db)
{
Tagid = db.BeginWriteListTag(pdb, TAG_DATA);
db.WriteString(pdb, TAG_NAME, Name, true);
db.WriteDWord(pdb, TAG_DATA_VALUETYPE, DataType, true);
switch (DataType)
{
case REG_SZ:
db.WriteString(pdb, TAG_DATA_STRING, StringData);
break;
case REG_DWORD:
db.WriteDWord(pdb, TAG_DATA_DWORD, DWordData);
break;
case REG_QWORD:
db.WriteQWord(pdb, TAG_DATA_QWORD, QWordData);
break;
default:
SHIM_ERR("Data node (%s) with unknown type (0x%x)\n", Name.c_str(), DataType);
return false;
}
return !!db.EndWriteListTag(pdb, Tagid);
}
/***********************************************************************
* Layer
*/
@ -407,6 +470,7 @@ bool Layer::fromXml(XMLHandle dbNode)
Name = ReadStringNode(dbNode, "NAME");
ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
ReadGeneric(dbNode, Datas, "DATA");
return true;
}
@ -418,6 +482,8 @@ bool Layer::toSdb(PDB pdb, Database& db)
return false;
if (!WriteGeneric(pdb, FlagRefs, db))
return false;
if (!WriteGeneric(pdb, Datas, db))
return false;
return !!db.EndWriteListTag(pdb, Tagid);
}

View file

@ -91,6 +91,22 @@ struct Flag
};
struct Data
{
Data() : Tagid(0), DataType(0), DWordData(0), QWordData(0) { ; }
bool fromXml(XMLHandle dbNode);
bool toSdb(PDB pdb, Database& db);
std::string Name;
TAGID Tagid;
DWORD DataType;
std::string StringData;
DWORD DWordData;
QWORD QWordData;
};
struct Layer
{
Layer() : Tagid(0) { ; }
@ -102,6 +118,7 @@ struct Layer
TAGID Tagid;
std::list<ShimRef> ShimRefs;
std::list<FlagRef> FlagRefs;
std::list<Data> Datas;
};
struct MatchingFile