ReactOS 0.4.15-dev-7942-gd23573b
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
21namespace tinyxml2
22{
23class XMLHandle;
24}
26
27typedef std::basic_string<WCHAR> sdbstring;
28
29struct Database;
30
32{
34 bool fromXml(XMLHandle dbNode);
35 bool toSdb(PDB pdb, Database& db);
36
37 std::string Module;
38 bool Include;
39};
40
41struct ShimRef
42{
43 ShimRef() : ShimTagid(0) { ; }
44
45 bool fromXml(XMLHandle dbNode);
46 bool toSdb(PDB pdb, Database& db);
47
48 std::string Name;
49 std::string CommandLine;
51 std::list<InExclude> InExcludes;
52};
53
54struct FlagRef
55{
56 FlagRef() : FlagTagid(0) { ; }
57
58 bool fromXml(XMLHandle dbNode);
59 bool toSdb(PDB pdb, Database& db);
60
61 std::string Name;
63};
64
65struct Shim
66{
67 Shim() : Tagid(0) { ; }
68
69 bool fromXml(XMLHandle dbNode);
70 bool toSdb(PDB pdb, Database& db);
71
72 std::string Name;
73 std::string DllFile;
76 std::list<InExclude> InExcludes;
77};
78
79struct Flag
80{
82
83 bool fromXml(XMLHandle dbNode);
84 bool toSdb(PDB pdb, Database& db);
85
86 std::string Name;
91};
92
93
94struct 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
101 std::string Name;
104
105 std::string StringData;
108};
109
110struct Layer
111{
112 Layer() : Tagid(0) { ; }
113
114 bool fromXml(XMLHandle dbNode);
115 bool toSdb(PDB pdb, Database& db);
116
117 std::string Name;
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
131 std::string Name;
134 std::string CompanyName;
135 std::string InternalName;
136 std::string ProductName;
137 std::string ProductVersion;
138 std::string FileVersion;
139 std::string BinFileVersion;
141 std::string VerLanguage;
142 std::string FileDescription;
143 std::string OriginalFilename;
146};
147
148struct Exe
149{
150 Exe() : Tagid(0) { ; }
151
152 bool fromXml(XMLHandle dbNode);
153 bool toSdb(PDB pdb, Database& db);
154
155 std::string Name;
157 std::string AppName;
158 std::string Vendor;
160 std::list<MatchingFile> MatchingFiles;
161 std::list<ShimRef> ShimRefs;
162 std::list<FlagRef> FlagRefs;
163};
164
166{
167 std::list<InExclude> InExcludes;
168 std::list<Shim> Shims;
169 std::list<Flag> Flags;
170};
171
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);
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 }
194 inline TAGID FindShimTagid(const std::string& name)
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 }
206 inline TAGID FindPatchTagid(const std::string& name)
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 }
217 inline TAGID FindFlagTagid(const std::string& name)
218 {
219 return FindFlagTagid(sdbstring(name.begin(), name.end()));
220 }
221
222 std::string Name;
224
226 std::list<Layer> Layers;
227 std::list<Exe> Exes;
228
229private:
230 std::map<sdbstring, TAGID> KnownShims;
231 std::map<sdbstring, TAGID> KnownPatches;
232 std::map<sdbstring, TAGID> KnownFlags;
233};
234
DWORD TAGID
static PDB pdb
Definition: db.cpp:172
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const GUID * guid
const WCHAR * str
UINT64 QWORD
Definition: shimdbg.c:104
DataType
Definition: simd.h:252
#define false
Definition: stdbool.h:37
DWORD DataType
Definition: xml2sdb.h:103
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:440
std::string Name
Definition: xml2sdb.h:101
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
Data()
Definition: xml2sdb.h:96
TAGID Tagid
Definition: xml2sdb.h:102
void InsertPatchTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:201
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
TAGID FindShimTagid(const std::string &name)
Definition: xml2sdb.h:194
void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always=false)
Definition: xml2sdb.cpp:612
TAGID FindPatchTagid(const sdbstring &name)
Definition: xml2sdb.cpp:749
TAGID FindFlagTagid(const std::string &name)
Definition: xml2sdb.h:217
void InsertShimTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:189
void WriteBinary(PDB pdb, TAG tag, const GUID &guid, bool always=false)
Definition: xml2sdb.cpp:589
void InsertFlagTagid(const std::string &name, TAGID tagid)
Definition: xml2sdb.h:212
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
TAGID FindPatchTagid(const std::string &name)
Definition: xml2sdb.h:206
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
std::string Name
Definition: xml2sdb.h:222
bool fromXml(const char *fileName)
Definition: xml2sdb.cpp:669
Definition: xml2sdb.h:149
std::list< MatchingFile > MatchingFiles
Definition: xml2sdb.h:160
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:546
TAGID Tagid
Definition: xml2sdb.h:159
std::string Name
Definition: xml2sdb.h:155
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
Exe()
Definition: xml2sdb.h:150
std::string Vendor
Definition: xml2sdb.h:158
std::list< FlagRef > FlagRefs
Definition: xml2sdb.h:162
FlagRef()
Definition: xml2sdb.h:56
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:323
TAGID FlagTagid
Definition: xml2sdb.h:62
bool toSdb(PDB pdb, Database &db)
Definition: xml2sdb.cpp:329
std::string Name
Definition: xml2sdb.h:61
Definition: xml2sdb.h:80
std::string Name
Definition: xml2sdb.h:86
TAGID Tagid
Definition: xml2sdb.h:87
Flag()
Definition: xml2sdb.h:81
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
InExclude()
Definition: xml2sdb.h:33
Definition: xml2sdb.h:111
std::string Name
Definition: xml2sdb.h:117
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
Layer()
Definition: xml2sdb.h:112
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 Name
Definition: xml2sdb.h:131
std::string BinFileVersion
Definition: xml2sdb.h:139
std::string CompanyName
Definition: xml2sdb.h:134
std::string UptoBinFileVersion
Definition: xml2sdb.h:144
MatchingFile()
Definition: xml2sdb.h:126
bool fromXml(XMLHandle dbNode)
Definition: xml2sdb.cpp:495
DWORD Size
Definition: xml2sdb.h:132
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
ShimRef()
Definition: xml2sdb.h:43
std::string Name
Definition: xml2sdb.h:48
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
std::string Name
Definition: xml2sdb.h:72
Shim()
Definition: xml2sdb.h:67
Definition: fs_rec.h:143
Definition: name.c:39
Definition: ecma_167.h:138
Definition: pdh_main.c:94
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
std::basic_string< WCHAR > sdbstring
Definition: xml2sdb.h:27
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185