ReactOS 0.4.17-dev-1190-g4c812f4
xml2sdb.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: xml2sdb
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Conversion functions from xml -> db
5 * COPYRIGHT: Copyright 2016-2026 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#include <sstream>
14
16
17static const GUID GUID_NULL = { 0 };
18static const char szCompilerVersion[] = "1.8.1.0";
19
20#if !defined(C_ASSERT)
21#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
22#endif
23
24
25C_ASSERT(sizeof(GUID) == 16);
26C_ASSERT(sizeof(ULONG) == 4);
27C_ASSERT(sizeof(LARGE_INTEGER) == 8);
28C_ASSERT(sizeof(WCHAR) == 2);
29C_ASSERT(sizeof(wchar_t) == 2);
30C_ASSERT(sizeof(TAG) == 2);
31C_ASSERT(sizeof(TAGID) == 4);
32
33
34extern "C"
37
38
39/***********************************************************************
40 * Helper functions
41 */
43 {"X86", PLATFORM_X86},
44 {"I386", PLATFORM_X86},
45 {"AMD64", PLATFORM_AMD64},
46 {"ANY", PLATFORM_ANY},
47 {nullptr, 0},
48};
49
51str_to_enum(const std::string& str, const str_to_flag* table)
52{
53 DWORD value = 0;
54 std::istringstream iss(str);
55 std::string item;
56 while (std::getline(iss, item, ','))
57 {
58 std::string trimmedItem = item;
59 trimmedItem.erase(remove_if(trimmedItem.begin(), trimmedItem.end(), isspace), trimmedItem.end());
60 std::transform(trimmedItem.begin(), trimmedItem.end(), trimmedItem.begin(), ::toupper);
61 for (const str_to_flag* p = table; p->name; ++p)
62 {
63 if (trimmedItem == p->name)
64 {
65 value |= p->flag;
66 break;
67 }
68 }
69 }
70 return value;
71}
72
73
74// Convert utf8 to utf16:
75// http://stackoverflow.com/a/7154226/4928207
76
77bool IsEmptyGuid(const GUID& g)
78{
79 return !memcmp(&g, &GUID_NULL, sizeof(GUID));
80}
81
83{
84 BYTE* p = (BYTE*)&g;
85 for (size_t n = 0; n < sizeof(GUID); ++n)
86 p[n] = (BYTE)(rand() % 0xff);
87}
88
89// Given a node, return the node value (safe)
91{
92 XMLText* txtNode = node.FirstChild().ToText();
93 const char* txt = txtNode ? txtNode->Value() : NULL;
94 if (txt)
95 return std::string(txt);
96 return std::string();
97}
98
99// Given a node, return the node name (safe)
101{
102 tinyxml2::XMLNode* raw = node.ToNode();
103 const char* txt = raw ? raw->Value() : NULL;
104 if (txt)
105 return std::string(txt);
106 return std::string();
107}
108
109// Read either an attribute, or a child node
110std::string ReadStringNode(XMLHandle dbNode, const char* nodeName)
111{
113 if (elem)
114 {
115 const char* rawVal = elem->Attribute(nodeName);
116 if (rawVal)
117 return std::string(rawVal);
118 }
119 return ToString(dbNode.FirstChildElement(nodeName));
120}
121
122QWORD ReadQWordNode(XMLHandle dbNode, const char* nodeName)
123{
124 std::string value = ReadStringNode(dbNode, nodeName);
125 int base = 10;
126 if (value.size() > 2 && value[0] == '0' && value[1] == 'x')
127 {
128 base = 16;
129 value = value.substr(2);
130 }
131 return static_cast<QWORD>(strtoull(value.c_str(), NULL, base));
132}
133
134DWORD ReadDWordNode(XMLHandle dbNode, const char* nodeName)
135{
136 return static_cast<DWORD>(ReadQWordNode(dbNode, nodeName));
137}
138
139PlatformType ReadPlatformNode(XMLHandle dbNode, const char *nodeName)
140{
141 std::string value = ReadStringNode(dbNode, nodeName);
142 if (value.empty())
143 return PLATFORM_ANY;
145 return static_cast<PlatformType>(platform);
146}
147
148unsigned char char2byte(char hexChar, bool* success = NULL)
149{
150 if (hexChar >= '0' && hexChar <= '9')
151 return hexChar - '0';
152 if (hexChar >= 'A' && hexChar <= 'F')
153 return hexChar - 'A' + 10;
154 if (hexChar >= 'a' && hexChar <= 'f')
155 return hexChar - 'a' + 10;
156
157 if (success)
158 *success = false;
159 return 0;
160}
161
162// adapted from wine's ntdll\rtlstr.c rev 1.45
163static bool StringToGuid(const std::string& str, GUID& guid)
164{
165 const char *lpszGUID = str.c_str();
166 BYTE* lpOut = (BYTE*)&guid;
167 int i = 0;
168 bool expectBrace = true;
169 while (i <= 37)
170 {
171 switch (i)
172 {
173 case 0:
174 if (*lpszGUID != '{')
175 {
176 i++;
177 expectBrace = false;
178 continue;
179 }
180 break;
181
182 case 9:
183 case 14:
184 case 19:
185 case 24:
186 if (*lpszGUID != '-')
187 return false;
188 break;
189
190 case 37:
191 return expectBrace == (*lpszGUID == '}');
192
193 default:
194 {
195 CHAR ch = *lpszGUID, ch2 = lpszGUID[1];
196 unsigned char byte;
197 bool converted = true;
198
199 byte = char2byte(ch, &converted) << 4 | char2byte(ch2, &converted);
200 if (!converted)
201 return false;
202
203 switch (i)
204 {
205#ifndef WORDS_BIGENDIAN
206 /* For Big Endian machines, we store the data such that the
207 * dword/word members can be read as DWORDS and WORDS correctly. */
208 /* Dword */
209 case 1:
210 lpOut[3] = byte;
211 break;
212 case 3:
213 lpOut[2] = byte;
214 break;
215 case 5:
216 lpOut[1] = byte;
217 break;
218 case 7:
219 lpOut[0] = byte;
220 lpOut += 4;
221 break;
222 /* Word */
223 case 10:
224 case 15:
225 lpOut[1] = byte;
226 break;
227 case 12:
228 case 17:
229 lpOut[0] = byte;
230 lpOut += 2;
231 break;
232#endif
233 /* Byte */
234 default:
235 lpOut[0] = byte;
236 lpOut++;
237 break;
238 }
239
240 lpszGUID++; /* Skip 2nd character of byte */
241 i++;
242 }
243 }
244
245 lpszGUID++;
246 i++;
247 }
248 return false;
249}
250
251bool ReadGuidNode(XMLHandle dbNode, const char* nodeName, GUID& guid)
252{
253 std::string value = ReadStringNode(dbNode, nodeName);
254 if (!StringToGuid(value, guid))
255 {
256 memset(&guid, 0, sizeof(GUID));
257 return false;
258 }
259 return true;
260}
261
262bool ReadBinaryNode(XMLHandle dbNode, const char* nodeName, std::vector<BYTE>& data)
263{
264 std::string value = ReadStringNode(dbNode, nodeName);
265 value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
266
267 size_t length = value.size() / 2;
268 if (length * 2 != value.size())
269 return false;
270
271 data.resize(length);
272 for (size_t n = 0; n < length; ++n)
273 {
274 data[n] = (BYTE)(char2byte(value[n * 2]) << 4 | char2byte(value[(n * 2) + 1]));
275 }
276 return true;
277}
278
279
280/***********************************************************************
281 * InExclude
282 */
283
285{
286 Module = ReadStringNode(dbNode, "MODULE");
287 // Special module names: '$' and '*'
288 if (!Module.empty())
289 {
290 Include = ToNodeName(dbNode) == "INCLUDE";
291 return true;
292 }
293 return false;
294}
295
297{
299 db.WriteString(TAG_MODULE, Module, true);
300 if (Include)
302 return !!db.EndWriteListTag(tagid);
303}
304
305
306template<typename T>
307void ReadGeneric(XMLHandle dbNode, std::list<T>& result, const char* nodeName)
308{
309 XMLHandle node = dbNode.FirstChildElement(nodeName);
310 while (node.ToNode())
311 {
312 T object;
313 if (object.fromXml(node))
314 result.push_back(object);
315
316 node = node.NextSiblingElement(nodeName);
317 }
318}
319
320template<typename T>
321void ReadGeneric(XMLHandle dbNode, std::list<T>& result, const char* nodeName, PlatformType platform)
322{
323 XMLHandle node = dbNode.FirstChildElement(nodeName);
324 while (node.ToNode())
325 {
326 T object;
327 if (object.fromXml(node) && ((object.Platform & platform) != PLATFORM_NONE))
328 result.push_back(object);
329
330 node = node.NextSiblingElement(nodeName);
331 }
332}
333
334template<typename T>
335bool WriteGeneric(std::list<T>& data, Database& db)
336{
337 for (typename std::list<T>::iterator it = data.begin(); it != data.end(); ++it)
338 {
339 if (!it->toSdb(db))
340 return false;
341 }
342 return true;
343}
344
345
346/***********************************************************************
347 * ShimRef
348 */
349
351{
352 Name = ReadStringNode(dbNode, "NAME");
353 CommandLine = ReadStringNode(dbNode, "COMMAND_LINE");
354 KShim = ToNodeName(dbNode) == "KSHIM_REF";
355 if (!KShim)
356 {
357 ReadGeneric(dbNode, InExcludes, "INCLUDE");
358 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
359 }
360 return !Name.empty();
361}
362
364{
366 db.WriteString(TAG_NAME, Name, true);
368
369 if (KShim)
370 {
371 std::string Module = db.FindKShimModule(Name);
372 if (Module.empty())
373 {
374 SHIM_ERR("Unknown kernel shim '%s'\n", Name.c_str());
375 return false;
376 }
377 db.WriteString(TAG_MODULE, Module, true);
378 }
379 else
380 {
381 if (!ShimTagid)
384 }
385 return !!db.EndWriteListTag(tagid);
386}
387
388
389
390/***********************************************************************
391 * FlagRef
392 */
393
395{
396 Name = ReadStringNode(dbNode, "NAME");
397 return !Name.empty();
398}
399
401{
403 db.WriteString(TAG_NAME, Name, true);
404
405 if (!FlagTagid)
408 return !!db.EndWriteListTag(tagid);
409}
410
411
412/***********************************************************************
413 * Shim
414 */
415
417{
418 Name = ReadStringNode(dbNode, "NAME");
419 KShim = ToNodeName(dbNode) == "KSHIM";
420 // Kernel shims are implemented in a module (for example 'NT kernel component')
421 DllFile = ReadStringNode(dbNode, KShim ? "MODULE" : "DLLFILE");
422 ReadGuidNode(dbNode, "FIX_ID", FixID);
423 // GENERAL ?
424 // DESCRIPTION_RC_ID
425 if (!KShim)
426 {
427 ReadGeneric(dbNode, InExcludes, "INCLUDE");
428 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
429 }
430 return !Name.empty() && !DllFile.empty();
431}
432
434{
436 if (!KShim)
440 if (IsEmptyGuid(FixID))
443 if (!WriteGeneric(InExcludes, db))
444 return false;
445 return !!db.EndWriteListTag(Tagid);
446}
447
448
449/***********************************************************************
450 * Flag
451 */
452
454{
455 Name = ReadStringNode(dbNode, "NAME");
456
457 KernelFlags = ReadQWordNode(dbNode, "FLAG_MASK_KERNEL");
458 UserFlags = ReadQWordNode(dbNode, "FLAG_MASK_USER");
459 ProcessParamFlags = ReadQWordNode(dbNode, "FLAG_PROCESSPARAM");
460
461 return !Name.empty();
462}
463
465{
468 db.WriteString(TAG_NAME, Name, true);
469
473
474 return !!db.EndWriteListTag(Tagid);
475}
476
477
478/***********************************************************************
479 * Data
480 */
481
482#ifndef REG_SZ
483#define REG_SZ 1
484//#define REG_BINARY 3
485#define REG_DWORD 4
486#define REG_QWORD 11
487#endif
488
489
491{
492 Name = ReadStringNode(dbNode, "NAME");
493
494 StringData = ReadStringNode(dbNode, "DATA_STRING");
495 if (!StringData.empty())
496 {
498 return !Name.empty();
499 }
500 DWordData = ReadDWordNode(dbNode, "DATA_DWORD");
501 if (DWordData)
502 {
504 return !Name.empty();
505 }
506 QWordData = ReadQWordNode(dbNode, "DATA_QWORD");
507 if (QWordData)
508 {
510 return !Name.empty();
511 }
512
513 SHIM_ERR("Data node (%s) without value!\n", Name.c_str());
514 return false;
515}
516
518{
520 db.WriteString(TAG_NAME, Name, true);
522 switch (DataType)
523 {
524 case REG_SZ:
526 break;
527 case REG_DWORD:
529 break;
530 case REG_QWORD:
532 break;
533 default:
534 SHIM_ERR("Data node (%s) with unknown type (0x%x)\n", Name.c_str(), DataType);
535 return false;
536 }
537
538 return !!db.EndWriteListTag(Tagid);
539}
540
541/***********************************************************************
542 * Layer
543 */
544
546{
547 Name = ReadStringNode(dbNode, "NAME");
548 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
549 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
550 ReadGeneric(dbNode, Datas, "DATA");
551 return true;
552}
553
555{
557 db.WriteString(TAG_NAME, Name, true);
558 if (!WriteGeneric(ShimRefs, db))
559 return false;
560 if (!WriteGeneric(FlagRefs, db))
561 return false;
562 if (!WriteGeneric(Datas, db))
563 return false;
564 return !!db.EndWriteListTag(Tagid);
565}
566
567
568/***********************************************************************
569 * MatchingFile
570 */
571
573{
574 Name = ReadStringNode(dbNode, "NAME");
575 Size = ReadDWordNode(dbNode, "SIZE");
576 Checksum = ReadDWordNode(dbNode, "CHECKSUM");
577 CompanyName = ReadStringNode(dbNode, "COMPANY_NAME");
578 InternalName = ReadStringNode(dbNode, "INTERNAL_NAME");
579 ProductName = ReadStringNode(dbNode, "PRODUCT_NAME");
580 ProductVersion = ReadStringNode(dbNode, "PRODUCT_VERSION");
581 FileVersion = ReadStringNode(dbNode, "FILE_VERSION");
582 BinFileVersion = ReadStringNode(dbNode, "BIN_FILE_VERSION");
583 LinkDate = ReadDWordNode(dbNode, "LINK_DATE");
584 VerLanguage = ReadStringNode(dbNode, "VER_LANGUAGE");
585 FileDescription = ReadStringNode(dbNode, "FILE_DESCRIPTION");
586 OriginalFilename = ReadStringNode(dbNode, "ORIGINAL_FILENAME");
587 UptoBinFileVersion = ReadStringNode(dbNode, "UPTO_BIN_FILE_VERSION");
588 LinkerVersion = ReadDWordNode(dbNode, "LINKER_VERSION");
589 return true;
590}
591
593{
595
596 db.WriteString(TAG_NAME, Name, true);
604 if (!BinFileVersion.empty())
605 SHIM_ERR("TAG_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(TAG_BIN_FILE_VERSION, BinFileVersion);
607 if (!VerLanguage.empty())
608 SHIM_ERR("TAG_VER_LANGUAGE Unimplemented\n"); //db.WriteDWord(TAG_VER_LANGUAGE, VerLanguage);
611 if (!UptoBinFileVersion.empty())
612 SHIM_ERR("TAG_UPTO_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(TAG_UPTO_BIN_FILE_VERSION, UptoBinFileVersion);
614
615 return !!db.EndWriteListTag(tagid);
616}
617
618
619/***********************************************************************
620 * Exe
621 */
622
624{
625 Name = ReadStringNode(dbNode, "NAME");
626 ReadGuidNode(dbNode, "EXE_ID", ExeID);
627 AppName = ReadStringNode(dbNode, "APP_NAME");
628 Vendor = ReadStringNode(dbNode, "VENDOR");
629
630 ReadGeneric(dbNode, MatchingFiles, "MATCHING_FILE");
631
632 KDriver = ToNodeName(dbNode) == "KDRIVER";
633 if (KDriver)
634 {
635 ReadGeneric(dbNode, ShimRefs, "KSHIM_REF");
636 }
637 else
638 {
639 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
640 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
641 }
642
643 Platform = ReadPlatformNode(dbNode, "RUNTIME_PLATFORM");
644
645 return !Name.empty();
646}
647
649{
651
652 db.WriteString(TAG_NAME, Name, true);
653 if (IsEmptyGuid(ExeID))
656
657
660
661 if (!WriteGeneric(MatchingFiles, db))
662 return false;
663 if (!WriteGeneric(ShimRefs, db))
664 return false;
665 if (!WriteGeneric(FlagRefs, db))
666 return false;
667
668 return !!db.EndWriteListTag(Tagid);
669}
670
671
672/***********************************************************************
673 * Database
674 */
675
676void Database::WriteBinary(TAG tag, const GUID& guid, bool always)
677{
678 if (always || !IsEmptyGuid(guid))
679 SdbWriteBinaryTag(pdb, tag, (BYTE*)&guid, sizeof(GUID));
680}
681
682void Database::WriteBinary(TAG tag, const std::vector<BYTE>& data, bool always)
683{
684 if (always || !data.empty())
685 SdbWriteBinaryTag(pdb, tag, data.data(), data.size());
686}
687
688void Database::WriteString(TAG tag, const sdbstring& str, bool always)
689{
690 if (always || !str.empty())
691 SdbWriteStringTag(pdb, tag, (LPCWSTR)str.c_str());
692}
693
694void Database::WriteString(TAG tag, const std::string& str, bool always)
695{
696 WriteString(tag, sdbstring(str.begin(), str.end()), always);
697}
698
700{
701 if (always || value)
703}
704
706{
707 if (always || value)
709}
710
712{
714}
715
717{
719}
720
722{
723 return SdbEndWriteListTag(pdb, tagid);
724}
725
727{
728 Name = ReadStringNode(dbNode, "NAME");
729 ReadGuidNode(dbNode, "DATABASE_ID", ID);
730
731 XMLHandle libChild = dbNode.FirstChildElement("LIBRARY").FirstChild();
732 while (libChild.ToNode())
733 {
734 std::string NodeName = ToNodeName(libChild);
735 if (NodeName == "SHIM")
736 {
737 Shim shim;
738 if (shim.fromXml(libChild) && ((shim.Platform & platform) != PLATFORM_NONE))
739 Library.Shims.push_back(shim);
740 }
741 else if (NodeName == "FLAG")
742 {
743 Flag flag;
744 if (flag.fromXml(libChild))
745 Library.Flags.push_back(flag);
746 }
747 else if (NodeName == "INCLUDE" || NodeName == "EXCLUDE")
748 {
749 InExclude inex;
750 if (inex.fromXml(libChild))
751 Library.InExcludes.push_back(inex);
752 }
753 libChild = libChild.NextSibling();
754 }
755
756 ReadGeneric(dbNode, Layers, "LAYER", platform);
757 ReadGeneric(dbNode, Exes, "EXE", platform);
758
759 ReadGeneric(dbNode, KShims, "KSHIM", platform);
760 ReadGeneric(dbNode, KDrivers, "KDRIVER", platform);
761 return true;
762}
763
764bool Database::fromXml(const char* fileName, PlatformType platform_)
765{
767 tinyxml2::XMLError err = doc.LoadFile(fileName);
768 XMLHandle dbHandle = tinyxml2::XMLHandle(&doc).FirstChildElement("SDB").FirstChildElement("DATABASE");
769 platform = platform_;
770 return fromXml(dbHandle);
771}
772
774{
776 TAGID tidDatabase = BeginWriteListTag(TAG_DATABASE);
777 LARGE_INTEGER li = { 0 };
782 WriteString(TAG_NAME, Name, true);
783 if (IsEmptyGuid(ID))
784 {
785 SHIM_WARN("DB has empty ID!\n");
786 RandomGuid(ID);
787 }
789 TAGID tidLibrary = BeginWriteListTag(TAG_LIBRARY);
790 if (!WriteGeneric(Library.InExcludes, *this))
791 return false;
792 if (!WriteGeneric(Library.Shims, *this))
793 return false;
794 if (!WriteGeneric(Library.Flags, *this))
795 return false;
796 EndWriteListTag(tidLibrary);
797 if (!WriteGeneric(Layers, *this))
798 return false;
799 if (!WriteGeneric(Exes, *this))
800 return false;
801 if (!WriteGeneric(KShims, *this))
802 return false;
803 if (!WriteGeneric(KDrivers, *this))
804 return false;
805 EndWriteListTag(tidDatabase);
806
808 pdb = nullptr;
809 return true;
810}
811
812static void InsertTagid(const sdbstring& name, TAGID tagid, std::map<sdbstring, TAGID>& lookup, const char* type)
813{
814 sdbstring nameLower = name;
815 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
816 if (lookup.find(nameLower) != lookup.end())
817 {
818 std::string nameA(name.begin(), name.end());
819 SHIM_WARN("%s '%s' redefined\n", type, nameA.c_str());
820 return;
821 }
822 lookup[nameLower] = tagid;
823}
824
825static TAGID FindTagid(const sdbstring& name, const std::map<sdbstring, TAGID>& lookup)
826{
827 sdbstring nameLower = name;
828 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
829 std::map<sdbstring, TAGID>::const_iterator it = lookup.find(nameLower);
830 if (it == lookup.end())
831 return 0;
832 return it->second;
833}
834
836{
837 InsertTagid(name, tagid, KnownShims, "Shim");
838}
839
841{
842 return FindTagid(name, KnownShims);
843}
844
846{
847 InsertTagid(name, tagid, KnownPatches, "Patch");
848}
849
851{
852 return FindTagid(name, KnownPatches);
853}
854
856{
857 InsertTagid(name, tagid, KnownFlags, "Flag");
858}
859
861{
862 return FindTagid(name, KnownFlags);
863}
864
865std::string Database::FindKShimModule(const std::string& name)
866{
867 for (const Shim& shim : KShims)
868 {
869 if (shim.Name.size() == name.size() &&
870 std::equal(name.begin(), name.end(), shim.Name.begin(),
871 [](char a, char b) { return ::tolower(a) == ::tolower(b); }))
872 {
873 return shim.DllFile;
874 }
875 }
876 return std::string();
877}
_STLP_INLINE_LOOP _ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred)
Definition: _algo.h:278
#define isspace(c)
Definition: acclib.h:69
#define REG_SZ
Definition: layer.c:22
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
#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
GUID guid
Definition: version.c:147
unsigned char ch[4][2]
Definition: console.c:118
int CDECL tolower(int c)
Definition: ctype.c:572
int CDECL toupper(int c)
Definition: ctype.c:514
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP int __cdecl rand(void)
Definition: misc.c:59
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
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLboolean g
Definition: glext.h:6204
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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
__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:71
static PLARGE_INTEGER Time
Definition: time.c:37
platform
Definition: msipriv.h:364
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
short WCHAR
Definition: pedump.c:58
char CHAR
Definition: pedump.c:57
#define err(...)
const WCHAR * str
#define T(num)
Definition: thunks.c:311
#define REG_QWORD
Definition: sdbapi.c:616
#define REG_DWORD
Definition: sdbapi.c:615
#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:209
#define TAG_KSHIM_REF
Definition: sdbtagid.h:192
#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_KSHIM
Definition: sdbtagid.h:191
#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_KDRIVER
Definition: sdbtagid.h:190
#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
#define strtoull
Definition: stabs.c:58
std::string Name
Definition: xml2sdb.h:120
DWORD DWordData
Definition: xml2sdb.h:125
bool toSdb(Database &db)
Definition: xml2sdb.cpp:517
std::string StringData
Definition: xml2sdb.h:124
QWORD QWordData
Definition: xml2sdb.h:126
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:490
TAGID Tagid
Definition: xml2sdb.h:121
PDB pdb
Definition: xml2sdb.h:255
void InsertShimTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:835
TAGID FindShimTagid(const sdbstring &name)
Definition: xml2sdb.cpp:840
GUID ID
Definition: xml2sdb.h:241
void WriteString(TAG tag, const sdbstring &str, bool always=false)
Definition: xml2sdb.cpp:688
TAGID FindPatchTagid(const sdbstring &name)
Definition: xml2sdb.cpp:850
void WriteQWord(TAG tag, QWORD value, bool always=false)
Definition: xml2sdb.cpp:705
BOOL EndWriteListTag(TAGID tagid)
Definition: xml2sdb.cpp:721
void WriteBinary(TAG tag, const GUID &guid, bool always=false)
Definition: xml2sdb.cpp:676
TAGID FindFlagTagid(const sdbstring &name)
Definition: xml2sdb.cpp:860
std::map< sdbstring, TAGID > KnownPatches
Definition: xml2sdb.h:253
std::string FindKShimModule(const std::string &name)
Definition: xml2sdb.cpp:865
std::list< Exe > Exes
Definition: xml2sdb.h:245
void WriteNull(TAG tag)
Definition: xml2sdb.cpp:711
std::map< sdbstring, TAGID > KnownFlags
Definition: xml2sdb.h:254
std::list< Shim > KShims
Definition: xml2sdb.h:249
bool toSdb(LPCWSTR path)
Definition: xml2sdb.cpp:773
void InsertPatchTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:845
TAGID BeginWriteListTag(TAG tag)
Definition: xml2sdb.cpp:716
bool fromXml(const char *fileName, PlatformType platform)
Definition: xml2sdb.cpp:764
void InsertFlagTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:855
std::map< sdbstring, TAGID > KnownShims
Definition: xml2sdb.h:252
std::list< Layer > Layers
Definition: xml2sdb.h:244
void WriteDWord(TAG tag, DWORD value, bool always=false)
Definition: xml2sdb.cpp:699
std::list< Exe > KDrivers
Definition: xml2sdb.h:248
std::string Name
Definition: xml2sdb.h:240
PlatformType Platform
Definition: xml2sdb.h:177
std::list< MatchingFile > MatchingFiles
Definition: xml2sdb.h:174
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:623
TAGID Tagid
Definition: xml2sdb.h:173
std::string Name
Definition: xml2sdb.h:169
std::string AppName
Definition: xml2sdb.h:171
GUID ExeID
Definition: xml2sdb.h:170
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:175
bool KDriver
Definition: xml2sdb.h:178
bool toSdb(Database &db)
Definition: xml2sdb.cpp:648
std::string Vendor
Definition: xml2sdb.h:172
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:176
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:394
TAGID FlagTagid
Definition: xml2sdb.h:85
bool toSdb(Database &db)
Definition: xml2sdb.cpp:400
std::string Name
Definition: xml2sdb.h:84
Definition: xml2sdb.h:103
std::string Name
Definition: xml2sdb.h:107
TAGID Tagid
Definition: xml2sdb.h:108
bool toSdb(Database &db)
Definition: xml2sdb.cpp:464
QWORD ProcessParamFlags
Definition: xml2sdb.h:111
QWORD KernelFlags
Definition: xml2sdb.h:109
QWORD UserFlags
Definition: xml2sdb.h:110
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:453
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:284
std::string Module
Definition: xml2sdb.h:63
bool Include
Definition: xml2sdb.h:64
bool toSdb(Database &db)
Definition: xml2sdb.cpp:296
std::string Name
Definition: xml2sdb.h:134
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:545
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:137
std::list< Data > Datas
Definition: xml2sdb.h:138
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:136
TAGID Tagid
Definition: xml2sdb.h:135
bool toSdb(Database &db)
Definition: xml2sdb.cpp:554
std::list< Shim > Shims
Definition: xml2sdb.h:184
std::list< InExclude > InExcludes
Definition: xml2sdb.h:183
std::list< Flag > Flags
Definition: xml2sdb.h:185
std::string OriginalFilename
Definition: xml2sdb.h:159
std::string InternalName
Definition: xml2sdb.h:151
DWORD LinkDate
Definition: xml2sdb.h:156
std::string ProductVersion
Definition: xml2sdb.h:153
DWORD LinkerVersion
Definition: xml2sdb.h:161
std::string FileDescription
Definition: xml2sdb.h:158
std::string ProductName
Definition: xml2sdb.h:152
std::string Name
Definition: xml2sdb.h:147
std::string BinFileVersion
Definition: xml2sdb.h:155
std::string CompanyName
Definition: xml2sdb.h:150
std::string UptoBinFileVersion
Definition: xml2sdb.h:160
bool toSdb(Database &db)
Definition: xml2sdb.cpp:592
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:572
DWORD Checksum
Definition: xml2sdb.h:149
std::string VerLanguage
Definition: xml2sdb.h:157
std::string FileVersion
Definition: xml2sdb.h:154
std::string CommandLine
Definition: xml2sdb.h:73
bool toSdb(Database &db)
Definition: xml2sdb.cpp:363
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:350
std::string Name
Definition: xml2sdb.h:72
std::list< InExclude > InExcludes
Definition: xml2sdb.h:75
TAGID ShimTagid
Definition: xml2sdb.h:74
bool KShim
Definition: xml2sdb.h:76
Definition: xml2sdb.h:89
GUID FixID
Definition: xml2sdb.h:95
bool toSdb(Database &db)
Definition: xml2sdb.cpp:433
std::list< InExclude > InExcludes
Definition: xml2sdb.h:97
bool KShim
Definition: xml2sdb.h:99
PlatformType Platform
Definition: xml2sdb.h:98
std::string DllFile
Definition: xml2sdb.h:94
TAGID Tagid
Definition: xml2sdb.h:96
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:416
std::string Name
Definition: xml2sdb.h:93
Definition: fs_rec.h:143
Definition: name.c:39
const WCHAR * name
Definition: ecma_167.h:138
#define TAG_SHIM
Definition: tag.h:144
#define byte(x, n)
Definition: tomcrypt.h:118
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#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:64
#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:4539
#define success(from, fromstr, to, tostr)
static const GUID GUID_NULL
Definition: xml2sdb.cpp:17
static TAGID FindTagid(const sdbstring &name, const std::map< sdbstring, TAGID > &lookup)
Definition: xml2sdb.cpp:825
bool ReadGuidNode(XMLHandle dbNode, const char *nodeName, GUID &guid)
Definition: xml2sdb.cpp:251
static bool StringToGuid(const std::string &str, GUID &guid)
Definition: xml2sdb.cpp:163
static const char szCompilerVersion[]
Definition: xml2sdb.cpp:18
std::string ToString(XMLHandle node)
Definition: xml2sdb.cpp:90
VOID NTAPI RtlSecondsSince1970ToTime(IN ULONG SecondsSince1970, OUT PLARGE_INTEGER Time)
Definition: time.c:406
void RandomGuid(GUID &g)
Definition: xml2sdb.cpp:82
unsigned char char2byte(char hexChar, bool *success=NULL)
Definition: xml2sdb.cpp:148
QWORD ReadQWordNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:122
DWORD ReadDWordNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:134
DWORD str_to_enum(const std::string &str, const str_to_flag *table)
Definition: xml2sdb.cpp:51
#define C_ASSERT(expr)
Definition: xml2sdb.cpp:21
PlatformType ReadPlatformNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:139
static void InsertTagid(const sdbstring &name, TAGID tagid, std::map< sdbstring, TAGID > &lookup, const char *type)
Definition: xml2sdb.cpp:812
void ReadGeneric(XMLHandle dbNode, std::list< T > &result, const char *nodeName)
Definition: xml2sdb.cpp:307
std::string ToNodeName(XMLHandle node)
Definition: xml2sdb.cpp:100
str_to_flag platform_to_flag[]
Definition: xml2sdb.cpp:42
bool WriteGeneric(std::list< T > &data, Database &db)
Definition: xml2sdb.cpp:335
std::string ReadStringNode(XMLHandle dbNode, const char *nodeName)
Definition: xml2sdb.cpp:110
bool ReadBinaryNode(XMLHandle dbNode, const char *nodeName, std::vector< BYTE > &data)
Definition: xml2sdb.cpp:262
bool IsEmptyGuid(const GUID &g)
Definition: xml2sdb.cpp:77
PlatformType
Definition: xml2sdb.h:36
@ PLATFORM_NONE
Definition: xml2sdb.h:37
@ PLATFORM_ANY
Definition: xml2sdb.h:45
@ PLATFORM_X86
Definition: xml2sdb.h:40
@ PLATFORM_AMD64
Definition: xml2sdb.h:43
std::basic_string< WCHAR > sdbstring
Definition: xml2sdb.h:31
unsigned char BYTE
Definition: xxhash.c:193