ReactOS 0.4.15-dev-8131-g4988de4
xml2sdb.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: xml2sdb
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Conversion functions from xml -> db
5 * COPYRIGHT: Copyright 2016-2018 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include "xml2sdb.h"
9#include "sdbpapi.h"
10#include "tinyxml2.h"
11#include <time.h>
12#include <algorithm>
13
15
16static const GUID GUID_NULL = { 0 };
17static const char szCompilerVersion[] = "1.7.0.1";
18
19#if !defined(C_ASSERT)
20#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
21#endif
22
23
24C_ASSERT(sizeof(GUID) == 16);
25C_ASSERT(sizeof(ULONG) == 4);
26C_ASSERT(sizeof(LARGE_INTEGER) == 8);
27C_ASSERT(sizeof(WCHAR) == 2);
28C_ASSERT(sizeof(wchar_t) == 2);
29C_ASSERT(sizeof(TAG) == 2);
30C_ASSERT(sizeof(TAGID) == 4);
31
32
33extern "C"
36
37
38/***********************************************************************
39 * Helper functions
40 */
41
42
43// Convert utf8 to utf16:
44// http://stackoverflow.com/a/7154226/4928207
45
46bool IsEmptyGuid(const GUID& g)
47{
48 return !memcmp(&g, &GUID_NULL, sizeof(GUID));
49}
50
52{
53 BYTE* p = (BYTE*)&g;
54 for (size_t n = 0; n < sizeof(GUID); ++n)
55 p[n] = (BYTE)(rand() % 0xff);
56}
57
58// Given a node, return the node value (safe)
60{
61 XMLText* txtNode = node.FirstChild().ToText();
62 const char* txt = txtNode ? txtNode->Value() : NULL;
63 if (txt)
64 return std::string(txt);
65 return std::string();
66}
67
68// Given a node, return the node name (safe)
70{
71 tinyxml2::XMLNode* raw = node.ToNode();
72 const char* txt = raw ? raw->Value() : NULL;
73 if (txt)
74 return std::string(txt);
75 return std::string();
76}
77
78// Read either an attribute, or a child node
79std::string ReadStringNode(XMLHandle dbNode, const char* nodeName)
80{
82 if (elem)
83 {
84 const char* rawVal = elem->Attribute(nodeName);
85 if (rawVal)
86 return std::string(rawVal);
87 }
88 return ToString(dbNode.FirstChildElement(nodeName));
89}
90
91DWORD ReadQWordNode(XMLHandle dbNode, const char* nodeName)
92{
93 std::string value = ReadStringNode(dbNode, nodeName);
94 int base = 10;
95 if (value.size() > 2 && value[0] == '0' && value[1] == 'x')
96 {
97 base = 16;
98 value = value.substr(2);
99 }
100 return static_cast<QWORD>(strtoul(value.c_str(), NULL, base));
101}
102
103DWORD ReadDWordNode(XMLHandle dbNode, const char* nodeName)
104{
105 return static_cast<DWORD>(ReadQWordNode(dbNode, nodeName));
106}
107
108unsigned char char2byte(char hexChar, bool* success = NULL)
109{
110 if (hexChar >= '0' && hexChar <= '9')
111 return hexChar - '0';
112 if (hexChar >= 'A' && hexChar <= 'F')
113 return hexChar - 'A' + 10;
114 if (hexChar >= 'a' && hexChar <= 'f')
115 return hexChar - 'a' + 10;
116
117 if (success)
118 *success = false;
119 return 0;
120}
121
122// adapted from wine's ntdll\rtlstr.c rev 1.45
123static bool StringToGuid(const std::string& str, GUID& guid)
124{
125 const char *lpszGUID = str.c_str();
126 BYTE* lpOut = (BYTE*)&guid;
127 int i = 0;
128 bool expectBrace = true;
129 while (i <= 37)
130 {
131 switch (i)
132 {
133 case 0:
134 if (*lpszGUID != '{')
135 {
136 i++;
137 expectBrace = false;
138 continue;
139 }
140 break;
141
142 case 9:
143 case 14:
144 case 19:
145 case 24:
146 if (*lpszGUID != '-')
147 return false;
148 break;
149
150 case 37:
151 return expectBrace == (*lpszGUID == '}');
152
153 default:
154 {
155 CHAR ch = *lpszGUID, ch2 = lpszGUID[1];
156 unsigned char byte;
157 bool converted = true;
158
159 byte = char2byte(ch, &converted) << 4 | char2byte(ch2, &converted);
160 if (!converted)
161 return false;
162
163 switch (i)
164 {
165#ifndef WORDS_BIGENDIAN
166 /* For Big Endian machines, we store the data such that the
167 * dword/word members can be read as DWORDS and WORDS correctly. */
168 /* Dword */
169 case 1:
170 lpOut[3] = byte;
171 break;
172 case 3:
173 lpOut[2] = byte;
174 break;
175 case 5:
176 lpOut[1] = byte;
177 break;
178 case 7:
179 lpOut[0] = byte;
180 lpOut += 4;
181 break;
182 /* Word */
183 case 10:
184 case 15:
185 lpOut[1] = byte;
186 break;
187 case 12:
188 case 17:
189 lpOut[0] = byte;
190 lpOut += 2;
191 break;
192#endif
193 /* Byte */
194 default:
195 lpOut[0] = byte;
196 lpOut++;
197 break;
198 }
199
200 lpszGUID++; /* Skip 2nd character of byte */
201 i++;
202 }
203 }
204
205 lpszGUID++;
206 i++;
207 }
208 return false;
209}
210
211bool ReadGuidNode(XMLHandle dbNode, const char* nodeName, GUID& guid)
212{
213 std::string value = ReadStringNode(dbNode, nodeName);
214 if (!StringToGuid(value, guid))
215 {
216 memset(&guid, 0, sizeof(GUID));
217 return false;
218 }
219 return true;
220}
221
222bool ReadBinaryNode(XMLHandle dbNode, const char* nodeName, std::vector<BYTE>& data)
223{
224 std::string value = ReadStringNode(dbNode, nodeName);
225 value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
226
227 size_t length = value.size() / 2;
228 if (length * 2 != value.size())
229 return false;
230
231 data.resize(length);
232 for (size_t n = 0; n < length; ++n)
233 {
234 data[n] = (BYTE)(char2byte(value[n * 2]) << 4 | char2byte(value[(n * 2) + 1]));
235 }
236 return true;
237}
238
239
240/***********************************************************************
241 * InExclude
242 */
243
245{
246 Module = ReadStringNode(dbNode, "MODULE");
247 // Special module names: '$' and '*'
248 if (!Module.empty())
249 {
250 Include = ToNodeName(dbNode) == "INCLUDE";
251 return true;
252 }
253 return false;
254}
255
257{
259 db.WriteString(pdb, TAG_MODULE, Module, true);
260 if (Include)
262 return !!db.EndWriteListTag(pdb, tagid);
263}
264
265
266template<typename T>
267void ReadGeneric(XMLHandle dbNode, std::list<T>& result, const char* nodeName)
268{
269 XMLHandle node = dbNode.FirstChildElement(nodeName);
270 while (node.ToNode())
271 {
272 T object;
273 if (object.fromXml(node))
274 result.push_back(object);
275
276 node = node.NextSiblingElement(nodeName);
277 }
278}
279
280template<typename T>
281bool WriteGeneric(PDB pdb, std::list<T>& data, Database& db)
282{
283 for (typename std::list<T>::iterator it = data.begin(); it != data.end(); ++it)
284 {
285 if (!it->toSdb(pdb, db))
286 return false;
287 }
288 return true;
289}
290
291
292/***********************************************************************
293 * ShimRef
294 */
295
297{
298 Name = ReadStringNode(dbNode, "NAME");
299 CommandLine = ReadStringNode(dbNode, "COMMAND_LINE");
300 ReadGeneric(dbNode, InExcludes, "INCLUDE");
301 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
302 return !Name.empty();
303}
304
306{
308 db.WriteString(pdb, TAG_NAME, Name, true);
310
311 if (!ShimTagid)
314 return !!db.EndWriteListTag(pdb, tagid);
315}
316
317
318
319/***********************************************************************
320 * FlagRef
321 */
322
324{
325 Name = ReadStringNode(dbNode, "NAME");
326 return !Name.empty();
327}
328
330{
332 db.WriteString(pdb, TAG_NAME, Name, true);
333
334 if (!FlagTagid)
337 return !!db.EndWriteListTag(pdb, tagid);
338}
339
340
341/***********************************************************************
342 * Shim
343 */
344
346{
347 Name = ReadStringNode(dbNode, "NAME");
348 DllFile = ReadStringNode(dbNode, "DLLFILE");
349 ReadGuidNode(dbNode, "FIX_ID", FixID);
350 // GENERAL ?
351 // DESCRIPTION_RC_ID
352 ReadGeneric(dbNode, InExcludes, "INCLUDE");
353 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
354 return !Name.empty() && !DllFile.empty();
355}
356
358{
363 if (IsEmptyGuid(FixID))
366 if (!WriteGeneric(pdb, InExcludes, db))
367 return false;
368 return !!db.EndWriteListTag(pdb, Tagid);
369}
370
371
372/***********************************************************************
373 * Flag
374 */
375
377{
378 Name = ReadStringNode(dbNode, "NAME");
379
380 KernelFlags = ReadQWordNode(dbNode, "FLAG_MASK_KERNEL");
381 UserFlags = ReadQWordNode(dbNode, "FLAG_MASK_USER");
382 ProcessParamFlags = ReadQWordNode(dbNode, "FLAG_PROCESSPARAM");
383
384 return !Name.empty();
385}
386
388{
391 db.WriteString(pdb, TAG_NAME, Name, true);
392
396
397 return !!db.EndWriteListTag(pdb, Tagid);
398}
399
400
401/***********************************************************************
402 * Data
403 */
404
405#ifndef REG_SZ
406#define REG_SZ 1
407//#define REG_BINARY 3
408#define REG_DWORD 4
409#define REG_QWORD 11
410#endif
411
412
414{
415 Name = ReadStringNode(dbNode, "NAME");
416
417 StringData = ReadStringNode(dbNode, "DATA_STRING");
418 if (!StringData.empty())
419 {
421 return !Name.empty();
422 }
423 DWordData = ReadDWordNode(dbNode, "DATA_DWORD");
424 if (DWordData)
425 {
427 return !Name.empty();
428 }
429 QWordData = ReadQWordNode(dbNode, "DATA_QWORD");
430 if (QWordData)
431 {
433 return !Name.empty();
434 }
435
436 SHIM_ERR("Data node (%s) without value!\n", Name.c_str());
437 return false;
438}
439
441{
443 db.WriteString(pdb, TAG_NAME, Name, true);
445 switch (DataType)
446 {
447 case REG_SZ:
449 break;
450 case REG_DWORD:
452 break;
453 case REG_QWORD:
455 break;
456 default:
457 SHIM_ERR("Data node (%s) with unknown type (0x%x)\n", Name.c_str(), DataType);
458 return false;
459 }
460
461 return !!db.EndWriteListTag(pdb, Tagid);
462}
463
464/***********************************************************************
465 * Layer
466 */
467
469{
470 Name = ReadStringNode(dbNode, "NAME");
471 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
472 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
473 ReadGeneric(dbNode, Datas, "DATA");
474 return true;
475}
476
478{
480 db.WriteString(pdb, TAG_NAME, Name, true);
481 if (!WriteGeneric(pdb, ShimRefs, db))
482 return false;
483 if (!WriteGeneric(pdb, FlagRefs, db))
484 return false;
485 if (!WriteGeneric(pdb, Datas, db))
486 return false;
487 return !!db.EndWriteListTag(pdb, Tagid);
488}
489
490
491/***********************************************************************
492 * MatchingFile
493 */
494
496{
497 Name = ReadStringNode(dbNode, "NAME");
498 Size = ReadDWordNode(dbNode, "SIZE");
499 Checksum = ReadDWordNode(dbNode, "CHECKSUM");
500 CompanyName = ReadStringNode(dbNode, "COMPANY_NAME");
501 InternalName = ReadStringNode(dbNode, "INTERNAL_NAME");
502 ProductName = ReadStringNode(dbNode, "PRODUCT_NAME");
503 ProductVersion = ReadStringNode(dbNode, "PRODUCT_VERSION");
504 FileVersion = ReadStringNode(dbNode, "FILE_VERSION");
505 BinFileVersion = ReadStringNode(dbNode, "BIN_FILE_VERSION");
506 LinkDate = ReadDWordNode(dbNode, "LINK_DATE");
507 VerLanguage = ReadStringNode(dbNode, "VER_LANGUAGE");
508 FileDescription = ReadStringNode(dbNode, "FILE_DESCRIPTION");
509 OriginalFilename = ReadStringNode(dbNode, "ORIGINAL_FILENAME");
510 UptoBinFileVersion = ReadStringNode(dbNode, "UPTO_BIN_FILE_VERSION");
511 LinkerVersion = ReadDWordNode(dbNode, "LINKER_VERSION");
512 return true;
513}
514
516{
518
519 db.WriteString(pdb, TAG_NAME, Name, true);
527 if (!BinFileVersion.empty())
528 SHIM_ERR("TAG_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(pdb, TAG_BIN_FILE_VERSION, BinFileVersion);
530 if (!VerLanguage.empty())
531 SHIM_ERR("TAG_VER_LANGUAGE Unimplemented\n"); //db.WriteDWord(pdb, TAG_VER_LANGUAGE, VerLanguage);
534 if (!UptoBinFileVersion.empty())
535 SHIM_ERR("TAG_UPTO_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(pdb, TAG_UPTO_BIN_FILE_VERSION, UptoBinFileVersion);
537
538 return !!db.EndWriteListTag(pdb, tagid);
539}
540
541
542/***********************************************************************
543 * Exe
544 */
545
547{
548 Name = ReadStringNode(dbNode, "NAME");
549 ReadGuidNode(dbNode, "EXE_ID", ExeID);
550 AppName = ReadStringNode(dbNode, "APP_NAME");
551 Vendor = ReadStringNode(dbNode, "VENDOR");
552
553 ReadGeneric(dbNode, MatchingFiles, "MATCHING_FILE");
554
555 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
556 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
557
558 return !Name.empty();
559}
560
562{
564
565 db.WriteString(pdb, TAG_NAME, Name, true);
566 if (IsEmptyGuid(ExeID))
569
570
573
574 if (!WriteGeneric(pdb, MatchingFiles, db))
575 return false;
576 if (!WriteGeneric(pdb, ShimRefs, db))
577 return false;
578 if (!WriteGeneric(pdb, FlagRefs, db))
579 return false;
580
581 return !!db.EndWriteListTag(pdb, Tagid);
582}
583
584
585/***********************************************************************
586 * Database
587 */
588
589void Database::WriteBinary(PDB pdb, TAG tag, const GUID& guid, bool always)
590{
591 if (always || !IsEmptyGuid(guid))
592 SdbWriteBinaryTag(pdb, tag, (BYTE*)&guid, sizeof(GUID));
593}
594
595void Database::WriteBinary(PDB pdb, TAG tag, const std::vector<BYTE>& data, bool always)
596{
597 if (always || !data.empty())
598 SdbWriteBinaryTag(pdb, tag, data.data(), data.size());
599}
600
601void Database::WriteString(PDB pdb, TAG tag, const sdbstring& str, bool always)
602{
603 if (always || !str.empty())
604 SdbWriteStringTag(pdb, tag, (LPCWSTR)str.c_str());
605}
606
607void Database::WriteString(PDB pdb, TAG tag, const std::string& str, bool always)
608{
609 WriteString(pdb, tag, sdbstring(str.begin(), str.end()), always);
610}
611
613{
614 if (always || value)
616}
617
619{
620 if (always || value)
622}
623
625{
627}
628
630{
631 return SdbEndWriteListTag(pdb, tagid);
632}
633
635{
636 Name = ReadStringNode(dbNode, "NAME");
637 ReadGuidNode(dbNode, "DATABASE_ID", ID);
638
639 XMLHandle libChild = dbNode.FirstChildElement("LIBRARY").FirstChild();
640 while (libChild.ToNode())
641 {
642 std::string NodeName = ToNodeName(libChild);
643 if (NodeName == "SHIM")
644 {
645 Shim shim;
646 if (shim.fromXml(libChild))
647 Library.Shims.push_back(shim);
648 }
649 else if (NodeName == "FLAG")
650 {
651 Flag flag;
652 if (flag.fromXml(libChild))
653 Library.Flags.push_back(flag);
654 }
655 else if (NodeName == "INCLUDE" || NodeName == "EXCLUDE")
656 {
657 InExclude inex;
658 if (inex.fromXml(libChild))
659 Library.InExcludes.push_back(inex);
660 }
661 libChild = libChild.NextSibling();
662 }
663
664 ReadGeneric(dbNode, Layers, "LAYER");
665 ReadGeneric(dbNode, Exes, "EXE");
666 return true;
667}
668
669bool Database::fromXml(const char* fileName)
670{
672 tinyxml2::XMLError err = doc.LoadFile(fileName);
673 XMLHandle dbHandle = tinyxml2::XMLHandle(&doc).FirstChildElement("SDB").FirstChildElement("DATABASE");
674 return fromXml(dbHandle);
675}
676
678{
680 TAGID tidDatabase = BeginWriteListTag(pdb, TAG_DATABASE);
681 LARGE_INTEGER li = { 0 };
686 WriteString(pdb, TAG_NAME, Name, true);
687 if (IsEmptyGuid(ID))
688 {
689 SHIM_WARN("DB has empty ID!\n");
690 RandomGuid(ID);
691 }
693 TAGID tidLibrary = BeginWriteListTag(pdb, TAG_LIBRARY);
694 if (!WriteGeneric(pdb, Library.InExcludes, *this))
695 return false;
696 if (!WriteGeneric(pdb, Library.Shims, *this))
697 return false;
698 if (!WriteGeneric(pdb, Library.Flags, *this))
699 return false;
700 EndWriteListTag(pdb, tidLibrary);
701 if (!WriteGeneric(pdb, Layers, *this))
702 return false;
703 if (!WriteGeneric(pdb, Exes, *this))
704 return false;
705 EndWriteListTag(pdb, tidDatabase);
706
708 return true;
709}
710
711static void InsertTagid(const sdbstring& name, TAGID tagid, std::map<sdbstring, TAGID>& lookup, const char* type)
712{
713 sdbstring nameLower = name;
714 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
715 if (lookup.find(nameLower) != lookup.end())
716 {
717 std::string nameA(name.begin(), name.end());
718 SHIM_WARN("%s '%s' redefined\n", type, nameA.c_str());
719 return;
720 }
721 lookup[nameLower] = tagid;
722}
723
724static TAGID FindTagid(const sdbstring& name, const std::map<sdbstring, TAGID>& lookup)
725{
726 sdbstring nameLower = name;
727 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
728 std::map<sdbstring, TAGID>::const_iterator it = lookup.find(nameLower);
729 if (it == lookup.end())
730 return 0;
731 return it->second;
732}
733
735{
736 InsertTagid(name, tagid, KnownShims, "Shim");
737}
738
740{
741 return FindTagid(name, KnownShims);
742}
743
745{
746 InsertTagid(name, tagid, KnownPatches, "Patch");
747}
748
750{
751 return FindTagid(name, KnownPatches);
752}
753
755{
756 InsertTagid(name, tagid, KnownFlags, "Flag");
757}
758
760{
761 return FindTagid(name, KnownFlags);
762}
763
764
765bool xml_2_db(const char* xml, const WCHAR* sdb)
766{
767 Database db;
768 if (db.fromXml(xml))
769 {
770 return db.toSdb((LPCWSTR)sdb);
771 }
772 return false;
773}
#define isspace(c)
Definition: acclib.h:69
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
int tolower(int c)
Definition: utclib.c:902
DWORD TAGID
XMLError LoadFile(const char *filename)
Definition: tinyxml2.cpp:1906
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1810
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1843
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1814
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1834
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1847
const char * Value() const
Definition: tinyxml2.cpp:719
static PDB pdb
Definition: db.cpp:172
#define TAG_MODULE
Definition: db.cpp:99
#define TAG_LAYER
Definition: db.cpp:90
#define TAG_DATABASE_ID
Definition: db.cpp:122
#define TAG_EXE
Definition: db.cpp:87
#define TAG_INEXCLUD
Definition: db.cpp:86
#define TAG_APP_NAME
Definition: db.cpp:101
#define DOS_PATH
Definition: db.cpp:32
#define TAG_VENDOR
Definition: db.cpp:100
#define TAG_COMMAND_LINE
Definition: db.cpp:102
#define TAG_MATCHING_FILE
Definition: db.cpp:88
#define TAG_DATA
Definition: db.cpp:93
#define TAG_COMPILER_VERSION
Definition: db.cpp:116
#define TAG_INCLUDE
Definition: db.cpp:56
#define TAG_OS_PLATFORM
Definition: db.cpp:76
#define TAG_EXE_ID
Definition: db.cpp:120
#define TAG_SHIM_REF
Definition: db.cpp:89
#define TAG_DATABASE
Definition: db.cpp:85
#define TAG_TIME
Definition: db.cpp:78
#define NULL
Definition: types.h:112
#define byte(x, n)
Definition: tomcrypt.h:118
static ULONG lookup[16]
Definition: vga.c:48
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble n
Definition: glext.h:7729
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define REG_SZ
Definition: layer.c:22
#define T
Definition: mbstring.h:31
const GUID * guid
__u16 time
Definition: mkdosfs.c:8
#define TAG_ORIGINAL_FILENAME
Definition: apphelp.c:69
#define TAG_LINKER_VERSION
Definition: apphelp.c:55
#define TAG_SIZE
Definition: apphelp.c:46
#define TAG_FILE_DESCRIPTION
Definition: apphelp.c:67
#define TAG_FILE_VERSION
Definition: apphelp.c:68
#define TAG_PRODUCT_NAME
Definition: apphelp.c:65
#define TAG_CHECKSUM
Definition: apphelp.c:47
#define TAG_COMPANY_NAME
Definition: apphelp.c:64
#define TAG_LINK_DATE
Definition: apphelp.c:56
#define TAG_INTERNAL_NAME
Definition: apphelp.c:70
#define TAG_PRODUCT_VERSION
Definition: apphelp.c:66
static size_t elem
Definition: string.c:68
static PLARGE_INTEGER Time
Definition: time.c:105
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define err(...)
const WCHAR * str
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77
#define SHIM_ERR(fmt,...)
Definition: sdbpapi.h:76
#define TAG_FLAG_REF
Definition: sdbtagid.h:183
#define TAG_FIX_ID
Definition: sdbtagid.h:205
#define TAG_FLAG_PROCESSPARAM
Definition: sdbtagid.h:124
#define TAG_SHIM_TAGID
Definition: sdbtagid.h:67
#define TAG_LIBRARY
Definition: sdbtagid.h:164
#define TAG_DATA_VALUETYPE
Definition: sdbtagid.h:86
#define TAG_DATA_QWORD
Definition: sdbtagid.h:116
#define TAG_FLAG_MASK_KERNEL
Definition: sdbtagid.h:114
#define TAG_DATA_STRING
Definition: sdbtagid.h:153
#define TAG_FLAG_MASK_USER
Definition: sdbtagid.h:117
#define TAG_FLAG_TAGID
Definition: sdbtagid.h:94
#define TAG_FLAG
Definition: sdbtagid.h:181
#define TAG_DLLFILE
Definition: sdbtagid.h:137
#define TAG_DATA_DWORD
Definition: sdbtagid.h:87
BOOL WINAPI SdbWriteNULLTag(PDB pdb, TAG tag)
Definition: sdbwrite.c:145
TAGID WINAPI SdbBeginWriteListTag(PDB pdb, TAG tag)
Definition: sdbwrite.c:321
BOOL WINAPI SdbWriteQWORDTag(PDB pdb, TAG tag, QWORD data)
Definition: sdbwrite.c:201
BOOL WINAPI SdbWriteStringTag(PDB pdb, TAG tag, LPCWSTR string)
Definition: sdbwrite.c:220
BOOL WINAPI SdbWriteDWORDTag(PDB pdb, TAG tag, DWORD data)
Definition: sdbwrite.c:182
BOOL WINAPI SdbEndWriteListTag(PDB pdb, TAGID tagid)
Definition: sdbwrite.c:343
BOOL WINAPI SdbWriteBinaryTag(PDB pdb, TAG tag, const BYTE *data, DWORD size)
Definition: sdbwrite.c:273
PDB WINAPI SdbCreateDatabase(LPCWSTR path, PATH_TYPE type)
Definition: sdbwrite.c:104
void WINAPI SdbCloseDatabaseWrite(PDB pdb)
Definition: sdbwrite.c:129
#define memset(x, y, z)
Definition: compat.h:39
UINT64 QWORD
Definition: shimdbg.c:104
DataType
Definition: simd.h:252
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:440
DWORD DWordData
Definition: xml2sdb.h:106
std::string StringData
Definition: xml2sdb.h:105
QWORD QWordData
Definition: xml2sdb.h:107
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:413
TAGID Tagid
Definition: xml2sdb.h:102
void InsertShimTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:734
TAGID FindShimTagid(const sdbstring &name)
Definition: xml2sdb.cpp:739
GUID ID
Definition: xml2sdb.h:223
void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always=false)
Definition: xml2sdb.cpp:612
TAGID FindPatchTagid(const sdbstring &name)
Definition: xml2sdb.cpp:749
void WriteBinary(PDB pdb, TAG tag, const GUID &guid, bool always=false)
Definition: xml2sdb.cpp:589
BOOL EndWriteListTag(PDB pdb, TAGID tagid)
Definition: xml2sdb.cpp:629
TAGID FindFlagTagid(const sdbstring &name)
Definition: xml2sdb.cpp:759
void WriteQWord(PDB pdb, TAG tag, QWORD value, bool always=false)
Definition: xml2sdb.cpp:618
std::map< sdbstring, TAGID > KnownPatches
Definition: xml2sdb.h:231
TAGID BeginWriteListTag(PDB pdb, TAG tag)
Definition: xml2sdb.cpp:624
std::list< Exe > Exes
Definition: xml2sdb.h:227
std::map< sdbstring, TAGID > KnownFlags
Definition: xml2sdb.h:232
bool toSdb(LPCWSTR path)
Definition: xml2sdb.cpp:677
void InsertPatchTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:744
void WriteString(PDB pdb, TAG tag, const sdbstring &str, bool always=false)
Definition: xml2sdb.cpp:601
void InsertFlagTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:754
std::map< sdbstring, TAGID > KnownShims
Definition: xml2sdb.h:230
std::list< Layer > Layers
Definition: xml2sdb.h:226
bool fromXml(const char *fileName)
Definition: xml2sdb.cpp:669
std::list< MatchingFile > MatchingFiles
Definition: xml2sdb.h:160
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:546
TAGID Tagid
Definition: xml2sdb.h:159
std::string AppName
Definition: xml2sdb.h:157
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:561
GUID ExeID
Definition: xml2sdb.h:156
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:161
std::string Vendor
Definition: xml2sdb.h:158
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:162
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:323
TAGID FlagTagid
Definition: xml2sdb.h:62
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:329
Definition: xml2sdb.h:80
TAGID Tagid
Definition: xml2sdb.h:87
QWORD ProcessParamFlags
Definition: xml2sdb.h:90
QWORD KernelFlags
Definition: xml2sdb.h:88
QWORD UserFlags
Definition: xml2sdb.h:89
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:376
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:387
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:256
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:244
std::string Module
Definition: xml2sdb.h:37
bool Include
Definition: xml2sdb.h:38
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:468
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:120
std::list< Data > Datas
Definition: xml2sdb.h:121
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:119
TAGID Tagid
Definition: xml2sdb.h:118
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:477
std::list< Shim > Shims
Definition: xml2sdb.h:168
std::list< InExclude > InExcludes
Definition: xml2sdb.h:167
std::list< Flag > Flags
Definition: xml2sdb.h:169
std::string OriginalFilename
Definition: xml2sdb.h:143
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:515
std::string InternalName
Definition: xml2sdb.h:135
DWORD LinkDate
Definition: xml2sdb.h:140
std::string ProductVersion
Definition: xml2sdb.h:137
DWORD LinkerVersion
Definition: xml2sdb.h:145
std::string FileDescription
Definition: xml2sdb.h:142
std::string ProductName
Definition: xml2sdb.h:136
std::string BinFileVersion
Definition: xml2sdb.h:139
std::string CompanyName
Definition: xml2sdb.h:134
std::string UptoBinFileVersion
Definition: xml2sdb.h:144
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:495
DWORD Checksum
Definition: xml2sdb.h:133
std::string VerLanguage
Definition: xml2sdb.h:141
std::string FileVersion
Definition: xml2sdb.h:138
std::string CommandLine
Definition: xml2sdb.h:49
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:296
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:305
std::list< InExclude > InExcludes
Definition: xml2sdb.h:51
TAGID ShimTagid
Definition: xml2sdb.h:50
Definition: xml2sdb.h:66
GUID FixID
Definition: xml2sdb.h:74
std::list< InExclude > InExcludes
Definition: xml2sdb.h:76
std::string DllFile
Definition: xml2sdb.h:73
TAGID Tagid
Definition: xml2sdb.h:75
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:345
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:357
Definition: fs_rec.h:143
Definition: name.c:39
Definition: ecma_167.h:138
#define TAG_SHIM
Definition: tag.h:138
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define hexChar
Definition: udf_info.cpp:45
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: dlist.c:348
Definition: pdh_main.c:94
#define TAG_NAME
Definition: vfat.h:553
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define success(from, fromstr, to, tostr)
static const GUID GUID_NULL
Definition: xml2sdb.cpp:16
static TAGID FindTagid(const sdbstring &name, const std::map< sdbstring, TAGID > &lookup)
Definition: xml2sdb.cpp:724
bool ReadGuidNode(XMLHandle dbNode, const char *nodeName, GUID &guid)
Definition: xml2sdb.cpp:211
static bool StringToGuid(const std::string &str, GUID &guid)
Definition: xml2sdb.cpp:123
static const char szCompilerVersion[]
Definition: xml2sdb.cpp:17
std::string ToString(XMLHandle node)
Definition: xml2sdb.cpp:59
VOID NTAPI RtlSecondsSince1970ToTime(IN ULONG SecondsSince1970, OUT PLARGE_INTEGER Time)
Definition: time.c:406
void RandomGuid(GUID &g)
Definition: xml2sdb.cpp:51
unsigned char char2byte(char hexChar, bool *success=NULL)
Definition: xml2sdb.cpp:108
DWORD ReadDWordNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:103
bool WriteGeneric(PDB pdb, std::list< T > &data, Database &db)
Definition: xml2sdb.cpp:281
bool xml_2_db(const char *xml, const WCHAR *sdb)
Definition: xml2sdb.cpp:765
DWORD ReadQWordNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:91
#define C_ASSERT(expr)
Definition: xml2sdb.cpp:20
static void InsertTagid(const sdbstring &name, TAGID tagid, std::map< sdbstring, TAGID > &lookup, const char *type)
Definition: xml2sdb.cpp:711
void ReadGeneric(XMLHandle dbNode, std::list< T > &result, const char *nodeName)
Definition: xml2sdb.cpp:267
std::string ToNodeName(XMLHandle node)
Definition: xml2sdb.cpp:69
std::string ReadStringNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:79
bool ReadBinaryNode(XMLHandle dbNode, const char *nodeName, std::vector< BYTE > &data)
Definition: xml2sdb.cpp:222
bool IsEmptyGuid(const GUID &g)
Definition: xml2sdb.cpp:46
std::basic_string< WCHAR > sdbstring
Definition: xml2sdb.h:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193