Missing include
[reactos.git] / reactos / sdk / tools / xml2sdb / xml2sdb.h
1 #pragma once
2
3 #include <string>
4 #include <list>
5 #include <vector>
6 #include <map>
7
8 #include <typedefs.h>
9 #include <guiddef.h>
10 #include "sdbtypes.h"
11 #include "sdbwrite.h"
12 #include "sdbtagid.h"
13
14 namespace tinyxml2
15 {
16 class XMLHandle;
17 }
18 using tinyxml2::XMLHandle;
19
20 typedef std::basic_string<WCHAR> sdbstring;
21
22 struct Database;
23
24 struct InExclude
25 {
26 InExclude() : Include(false) { ; }
27 bool fromXml(XMLHandle dbNode);
28 bool toSdb(PDB pdb, Database& db);
29
30 std::string Module;
31 bool Include;
32 };
33
34 struct ShimRef
35 {
36 ShimRef() : ShimTagid(0) { ; }
37
38 bool fromXml(XMLHandle dbNode);
39 bool toSdb(PDB pdb, Database& db);
40
41 std::string Name;
42 std::string CommandLine;
43 TAGID ShimTagid;
44 std::list<InExclude> InExcludes;
45 };
46
47 struct Shim
48 {
49 Shim() : Tagid(0) { ; }
50
51 bool fromXml(XMLHandle dbNode);
52 bool toSdb(PDB pdb, Database& db);
53
54 std::string Name;
55 std::string DllFile;
56 GUID FixID;
57 TAGID Tagid;
58 std::list<InExclude> InExcludes;
59 };
60
61 struct Layer
62 {
63 Layer() : Tagid(0) { ; }
64
65 bool fromXml(XMLHandle dbNode);
66 bool toSdb(PDB pdb, Database& db);
67
68 std::string Name;
69 TAGID Tagid;
70 std::list<ShimRef> ShimRefs;
71 };
72
73 struct MatchingFile
74 {
75 MatchingFile() : Size(0), Checksum(0) {;}
76
77 bool fromXml(XMLHandle dbNode);
78 bool toSdb(PDB pdb, Database& db);
79
80 std::string Name;
81 DWORD Size;
82 DWORD Checksum;
83 std::string CompanyName;
84 std::string InternalName;
85 std::string ProductName;
86 std::string ProductVersion;
87 std::string FileVersion;
88 std::string BinFileVersion;
89 std::string LinkDate;
90 std::string VerLanguage;
91 std::string FileDescription;
92 std::string OriginalFilename;
93 std::string UptoBinFileVersion;
94 std::string LinkerVersion;
95 };
96
97 struct Exe
98 {
99 Exe() : Tagid(0) { ; }
100
101 bool fromXml(XMLHandle dbNode);
102 bool toSdb(PDB pdb, Database& db);
103
104 std::string Name;
105 GUID ExeID;
106 std::string AppName;
107 std::string Vendor;
108 TAGID Tagid;
109 std::list<MatchingFile> MatchingFiles;
110 std::list<ShimRef> ShimRefs;
111 };
112
113 struct Library
114 {
115 std::list<Shim> Shims;
116 };
117
118 struct Database
119 {
120
121 bool fromXml(const char* fileName);
122 bool fromXml(XMLHandle dbNode);
123 bool toSdb(LPCWSTR path);
124
125 void WriteString(PDB pdb, TAG tag, const sdbstring& str, bool always = false);
126 void WriteString(PDB pdb, TAG tag, const std::string& str, bool always = false);
127 void WriteBinary(PDB pdb, TAG tag, const GUID& guid, bool always = false);
128 void WriteBinary(PDB pdb, TAG tag, const std::vector<BYTE>& data, bool always = false);
129 void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always = false);
130 TAGID BeginWriteListTag(PDB db, TAG tag);
131 BOOL EndWriteListTag(PDB db, TAGID tagid);
132
133 void InsertShimTagid(const sdbstring& name, TAGID tagid);
134 inline void InsertShimTagid(const std::string& name, TAGID tagid)
135 {
136 InsertShimTagid(sdbstring(name.begin(), name.end()), tagid);
137 }
138 TAGID FindShimTagid(const sdbstring& name);
139 inline TAGID FindShimTagid(const std::string& name)
140 {
141 return FindShimTagid(sdbstring(name.begin(), name.end()));
142 }
143
144 std::string Name;
145 GUID ID;
146
147 struct Library Library;
148 std::list<Layer> Layers;
149 std::list<Exe> Exes;
150
151 private:
152 std::map<sdbstring, TAGID> KnownShims;
153 std::map<sdbstring, TAGID> KnownPatches;
154 };
155