ReactOS  0.4.14-dev-583-g2a1ba2c
xml2sdb.h
Go to the documentation of this file.
1 /*
2  * PROJECT: xml2sdb
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Define mapping of all shim database types to xml
5  * COPYRIGHT: Copyright 2016-2019 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #pragma once
9 
10 #include <string>
11 #include <list>
12 #include <vector>
13 #include <map>
14 
15 #include <typedefs.h>
16 #include <guiddef.h>
17 #include <sdbtypes.h>
18 #include "sdbwrite.h"
19 #include <sdbtagid.h>
20 
21 namespace tinyxml2
22 {
23 class XMLHandle;
24 }
26 
27 typedef std::basic_string<WCHAR> sdbstring;
28 
29 struct Database;
30 
31 struct InExclude
32 {
33  InExclude() : Include(false) { ; }
34  bool fromXml(XMLHandle dbNode);
35  bool toSdb(PDB pdb, Database& db);
36 
38  bool Include;
39 };
40 
41 struct ShimRef
42 {
43  ShimRef() : ShimTagid(0) { ; }
44 
45  bool fromXml(XMLHandle dbNode);
46  bool toSdb(PDB pdb, Database& db);
47 
51  std::list<InExclude> InExcludes;
52 };
53 
54 struct FlagRef
55 {
56  FlagRef() : FlagTagid(0) { ; }
57 
58  bool fromXml(XMLHandle dbNode);
59  bool toSdb(PDB pdb, Database& db);
60 
63 };
64 
65 struct Shim
66 {
67  Shim() : Tagid(0) { ; }
68 
69  bool fromXml(XMLHandle dbNode);
70  bool toSdb(PDB pdb, Database& db);
71 
76  std::list<InExclude> InExcludes;
77 };
78 
79 struct Flag
80 {
82 
83  bool fromXml(XMLHandle dbNode);
84  bool toSdb(PDB pdb, Database& db);
85 
91 };
92 
93 
94 struct Data
95 {
96  Data() : Tagid(0), DataType(0), DWordData(0), QWordData(0) { ; }
97 
98  bool fromXml(XMLHandle dbNode);
99  bool toSdb(PDB pdb, Database& db);
100 
104 
108 };
109 
110 struct Layer
111 {
112  Layer() : Tagid(0) { ; }
113 
114  bool fromXml(XMLHandle dbNode);
115  bool toSdb(PDB pdb, Database& db);
116 
119  std::list<ShimRef> ShimRefs;
120  std::list<FlagRef> FlagRefs;
121  std::list<Data> Datas;
122 };
123 
125 {
127 
128  bool fromXml(XMLHandle dbNode);
129  bool toSdb(PDB pdb, Database& db);
130 
146 };
147 
148 struct Exe
149 {
150  Exe() : Tagid(0) { ; }
151 
152  bool fromXml(XMLHandle dbNode);
153  bool toSdb(PDB pdb, Database& db);
154 
160  std::list<MatchingFile> MatchingFiles;
161  std::list<ShimRef> ShimRefs;
162  std::list<FlagRef> FlagRefs;
163 };
164 
165 struct Library
166 {
167  std::list<InExclude> InExcludes;
168  std::list<Shim> Shims;
169  std::list<Flag> Flags;
170 };
171 
172 struct Database
173 {
174 
175  bool fromXml(const char* fileName);
176  bool fromXml(XMLHandle dbNode);
177  bool toSdb(LPCWSTR path);
178 
179  void WriteString(PDB pdb, TAG tag, const sdbstring& str, bool always = false);
180  void WriteString(PDB pdb, TAG tag, const std::string& str, bool always = false);
181  void WriteBinary(PDB pdb, TAG tag, const GUID& guid, bool always = false);
182  void WriteBinary(PDB pdb, TAG tag, const std::vector<BYTE>& data, bool always = false);
183  void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always = false);
184  void WriteQWord(PDB pdb, TAG tag, QWORD value, bool always = false);
186  BOOL EndWriteListTag(PDB pdb, TAGID tagid);
187 
188  void InsertShimTagid(const sdbstring& name, TAGID tagid);
189  inline void InsertShimTagid(const std::string& name, TAGID tagid)
190  {
191  InsertShimTagid(sdbstring(name.begin(), name.end()), tagid);
192  }
195  {
196  return FindShimTagid(sdbstring(name.begin(), name.end()));
197  }
198 
199 
200  void InsertPatchTagid(const sdbstring& name, TAGID tagid);
201  inline void InsertPatchTagid(const std::string& name, TAGID tagid)
202  {
203  InsertPatchTagid(sdbstring(name.begin(), name.end()), tagid);
204  }
207  {
208  return FindPatchTagid(sdbstring(name.begin(), name.end()));
209  }
210 
211  void InsertFlagTagid(const sdbstring& name, TAGID tagid);
212  inline void InsertFlagTagid(const std::string& name, TAGID tagid)
213  {
214  InsertFlagTagid(sdbstring(name.begin(), name.end()), tagid);
215  }
218  {
219  return FindFlagTagid(sdbstring(name.begin(), name.end()));
220  }
221 
224 
225  struct Library Library;
226  std::list<Layer> Layers;
227  std::list<Exe> Exes;
228 
229 private:
230  std::map<sdbstring, TAGID> KnownShims;
231  std::map<sdbstring, TAGID> KnownPatches;
232  std::map<sdbstring, TAGID> KnownFlags;
233 };
234 
std::map< sdbstring, TAGID > KnownShims
Definition: xml2sdb.h:230
InExclude()
Definition: xml2sdb.h:33
TAGID FindPatchTagid(const std::string &name)
Definition: xml2sdb.h:206
TAGID FindShimTagid(const sdbstring &name)
Definition: xml2sdb.cpp:739
Exe()
Definition: xml2sdb.h:150
std::list< InExclude > InExcludes
Definition: xml2sdb.h:167
std::list< InExclude > InExcludes
Definition: xml2sdb.h:51
static PDB pdb
Definition: db.cpp:170
void InsertPatchTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:201
TAGID BeginWriteListTag(PDB pdb, TAG tag)
Definition: xml2sdb.cpp:624
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
std::string Name
Definition: xml2sdb.h:117
QWORD QWordData
Definition: xml2sdb.h:107
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:162
TAGID FindPatchTagid(const sdbstring &name)
Definition: xml2sdb.cpp:749
void WriteQWord(PDB pdb, TAG tag, QWORD value, bool always=false)
Definition: xml2sdb.cpp:618
std::basic_string< WCHAR > sdbstring
Definition: xml2sdb.h:27
std::list< MatchingFile > MatchingFiles
Definition: xml2sdb.h:160
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:161
std::string Name
Definition: xml2sdb.h:222
DWORD Size
Definition: xml2sdb.h:132
std::string VerLanguage
Definition: xml2sdb.h:141
bool Include
Definition: xml2sdb.h:38
std::string ProductName
Definition: xml2sdb.h:136
Definition: ecma_167.h:138
QWORD UserFlags
Definition: xml2sdb.h:89
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:468
void InsertPatchTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:744
DWORD DataType
Definition: xml2sdb.h:103
Layer()
Definition: xml2sdb.h:112
void WriteString(PDB pdb, TAG tag, const sdbstring &str, bool always=false)
Definition: xml2sdb.cpp:601
TAGID Tagid
Definition: xml2sdb.h:75
std::list< ShimRef > ShimRefs
Definition: xml2sdb.h:119
std::map< sdbstring, TAGID > KnownPatches
Definition: xml2sdb.h:231
void InsertShimTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:189
TAGID Tagid
Definition: xml2sdb.h:118
const GUID * guid
std::string ProductVersion
Definition: xml2sdb.h:137
unsigned int BOOL
Definition: ntddk_ex.h:94
std::map< sdbstring, TAGID > KnownFlags
Definition: xml2sdb.h:232
BOOL EndWriteListTag(PDB pdb, TAGID tagid)
Definition: xml2sdb.cpp:629
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:477
void InsertFlagTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:754
const WCHAR * str
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:244
std::list< InExclude > InExcludes
Definition: xml2sdb.h:76
std::string CommandLine
Definition: xml2sdb.h:49
std::string Name
Definition: xml2sdb.h:48
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:561
TAGID FindShimTagid(const std::string &name)
Definition: xml2sdb.h:194
std::string Module
Definition: xml2sdb.h:37
std::string Name
Definition: xml2sdb.h:131
TAGID Tagid
Definition: xml2sdb.h:102
std::string FileDescription
Definition: xml2sdb.h:142
std::list< Exe > Exes
Definition: xml2sdb.h:227
std::string CompanyName
Definition: xml2sdb.h:134
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:495
Shim()
Definition: xml2sdb.h:67
std::string UptoBinFileVersion
Definition: xml2sdb.h:144
Data()
Definition: xml2sdb.h:96
std::string Name
Definition: xml2sdb.h:61
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:413
TAGID Tagid
Definition: xml2sdb.h:87
UINT64 QWORD
Definition: shimdbg.c:104
std::string AppName
Definition: xml2sdb.h:157
bool fromXml(const char *fileName)
Definition: xml2sdb.cpp:669
Definition: xml2sdb.h:79
TAGID ShimTagid
Definition: xml2sdb.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
GUID ID
Definition: xml2sdb.h:223
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:323
DWORD DWordData
Definition: xml2sdb.h:106
MatchingFile()
Definition: xml2sdb.h:126
void InsertFlagTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:212
Definition: xml2sdb.h:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:345
QWORD KernelFlags
Definition: xml2sdb.h:88
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:120
FlagRef()
Definition: xml2sdb.h:56
DWORD LinkDate
Definition: xml2sdb.h:140
std::list< Data > Datas
Definition: xml2sdb.h:121
TAGID FindFlagTagid(const std::string &name)
Definition: xml2sdb.h:217
#define false
Definition: stdbool.h:38
void InsertShimTagid(const sdbstring &name, TAGID tagid)
Definition: xml2sdb.cpp:734
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:376
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
std::string Name
Definition: xml2sdb.h:101
QWORD ProcessParamFlags
Definition: xml2sdb.h:90
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:515
char string[160]
Definition: util.h:11
void WriteBinary(PDB pdb, TAG tag, const GUID &guid, bool always=false)
Definition: xml2sdb.cpp:589
GUID ExeID
Definition: xml2sdb.h:156
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:329
std::string OriginalFilename
Definition: xml2sdb.h:143
std::string Vendor
Definition: xml2sdb.h:158
TAGID FlagTagid
Definition: xml2sdb.h:62
Definition: xml2sdb.h:148
TAGID FindFlagTagid(const sdbstring &name)
Definition: xml2sdb.cpp:759
std::list< Shim > Shims
Definition: xml2sdb.h:168
std::string Name
Definition: xml2sdb.h:72
std::string DllFile
Definition: xml2sdb.h:73
GUID FixID
Definition: xml2sdb.h:74
void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always=false)
Definition: xml2sdb.cpp:612
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:296
Definition: fs_rec.h:142
DWORD LinkerVersion
Definition: xml2sdb.h:145
ShimRef()
Definition: xml2sdb.h:43
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:256
std::string InternalName
Definition: xml2sdb.h:135
Definition: name.c:38
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:305
std::string Name
Definition: xml2sdb.h:155
bool toSdb(LPCWSTR path)
Definition: xml2sdb.cpp:677
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:546
std::string StringData
Definition: xml2sdb.h:105
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:357
Definition: xml2sdb.h:110
DWORD TAGID
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:387
std::string BinFileVersion
Definition: xml2sdb.h:139
DWORD Checksum
Definition: xml2sdb.h:133
Flag()
Definition: xml2sdb.h:81
std::string Name
Definition: xml2sdb.h:86
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:440
std::list< Flag > Flags
Definition: xml2sdb.h:169
TAGID Tagid
Definition: xml2sdb.h:159
std::list< Layer > Layers
Definition: xml2sdb.h:226
std::string FileVersion
Definition: xml2sdb.h:138