[APPHELP][APPHELP_APITEST] Add SdbTagToString + test by Mislav Blažević CORE-10367
[reactos.git] / reactos / dll / appcompat / apphelp / apphelp.h
1 /*
2 * Copyright 2013 Mislav Blažević
3 * Copyright 2015 Mark Jansen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #ifndef APPHELP_H
21 #define APPHELP_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 typedef WORD TAG;
28 typedef DWORD TAGID;
29 typedef DWORD TAGREF;
30 typedef UINT64 QWORD;
31
32 #define TAGREF_NULL (0)
33 #define TAGREF_ROOT (0)
34
35 typedef enum _SHIM_LOG_LEVEL {
36 SHIM_ERR = 1,
37 SHIM_WARN = 2,
38 SHIM_INFO = 3,
39 }SHIM_LOG_LEVEL;
40
41 /* apphelp.c */
42 BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format, ...);
43 extern ULONG g_ShimDebugLevel;
44
45 #define SHIM_ERR(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
46 #define SHIM_WARN(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
47 #define SHIM_INFO(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
48
49
50 /* sdbapi.c */
51 void SdbpHeapInit(void);
52 void SdbpHeapDeinit(void);
53 #if SDBAPI_DEBUG_ALLOC
54
55 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
56 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, int line, const char* file);
57 void SdbpFree(LPVOID mem, int line, const char* file);
58
59 #define SdbAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
60 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size, __LINE__, __FILE__)
61 #define SdbFree(mem) SdbpFree(mem, __LINE__, __FILE__)
62
63 #else
64
65 LPVOID SdbpAlloc(SIZE_T size);
66 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size);
67 void SdbpFree(LPVOID mem);
68
69 #define SdbAlloc(size) SdbpAlloc(size)
70 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size)
71 #define SdbFree(mem) SdbpFree(mem)
72
73 #endif
74
75
76 /* layer.c */
77 BOOL WINAPI AllowPermLayer(PCWSTR path);
78 BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags);
79 BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable);
80
81
82 #define TAGID_NULL 0x0
83 #define TAGID_ROOT 0x0
84
85 /* The above definition of TAGID_ROOT is used in winapi and can be found
86 * on msdn it but doesn't make sense, especially internally, because
87 * TAGID represents offset into database data and there is a header at
88 * offset 0, NOT a tag. Therfore, this definition should be used internally
89 * to represent first valid TAGID. Header size is 12 bytes. */
90 #define _TAGID_ROOT 12
91
92 #define TAG_TYPE_MASK 0xF000
93
94 #define TAG_TYPE_NULL 0x1000
95 #define TAG_TYPE_BYTE 0x2000
96 #define TAG_TYPE_WORD 0x3000
97 #define TAG_TYPE_DWORD 0x4000
98 #define TAG_TYPE_QWORD 0x5000
99 #define TAG_TYPE_STRINGREF 0x6000
100 #define TAG_TYPE_LIST 0x7000
101 #define TAG_TYPE_STRING 0x8000
102 #define TAG_TYPE_BINARY 0x9000
103
104 #define TAG_NULL 0x0
105
106 /* TAG_TYPE_NULL */
107 #define TAG_INCLUDE (0x1 | TAG_TYPE_NULL)
108 #define TAG_GENERAL (0x2 | TAG_TYPE_NULL)
109 #define TAG_MATCH_LOGIC_NOT (0x3 | TAG_TYPE_NULL)
110 #define TAG_APPLY_ALL_SHIMS (0x4 | TAG_TYPE_NULL)
111 #define TAG_USE_SERVICE_PACK_FILES (0x5 | TAG_TYPE_NULL)
112 #define TAG_MITIGATION_OS (0x6 | TAG_TYPE_NULL)
113 #define TAG_BLOCK_UPGRADE (0x7 | TAG_TYPE_NULL)
114 #define TAG_INCLUDEEXCLUDEDLL (0x8 | TAG_TYPE_NULL)
115 #define TAG_RAC_EVENT_OFF (0x9 | TAG_TYPE_NULL)
116 #define TAG_TELEMETRY_OFF (0xA | TAG_TYPE_NULL)
117 #define TAG_SHIM_ENGINE_OFF (0xB | TAG_TYPE_NULL)
118 #define TAG_LAYER_PROPAGATION_OFF (0xC | TAG_TYPE_NULL)
119 #define TAG_REINSTALL_UPGRADE (0xD | TAG_TYPE_NULL)
120
121 /* TAG_TYPE_BYTE */
122
123 /* TAG_TYPE_WORD */
124 #define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD)
125 #define TAG_TAG (0x801 | TAG_TYPE_WORD)
126 #define TAG_INDEX_TAG (0x802 | TAG_TYPE_WORD)
127 #define TAG_INDEX_KEY (0x803 | TAG_TYPE_WORD)
128
129 /* TAG_TYPE_DWORD */
130 #define TAG_SIZE (0x1 | TAG_TYPE_DWORD)
131 #define TAG_OFFSET (0x2 | TAG_TYPE_DWORD)
132 #define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD)
133 #define TAG_SHIM_TAGID (0x4 | TAG_TYPE_DWORD)
134 #define TAG_PATCH_TAGID (0x5 | TAG_TYPE_DWORD)
135 #define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD)
136 #define TAG_VERDATEHI (0x7 | TAG_TYPE_DWORD)
137 #define TAG_VERDATELO (0x8 | TAG_TYPE_DWORD)
138 #define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD)
139 #define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD)
140 #define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD)
141 #define TAG_PREVOSMAJORVER (0xC | TAG_TYPE_DWORD)
142 #define TAG_PREVOSMINORVER (0xD | TAG_TYPE_DWORD)
143 #define TAG_PREVOSPLATFORMID (0xE | TAG_TYPE_DWORD)
144 #define TAG_PREVOSBUILDNO (0xF | TAG_TYPE_DWORD)
145 #define TAG_PROBLEMSEVERITY (0x10 | TAG_TYPE_DWORD)
146 #define TAG_LANGID (0x11 | TAG_TYPE_DWORD)
147 #define TAG_VER_LANGUAGE (0x12 | TAG_TYPE_DWORD)
148 #define TAG_ENGINE (0x14 | TAG_TYPE_DWORD)
149 #define TAG_HTMLHELPID (0x15 | TAG_TYPE_DWORD)
150 #define TAG_INDEX_FLAGS (0x16 | TAG_TYPE_DWORD)
151 #define TAG_FLAGS (0x17 | TAG_TYPE_DWORD)
152 #define TAG_DATA_VALUETYPE (0x18 | TAG_TYPE_DWORD)
153 #define TAG_DATA_DWORD (0x19 | TAG_TYPE_DWORD)
154 #define TAG_LAYER_TAGID (0x1A | TAG_TYPE_DWORD)
155 #define TAG_MSI_TRANSFORM_TAGID (0x1B | TAG_TYPE_DWORD)
156 #define TAG_LINKER_VERSION (0x1C | TAG_TYPE_DWORD)
157 #define TAG_LINK_DATE (0x1D | TAG_TYPE_DWORD)
158 #define TAG_UPTO_LINK_DATE (0x1E | TAG_TYPE_DWORD)
159 #define TAG_OS_SERVICE_PACK (0x1F | TAG_TYPE_DWORD)
160 #define TAG_FLAG_TAGID (0x20 | TAG_TYPE_DWORD)
161 #define TAG_RUNTIME_PLATFORM (0x21 | TAG_TYPE_DWORD)
162 #define TAG_OS_SKU (0x22 | TAG_TYPE_DWORD)
163 #define TAG_OS_PLATFORM (0x23 | TAG_TYPE_DWORD)
164 #define TAG_APP_NAME_RC_ID (0x24 | TAG_TYPE_DWORD)
165 #define TAG_VENDOR_NAME_RC_ID (0x25 | TAG_TYPE_DWORD)
166 #define TAG_SUMMARY_MSG_RC_ID (0x26 | TAG_TYPE_DWORD)
167 #define TAG_VISTA_SKU (0x27 | TAG_TYPE_DWORD)
168 #define TAG_DESCRIPTION_RC_ID (0x28 | TAG_TYPE_DWORD)
169 #define TAG_PARAMETER1_RC_ID (0x29 | TAG_TYPE_DWORD)
170 #define TAG_CONTEXT_TAGID (0x30 | TAG_TYPE_DWORD)
171 #define TAG_EXE_WRAPPER (0x31 | TAG_TYPE_DWORD)
172 #define TAG_TAGID (0x801 | TAG_TYPE_DWORD)
173
174 /* TAG_TYPE_QWORD */
175 #define TAG_TIME (0x1 | TAG_TYPE_QWORD)
176 #define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD)
177 #define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD)
178 #define TAG_MODTIME (0x4 | TAG_TYPE_QWORD)
179 #define TAG_FLAG_MASK_KERNEL (0x5 | TAG_TYPE_QWORD)
180 #define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD)
181 #define TAG_DATA_QWORD (0x7 | TAG_TYPE_QWORD)
182 #define TAG_FLAG_MASK_USER (0x8 | TAG_TYPE_QWORD)
183 #define TAG_FLAGS_NTVDM1 (0x9 | TAG_TYPE_QWORD)
184 #define TAG_FLAGS_NTVDM2 (0xA | TAG_TYPE_QWORD)
185 #define TAG_FLAGS_NTVDM3 (0xB | TAG_TYPE_QWORD)
186 #define TAG_FLAG_MASK_SHELL (0xC | TAG_TYPE_QWORD)
187 #define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD)
188 #define TAG_FLAG_MASK_FUSION (0xE | TAG_TYPE_QWORD)
189 #define TAG_FLAG_PROCESSPARAM (0xF | TAG_TYPE_QWORD)
190 #define TAG_FLAG_LUA (0x10 | TAG_TYPE_QWORD)
191 #define TAG_FLAG_INSTALL (0x11 | TAG_TYPE_QWORD)
192
193 /* TAG_TYPE_STRINGREF */
194 #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF)
195 #define TAG_DESCRIPTION (0x2 | TAG_TYPE_STRINGREF)
196 #define TAG_MODULE (0x3 | TAG_TYPE_STRINGREF)
197 #define TAG_API (0x4 | TAG_TYPE_STRINGREF)
198 #define TAG_VENDOR (0x5 | TAG_TYPE_STRINGREF)
199 #define TAG_APP_NAME (0x6 | TAG_TYPE_STRINGREF)
200 #define TAG_COMMAND_LINE (0x8 | TAG_TYPE_STRINGREF)
201 #define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF)
202 #define TAG_DLLFILE (0xA | TAG_TYPE_STRINGREF)
203 #define TAG_WILDCARD_NAME (0xB | TAG_TYPE_STRINGREF)
204 #define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF)
205 #define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF)
206 #define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF)
207 #define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF)
208 #define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF)
209 #define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF)
210 #define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF)
211 #define TAG_16BIT_DESCRIPTION (0x17 | TAG_TYPE_STRINGREF)
212 #define TAG_APPHELP_DETAILS (0x18 | TAG_TYPE_STRINGREF)
213 #define TAG_LINK_URL (0x19 | TAG_TYPE_STRINGREF)
214 #define TAG_LINK_TEXT (0x1A | TAG_TYPE_STRINGREF)
215 #define TAG_APPHELP_TITLE (0x1B | TAG_TYPE_STRINGREF)
216 #define TAG_APPHELP_CONTACT (0x1C | TAG_TYPE_STRINGREF)
217 #define TAG_SXS_MANIFEST (0x1D | TAG_TYPE_STRINGREF)
218 #define TAG_DATA_STRING (0x1E | TAG_TYPE_STRINGREF)
219 #define TAG_MSI_TRANSFORM_FILE (0x1F | TAG_TYPE_STRINGREF)
220 #define TAG_16BIT_MODULE_NAME (0x20 | TAG_TYPE_STRINGREF)
221 #define TAG_LAYER_DISPLAYNAME (0x21 | TAG_TYPE_STRINGREF)
222 #define TAG_COMPILER_VERSION (0x22 | TAG_TYPE_STRINGREF)
223 #define TAG_ACTION_TYPE (0x23 | TAG_TYPE_STRINGREF)
224 #define TAG_EXPORT_NAME (0x24 | TAG_TYPE_STRINGREF)
225
226 /* TAG_TYPE_LIST */
227 #define TAG_DATABASE (0x1 | TAG_TYPE_LIST)
228 #define TAG_LIBRARY (0x2 | TAG_TYPE_LIST)
229 #define TAG_INEXCLUD (0x3 | TAG_TYPE_LIST)
230 #define TAG_SHIM (0x4 | TAG_TYPE_LIST)
231 #define TAG_PATCH (0x5 | TAG_TYPE_LIST)
232 #define TAG_APP (0x6 | TAG_TYPE_LIST)
233 #define TAG_EXE (0x7 | TAG_TYPE_LIST)
234 #define TAG_MATCHING_FILE (0x8 | TAG_TYPE_LIST)
235 #define TAG_SHIM_REF (0x9| TAG_TYPE_LIST)
236 #define TAG_PATCH_REF (0xA | TAG_TYPE_LIST)
237 #define TAG_LAYER (0xB | TAG_TYPE_LIST)
238 #define TAG_FILE (0xC | TAG_TYPE_LIST)
239 #define TAG_APPHELP (0xD | TAG_TYPE_LIST)
240 #define TAG_LINK (0xE | TAG_TYPE_LIST)
241 #define TAG_DATA (0xF | TAG_TYPE_LIST)
242 #define TAG_MSI_TRANSFORM (0x10 | TAG_TYPE_LIST)
243 #define TAG_MSI_TRANSFORM_REF (0x11 | TAG_TYPE_LIST)
244 #define TAG_MSI_PACKAGE (0x12 | TAG_TYPE_LIST)
245 #define TAG_FLAG (0x13 | TAG_TYPE_LIST)
246 #define TAG_MSI_CUSTOM_ACTION (0x14 | TAG_TYPE_LIST)
247 #define TAG_FLAG_REF (0x15 | TAG_TYPE_LIST)
248 #define TAG_ACTION (0x16 | TAG_TYPE_LIST)
249 #define TAG_LOOKUP (0x17 | TAG_TYPE_LIST)
250 #define TAG_CONTEXT (0x18 | TAG_TYPE_LIST)
251 #define TAG_CONTEXT_REF (0x19 | TAG_TYPE_LIST)
252 #define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST)
253 #define TAG_INDEXES (0x802 | TAG_TYPE_LIST)
254 #define TAG_INDEX (0x803 | TAG_TYPE_LIST)
255
256 /* TAG_TYPE_STRING */
257 #define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING)
258
259 /* TAG_TYPE_BINARY */
260 #define TAG_PATCH_BITS (0x2 | TAG_TYPE_BINARY)
261 #define TAG_FILE_BITS (0x3 | TAG_TYPE_BINARY)
262 #define TAG_EXE_ID (0x4 | TAG_TYPE_BINARY)
263 #define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY)
264 #define TAG_MSI_PACKAGE_ID (0x6 | TAG_TYPE_BINARY)
265 #define TAG_DATABASE_ID (0x7 | TAG_TYPE_BINARY)
266 #define TAG_CONTEXT_PLATFORM_ID (0x8 | TAG_TYPE_BINARY)
267 #define TAG_CONTEXT_BRANCH_ID (0x9 | TAG_TYPE_BINARY)
268 #define TAG_FIX_ID (0x10 | TAG_TYPE_BINARY)
269 #define TAG_APP_ID (0x11 | TAG_TYPE_BINARY)
270 #define TAG_INDEX_BITS (0x801 | TAG_TYPE_BINARY)
271
272 #ifdef __cplusplus
273 } // extern "C"
274 #endif
275
276 #endif // APPHELP_H