ReactOS 0.4.16-dev-1946-g52006dd
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-2025 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.0.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 ReadGeneric(dbNode, InExcludes, "INCLUDE");
355 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
356 return !Name.empty();
357}
358
360{
362 db.WriteString(TAG_NAME, Name, true);
364
365 if (!ShimTagid)
368 return !!db.EndWriteListTag(tagid);
369}
370
371
372
373/***********************************************************************
374 * FlagRef
375 */
376
378{
379 Name = ReadStringNode(dbNode, "NAME");
380 return !Name.empty();
381}
382
384{
386 db.WriteString(TAG_NAME, Name, true);
387
388 if (!FlagTagid)
391 return !!db.EndWriteListTag(tagid);
392}
393
394
395/***********************************************************************
396 * Shim
397 */
398
400{
401 Name = ReadStringNode(dbNode, "NAME");
402 DllFile = ReadStringNode(dbNode, "DLLFILE");
403 ReadGuidNode(dbNode, "FIX_ID", FixID);
404 // GENERAL ?
405 // DESCRIPTION_RC_ID
406 ReadGeneric(dbNode, InExcludes, "INCLUDE");
407 ReadGeneric(dbNode, InExcludes, "EXCLUDE");
408 return !Name.empty() && !DllFile.empty();
409}
410
412{
417 if (IsEmptyGuid(FixID))
420 if (!WriteGeneric(InExcludes, db))
421 return false;
422 return !!db.EndWriteListTag(Tagid);
423}
424
425
426/***********************************************************************
427 * Flag
428 */
429
431{
432 Name = ReadStringNode(dbNode, "NAME");
433
434 KernelFlags = ReadQWordNode(dbNode, "FLAG_MASK_KERNEL");
435 UserFlags = ReadQWordNode(dbNode, "FLAG_MASK_USER");
436 ProcessParamFlags = ReadQWordNode(dbNode, "FLAG_PROCESSPARAM");
437
438 return !Name.empty();
439}
440
442{
445 db.WriteString(TAG_NAME, Name, true);
446
450
451 return !!db.EndWriteListTag(Tagid);
452}
453
454
455/***********************************************************************
456 * Data
457 */
458
459#ifndef REG_SZ
460#define REG_SZ 1
461//#define REG_BINARY 3
462#define REG_DWORD 4
463#define REG_QWORD 11
464#endif
465
466
468{
469 Name = ReadStringNode(dbNode, "NAME");
470
471 StringData = ReadStringNode(dbNode, "DATA_STRING");
472 if (!StringData.empty())
473 {
475 return !Name.empty();
476 }
477 DWordData = ReadDWordNode(dbNode, "DATA_DWORD");
478 if (DWordData)
479 {
481 return !Name.empty();
482 }
483 QWordData = ReadQWordNode(dbNode, "DATA_QWORD");
484 if (QWordData)
485 {
487 return !Name.empty();
488 }
489
490 SHIM_ERR("Data node (%s) without value!\n", Name.c_str());
491 return false;
492}
493
495{
497 db.WriteString(TAG_NAME, Name, true);
499 switch (DataType)
500 {
501 case REG_SZ:
503 break;
504 case REG_DWORD:
506 break;
507 case REG_QWORD:
509 break;
510 default:
511 SHIM_ERR("Data node (%s) with unknown type (0x%x)\n", Name.c_str(), DataType);
512 return false;
513 }
514
515 return !!db.EndWriteListTag(Tagid);
516}
517
518/***********************************************************************
519 * Layer
520 */
521
523{
524 Name = ReadStringNode(dbNode, "NAME");
525 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
526 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
527 ReadGeneric(dbNode, Datas, "DATA");
528 return true;
529}
530
532{
534 db.WriteString(TAG_NAME, Name, true);
535 if (!WriteGeneric(ShimRefs, db))
536 return false;
537 if (!WriteGeneric(FlagRefs, db))
538 return false;
539 if (!WriteGeneric(Datas, db))
540 return false;
541 return !!db.EndWriteListTag(Tagid);
542}
543
544
545/***********************************************************************
546 * MatchingFile
547 */
548
550{
551 Name = ReadStringNode(dbNode, "NAME");
552 Size = ReadDWordNode(dbNode, "SIZE");
553 Checksum = ReadDWordNode(dbNode, "CHECKSUM");
554 CompanyName = ReadStringNode(dbNode, "COMPANY_NAME");
555 InternalName = ReadStringNode(dbNode, "INTERNAL_NAME");
556 ProductName = ReadStringNode(dbNode, "PRODUCT_NAME");
557 ProductVersion = ReadStringNode(dbNode, "PRODUCT_VERSION");
558 FileVersion = ReadStringNode(dbNode, "FILE_VERSION");
559 BinFileVersion = ReadStringNode(dbNode, "BIN_FILE_VERSION");
560 LinkDate = ReadDWordNode(dbNode, "LINK_DATE");
561 VerLanguage = ReadStringNode(dbNode, "VER_LANGUAGE");
562 FileDescription = ReadStringNode(dbNode, "FILE_DESCRIPTION");
563 OriginalFilename = ReadStringNode(dbNode, "ORIGINAL_FILENAME");
564 UptoBinFileVersion = ReadStringNode(dbNode, "UPTO_BIN_FILE_VERSION");
565 LinkerVersion = ReadDWordNode(dbNode, "LINKER_VERSION");
566 return true;
567}
568
570{
572
573 db.WriteString(TAG_NAME, Name, true);
581 if (!BinFileVersion.empty())
582 SHIM_ERR("TAG_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(TAG_BIN_FILE_VERSION, BinFileVersion);
584 if (!VerLanguage.empty())
585 SHIM_ERR("TAG_VER_LANGUAGE Unimplemented\n"); //db.WriteDWord(TAG_VER_LANGUAGE, VerLanguage);
588 if (!UptoBinFileVersion.empty())
589 SHIM_ERR("TAG_UPTO_BIN_FILE_VERSION Unimplemented\n"); //db.WriteQWord(TAG_UPTO_BIN_FILE_VERSION, UptoBinFileVersion);
591
592 return !!db.EndWriteListTag(tagid);
593}
594
595
596/***********************************************************************
597 * Exe
598 */
599
601{
602 Name = ReadStringNode(dbNode, "NAME");
603 ReadGuidNode(dbNode, "EXE_ID", ExeID);
604 AppName = ReadStringNode(dbNode, "APP_NAME");
605 Vendor = ReadStringNode(dbNode, "VENDOR");
606
607 ReadGeneric(dbNode, MatchingFiles, "MATCHING_FILE");
608
609 ReadGeneric(dbNode, ShimRefs, "SHIM_REF");
610 ReadGeneric(dbNode, FlagRefs, "FLAG_REF");
611
612 Platform = ReadPlatformNode(dbNode, "RUNTIME_PLATFORM");
613
614 return !Name.empty();
615}
616
618{
620
621 db.WriteString(TAG_NAME, Name, true);
622 if (IsEmptyGuid(ExeID))
625
626
629
630 if (!WriteGeneric(MatchingFiles, db))
631 return false;
632 if (!WriteGeneric(ShimRefs, db))
633 return false;
634 if (!WriteGeneric(FlagRefs, db))
635 return false;
636
637 return !!db.EndWriteListTag(Tagid);
638}
639
640
641/***********************************************************************
642 * Database
643 */
644
645void Database::WriteBinary(TAG tag, const GUID& guid, bool always)
646{
647 if (always || !IsEmptyGuid(guid))
648 SdbWriteBinaryTag(pdb, tag, (BYTE*)&guid, sizeof(GUID));
649}
650
651void Database::WriteBinary(TAG tag, const std::vector<BYTE>& data, bool always)
652{
653 if (always || !data.empty())
654 SdbWriteBinaryTag(pdb, tag, data.data(), data.size());
655}
656
657void Database::WriteString(TAG tag, const sdbstring& str, bool always)
658{
659 if (always || !str.empty())
660 SdbWriteStringTag(pdb, tag, (LPCWSTR)str.c_str());
661}
662
663void Database::WriteString(TAG tag, const std::string& str, bool always)
664{
665 WriteString(tag, sdbstring(str.begin(), str.end()), always);
666}
667
669{
670 if (always || value)
672}
673
675{
676 if (always || value)
678}
679
681{
683}
684
686{
688}
689
691{
692 return SdbEndWriteListTag(pdb, tagid);
693}
694
696{
697 Name = ReadStringNode(dbNode, "NAME");
698 ReadGuidNode(dbNode, "DATABASE_ID", ID);
699
700 XMLHandle libChild = dbNode.FirstChildElement("LIBRARY").FirstChild();
701 while (libChild.ToNode())
702 {
703 std::string NodeName = ToNodeName(libChild);
704 if (NodeName == "SHIM")
705 {
706 Shim shim;
707 if (shim.fromXml(libChild) && ((shim.Platform & platform) != PLATFORM_NONE))
708 Library.Shims.push_back(shim);
709 }
710 else if (NodeName == "FLAG")
711 {
712 Flag flag;
713 if (flag.fromXml(libChild))
714 Library.Flags.push_back(flag);
715 }
716 else if (NodeName == "INCLUDE" || NodeName == "EXCLUDE")
717 {
718 InExclude inex;
719 if (inex.fromXml(libChild))
720 Library.InExcludes.push_back(inex);
721 }
722 libChild = libChild.NextSibling();
723 }
724
725 ReadGeneric(dbNode, Layers, "LAYER", platform);
726 ReadGeneric(dbNode, Exes, "EXE", platform);
727 return true;
728}
729
730bool Database::fromXml(const char* fileName, PlatformType platform_)
731{
733 tinyxml2::XMLError err = doc.LoadFile(fileName);
734 XMLHandle dbHandle = tinyxml2::XMLHandle(&doc).FirstChildElement("SDB").FirstChildElement("DATABASE");
735 platform = platform_;
736 return fromXml(dbHandle);
737}
738
740{
742 TAGID tidDatabase = BeginWriteListTag(TAG_DATABASE);
743 LARGE_INTEGER li = { 0 };
748 WriteString(TAG_NAME, Name, true);
749 if (IsEmptyGuid(ID))
750 {
751 SHIM_WARN("DB has empty ID!\n");
752 RandomGuid(ID);
753 }
755 TAGID tidLibrary = BeginWriteListTag(TAG_LIBRARY);
756 if (!WriteGeneric(Library.InExcludes, *this))
757 return false;
758 if (!WriteGeneric(Library.Shims, *this))
759 return false;
760 if (!WriteGeneric(Library.Flags, *this))
761 return false;
762 EndWriteListTag(tidLibrary);
763 if (!WriteGeneric(Layers, *this))
764 return false;
765 if (!WriteGeneric(Exes, *this))
766 return false;
767 EndWriteListTag(tidDatabase);
768
770 pdb = nullptr;
771 return true;
772}
773
774static void InsertTagid(const sdbstring& name, TAGID tagid, std::map<sdbstring, TAGID>& lookup, const char* type)
775{
776 sdbstring nameLower = name;
777 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
778 if (lookup.find(nameLower) != lookup.end())
779 {
780 std::string nameA(name.begin(), name.end());
781 SHIM_WARN("%s '%s' redefined\n", type, nameA.c_str());
782 return;
783 }
784 lookup[nameLower] = tagid;
785}
786
787static TAGID FindTagid(const sdbstring& name, const std::map<sdbstring, TAGID>& lookup)
788{
789 sdbstring nameLower = name;
790 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
791 std::map<sdbstring, TAGID>::const_iterator it = lookup.find(nameLower);
792 if (it == lookup.end())
793 return 0;
794 return it->second;
795}
796
798{
799 InsertTagid(name, tagid, KnownShims, "Shim");
800}
801
803{
804 return FindTagid(name, KnownShims);
805}
806
808{
809 InsertTagid(name, tagid, KnownPatches, "Patch");
810}
811
813{
814 return FindTagid(name, KnownPatches);
815}
816
818{
819 InsertTagid(name, tagid, KnownFlags, "Flag");
820}
821
823{
824 return FindTagid(name, KnownFlags);
825}
_STLP_INLINE_LOOP _ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred)
Definition: _algo.h:278
#define isspace(c)
Definition: acclib.h:69
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
int toupper(int c)
Definition: utclib.c:881
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
#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
#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
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
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
#define REG_SZ
Definition: layer.c:22
__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:105
platform
Definition: msipriv.h:364
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#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: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
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#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:114
DWORD DWordData
Definition: xml2sdb.h:119
bool toSdb(Database &db)
Definition: xml2sdb.cpp:494
std::string StringData
Definition: xml2sdb.h:118
QWORD QWordData
Definition: xml2sdb.h:120
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:467
TAGID Tagid
Definition: xml2sdb.h:115
PDB pdb
Definition: xml2sdb.h:242
void InsertShimTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:797
TAGID FindShimTagid(const sdbstring &name)
Definition: xml2sdb.cpp:802
GUID ID
Definition: xml2sdb.h:232
void WriteString(TAG tag, const sdbstring &str, bool always=false)
Definition: xml2sdb.cpp:657
TAGID FindPatchTagid(const sdbstring &name)
Definition: xml2sdb.cpp:812
void WriteQWord(TAG tag, QWORD value, bool always=false)
Definition: xml2sdb.cpp:674
BOOL EndWriteListTag(TAGID tagid)
Definition: xml2sdb.cpp:690
void WriteBinary(TAG tag, const GUID &guid, bool always=false)
Definition: xml2sdb.cpp:645
TAGID FindFlagTagid(const sdbstring &name)
Definition: xml2sdb.cpp:822
std::map< sdbstring, TAGID > KnownPatches
Definition: xml2sdb.h:240
std::list< Exe > Exes
Definition: xml2sdb.h:236
void WriteNull(TAG tag)
Definition: xml2sdb.cpp:680
std::map< sdbstring, TAGID > KnownFlags
Definition: xml2sdb.h:241
bool toSdb(LPCWSTR path)
Definition: xml2sdb.cpp:739
void InsertPatchTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:807
TAGID BeginWriteListTag(TAG tag)
Definition: xml2sdb.cpp:685
bool fromXml(const char *fileName, PlatformType platform)
Definition: xml2sdb.cpp:730
void InsertFlagTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:817
std::map< sdbstring, TAGID > KnownShims
Definition: xml2sdb.h:239
std::list< Layer > Layers
Definition: xml2sdb.h:235
void WriteDWord(TAG tag, DWORD value, bool always=false)
Definition: xml2sdb.cpp:668
std::string Name
Definition: xml2sdb.h:231
PlatformType Platform
Definition: xml2sdb.h:171
std::list< MatchingFile > MatchingFiles
Definition: xml2sdb.h:168
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:600
TAGID Tagid
Definition: xml2sdb.h:167
std::string Name
Definition: xml2sdb.h:163
std::string AppName
Definition: xml2sdb.h:165
GUID ExeID
Definition: xml2sdb.h:164
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:169
bool toSdb(Database &db)
Definition: xml2sdb.cpp:617
std::string Vendor
Definition: xml2sdb.h:166
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:170
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:377
TAGID FlagTagid
Definition: xml2sdb.h:80
bool toSdb(Database &db)
Definition: xml2sdb.cpp:383
std::string Name
Definition: xml2sdb.h:79
Definition: xml2sdb.h:97
std::string Name
Definition: xml2sdb.h:101
TAGID Tagid
Definition: xml2sdb.h:102
bool toSdb(Database &db)
Definition: xml2sdb.cpp:441
QWORD ProcessParamFlags
Definition: xml2sdb.h:105
QWORD KernelFlags
Definition: xml2sdb.h:103
QWORD UserFlags
Definition: xml2sdb.h:104
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:430
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:284
std::string Module
Definition: xml2sdb.h:59
bool Include
Definition: xml2sdb.h:60
bool toSdb(Database &db)
Definition: xml2sdb.cpp:296
std::string Name
Definition: xml2sdb.h:128
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:522
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:131
std::list< Data > Datas
Definition: xml2sdb.h:132
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:130
TAGID Tagid
Definition: xml2sdb.h:129
bool toSdb(Database &db)
Definition: xml2sdb.cpp:531
std::list< Shim > Shims
Definition: xml2sdb.h:177
std::list< InExclude > InExcludes
Definition: xml2sdb.h:176
std::list< Flag > Flags
Definition: xml2sdb.h:178
std::string OriginalFilename
Definition: xml2sdb.h:153
std::string InternalName
Definition: xml2sdb.h:145
DWORD LinkDate
Definition: xml2sdb.h:150
std::string ProductVersion
Definition: xml2sdb.h:147
DWORD LinkerVersion
Definition: xml2sdb.h:155
std::string FileDescription
Definition: xml2sdb.h:152
std::string ProductName
Definition: xml2sdb.h:146
std::string Name
Definition: xml2sdb.h:141
std::string BinFileVersion
Definition: xml2sdb.h:149
std::string CompanyName
Definition: xml2sdb.h:144
std::string UptoBinFileVersion
Definition: xml2sdb.h:154
bool toSdb(Database &db)
Definition: xml2sdb.cpp:569
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:549
DWORD Checksum
Definition: xml2sdb.h:143
std::string VerLanguage
Definition: xml2sdb.h:151
std::string FileVersion
Definition: xml2sdb.h:148
std::string CommandLine
Definition: xml2sdb.h:69
bool toSdb(Database &db)
Definition: xml2sdb.cpp:359
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:350
std::string Name
Definition: xml2sdb.h:68
std::list< InExclude > InExcludes
Definition: xml2sdb.h:71
TAGID ShimTagid
Definition: xml2sdb.h:70
Definition: xml2sdb.h:84
GUID FixID
Definition: xml2sdb.h:90
bool toSdb(Database &db)
Definition: xml2sdb.cpp:411
std::list< InExclude > InExcludes
Definition: xml2sdb.h:92
PlatformType Platform
Definition: xml2sdb.h:93
std::string DllFile
Definition: xml2sdb.h:89
TAGID Tagid
Definition: xml2sdb.h:91
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:399
std::string Name
Definition: xml2sdb.h:88
Definition: fs_rec.h:143
Definition: name.c:39
const WCHAR * name
Definition: ecma_167.h:138
#define TAG_SHIM
Definition: tag.h:137
#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:96
#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:787
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:774
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:32
@ PLATFORM_NONE
Definition: xml2sdb.h:33
@ PLATFORM_ANY
Definition: xml2sdb.h:41
@ PLATFORM_X86
Definition: xml2sdb.h:36
@ PLATFORM_AMD64
Definition: xml2sdb.h:39
std::basic_string< WCHAR > sdbstring
Definition: xml2sdb.h:27
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193