f9f25002bca2e2cb375a30267b83ab914e0f8fb8
[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 #define HID_DATABASE_TYPE_MASK 0xF00F0000
36 #define SDB_DATABASE_MAIN_MSI 0x80020000
37 #define SDB_DATABASE_MAIN_SHIM 0x80030000
38 #define SDB_DATABASE_MAIN_DRIVERS 0x80040000
39
40 typedef struct tagATTRINFO {
41 TAG type;
42 DWORD flags;
43 union {
44 QWORD qwattr;
45 DWORD dwattr;
46 WCHAR *lpattr;
47 };
48 } ATTRINFO, *PATTRINFO;
49
50 typedef enum _SHIM_LOG_LEVEL {
51 SHIM_ERR = 1,
52 SHIM_WARN = 2,
53 SHIM_INFO = 3,
54 }SHIM_LOG_LEVEL;
55
56 /* apphelp.c */
57 BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format, ...);
58 extern ULONG g_ShimDebugLevel;
59
60 #define SHIM_ERR(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
61 #define SHIM_WARN(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
62 #define SHIM_INFO(fmt, ...) do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
63
64
65 /* sdbapi.c */
66 void SdbpHeapInit(void);
67 void SdbpHeapDeinit(void);
68 #if SDBAPI_DEBUG_ALLOC
69
70 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
71 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, int line, const char* file);
72 void SdbpFree(LPVOID mem, int line, const char* file);
73
74 #define SdbAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
75 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size, __LINE__, __FILE__)
76 #define SdbFree(mem) SdbpFree(mem, __LINE__, __FILE__)
77
78 #else
79
80 LPVOID SdbpAlloc(SIZE_T size);
81 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size);
82 void SdbpFree(LPVOID mem);
83
84 #define SdbAlloc(size) SdbpAlloc(size)
85 #define SdbReAlloc(mem, size) SdbpReAlloc(mem, size)
86 #define SdbFree(mem) SdbpFree(mem)
87
88 #endif
89
90 typedef struct tagMEMMAPPED {
91 HANDLE file;
92 HANDLE section;
93 PBYTE view;
94 SIZE_T size;
95 SIZE_T mapped_size;
96 } MEMMAPPED, *PMEMMAPPED;
97
98 BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping);
99 void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping);
100 DWORD SdbpStrlen(LPCWSTR string);
101 PWSTR SdbpStrDup(LPCWSTR string);
102
103
104 /* layer.c */
105 BOOL WINAPI AllowPermLayer(PCWSTR path);
106 BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags);
107 BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable);
108
109
110 #define ATTRIBUTE_AVAILABLE 0x1
111 #define ATTRIBUTE_FAILED 0x2
112
113 #define TAGID_NULL 0x0
114 #define TAGID_ROOT 0x0
115
116 /* The above definition of TAGID_ROOT is used in winapi and can be found
117 * on msdn it but doesn't make sense, especially internally, because
118 * TAGID represents offset into database data and there is a header at
119 * offset 0, NOT a tag. Therfore, this definition should be used internally
120 * to represent first valid TAGID. Header size is 12 bytes. */
121 #define _TAGID_ROOT 12
122
123 #define TAG_TYPE_MASK 0xF000
124
125 #define TAG_TYPE_NULL 0x1000
126 #define TAG_TYPE_BYTE 0x2000
127 #define TAG_TYPE_WORD 0x3000
128 #define TAG_TYPE_DWORD 0x4000
129 #define TAG_TYPE_QWORD 0x5000
130 #define TAG_TYPE_STRINGREF 0x6000
131 #define TAG_TYPE_LIST 0x7000
132 #define TAG_TYPE_STRING 0x8000
133 #define TAG_TYPE_BINARY 0x9000
134
135 #define TAG_NULL 0x0
136
137 /* TAG_TYPE_NULL */
138 #define TAG_INCLUDE (0x1 | TAG_TYPE_NULL)
139 #define TAG_GENERAL (0x2 | TAG_TYPE_NULL)
140 #define TAG_MATCH_LOGIC_NOT (0x3 | TAG_TYPE_NULL)
141 #define TAG_APPLY_ALL_SHIMS (0x4 | TAG_TYPE_NULL)
142 #define TAG_USE_SERVICE_PACK_FILES (0x5 | TAG_TYPE_NULL)
143 #define TAG_MITIGATION_OS (0x6 | TAG_TYPE_NULL)
144 #define TAG_BLOCK_UPGRADE (0x7 | TAG_TYPE_NULL)
145 #define TAG_INCLUDEEXCLUDEDLL (0x8 | TAG_TYPE_NULL)
146 #define TAG_RAC_EVENT_OFF (0x9 | TAG_TYPE_NULL)
147 #define TAG_TELEMETRY_OFF (0xA | TAG_TYPE_NULL)
148 #define TAG_SHIM_ENGINE_OFF (0xB | TAG_TYPE_NULL)
149 #define TAG_LAYER_PROPAGATION_OFF (0xC | TAG_TYPE_NULL)
150 #define TAG_REINSTALL_UPGRADE (0xD | TAG_TYPE_NULL)
151
152 /* TAG_TYPE_BYTE */
153
154 /* TAG_TYPE_WORD */
155 #define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD)
156 #define TAG_TAG (0x801 | TAG_TYPE_WORD)
157 #define TAG_INDEX_TAG (0x802 | TAG_TYPE_WORD)
158 #define TAG_INDEX_KEY (0x803 | TAG_TYPE_WORD)
159
160 /* TAG_TYPE_DWORD */
161 #define TAG_SIZE (0x1 | TAG_TYPE_DWORD)
162 #define TAG_OFFSET (0x2 | TAG_TYPE_DWORD)
163 #define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD)
164 #define TAG_SHIM_TAGID (0x4 | TAG_TYPE_DWORD)
165 #define TAG_PATCH_TAGID (0x5 | TAG_TYPE_DWORD)
166 #define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD)
167 #define TAG_VERDATEHI (0x7 | TAG_TYPE_DWORD)
168 #define TAG_VERDATELO (0x8 | TAG_TYPE_DWORD)
169 #define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD)
170 #define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD)
171 #define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD)
172 #define TAG_PREVOSMAJORVER (0xC | TAG_TYPE_DWORD)
173 #define TAG_PREVOSMINORVER (0xD | TAG_TYPE_DWORD)
174 #define TAG_PREVOSPLATFORMID (0xE | TAG_TYPE_DWORD)
175 #define TAG_PREVOSBUILDNO (0xF | TAG_TYPE_DWORD)
176 #define TAG_PROBLEMSEVERITY (0x10 | TAG_TYPE_DWORD)
177 #define TAG_LANGID (0x11 | TAG_TYPE_DWORD)
178 #define TAG_VER_LANGUAGE (0x12 | TAG_TYPE_DWORD)
179 #define TAG_ENGINE (0x14 | TAG_TYPE_DWORD)
180 #define TAG_HTMLHELPID (0x15 | TAG_TYPE_DWORD)
181 #define TAG_INDEX_FLAGS (0x16 | TAG_TYPE_DWORD)
182 #define TAG_FLAGS (0x17 | TAG_TYPE_DWORD)
183 #define TAG_DATA_VALUETYPE (0x18 | TAG_TYPE_DWORD)
184 #define TAG_DATA_DWORD (0x19 | TAG_TYPE_DWORD)
185 #define TAG_LAYER_TAGID (0x1A | TAG_TYPE_DWORD)
186 #define TAG_MSI_TRANSFORM_TAGID (0x1B | TAG_TYPE_DWORD)
187 #define TAG_LINKER_VERSION (0x1C | TAG_TYPE_DWORD)
188 #define TAG_LINK_DATE (0x1D | TAG_TYPE_DWORD)
189 #define TAG_UPTO_LINK_DATE (0x1E | TAG_TYPE_DWORD)
190 #define TAG_OS_SERVICE_PACK (0x1F | TAG_TYPE_DWORD)
191 #define TAG_FLAG_TAGID (0x20 | TAG_TYPE_DWORD)
192 #define TAG_RUNTIME_PLATFORM (0x21 | TAG_TYPE_DWORD)
193 #define TAG_OS_SKU (0x22 | TAG_TYPE_DWORD)
194 #define TAG_OS_PLATFORM (0x23 | TAG_TYPE_DWORD)
195 #define TAG_APP_NAME_RC_ID (0x24 | TAG_TYPE_DWORD)
196 #define TAG_VENDOR_NAME_RC_ID (0x25 | TAG_TYPE_DWORD)
197 #define TAG_SUMMARY_MSG_RC_ID (0x26 | TAG_TYPE_DWORD)
198 #define TAG_VISTA_SKU (0x27 | TAG_TYPE_DWORD)
199 #define TAG_DESCRIPTION_RC_ID (0x28 | TAG_TYPE_DWORD)
200 #define TAG_PARAMETER1_RC_ID (0x29 | TAG_TYPE_DWORD)
201 #define TAG_CONTEXT_TAGID (0x30 | TAG_TYPE_DWORD)
202 #define TAG_EXE_WRAPPER (0x31 | TAG_TYPE_DWORD)
203 #define TAG_URL_ID (0x32 | TAG_TYPE_DWORD)
204 #define TAG_TAGID (0x801 | TAG_TYPE_DWORD)
205
206 /* TAG_TYPE_QWORD */
207 #define TAG_TIME (0x1 | TAG_TYPE_QWORD)
208 #define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD)
209 #define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD)
210 #define TAG_MODTIME (0x4 | TAG_TYPE_QWORD)
211 #define TAG_FLAG_MASK_KERNEL (0x5 | TAG_TYPE_QWORD)
212 #define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD)
213 #define TAG_DATA_QWORD (0x7 | TAG_TYPE_QWORD)
214 #define TAG_FLAG_MASK_USER (0x8 | TAG_TYPE_QWORD)
215 #define TAG_FLAGS_NTVDM1 (0x9 | TAG_TYPE_QWORD)
216 #define TAG_FLAGS_NTVDM2 (0xA | TAG_TYPE_QWORD)
217 #define TAG_FLAGS_NTVDM3 (0xB | TAG_TYPE_QWORD)
218 #define TAG_FLAG_MASK_SHELL (0xC | TAG_TYPE_QWORD)
219 #define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD)
220 #define TAG_FLAG_MASK_FUSION (0xE | TAG_TYPE_QWORD)
221 #define TAG_FLAG_PROCESSPARAM (0xF | TAG_TYPE_QWORD)
222 #define TAG_FLAG_LUA (0x10 | TAG_TYPE_QWORD)
223 #define TAG_FLAG_INSTALL (0x11 | TAG_TYPE_QWORD)
224
225 /* TAG_TYPE_STRINGREF */
226 #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF)
227 #define TAG_DESCRIPTION (0x2 | TAG_TYPE_STRINGREF)
228 #define TAG_MODULE (0x3 | TAG_TYPE_STRINGREF)
229 #define TAG_API (0x4 | TAG_TYPE_STRINGREF)
230 #define TAG_VENDOR (0x5 | TAG_TYPE_STRINGREF)
231 #define TAG_APP_NAME (0x6 | TAG_TYPE_STRINGREF)
232 #define TAG_COMMAND_LINE (0x8 | TAG_TYPE_STRINGREF)
233 #define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF)
234 #define TAG_DLLFILE (0xA | TAG_TYPE_STRINGREF)
235 #define TAG_WILDCARD_NAME (0xB | TAG_TYPE_STRINGREF)
236 #define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF)
237 #define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF)
238 #define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF)
239 #define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF)
240 #define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF)
241 #define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF)
242 #define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF)
243 #define TAG_16BIT_DESCRIPTION (0x17 | TAG_TYPE_STRINGREF)
244 #define TAG_APPHELP_DETAILS (0x18 | TAG_TYPE_STRINGREF)
245 #define TAG_LINK_URL (0x19 | TAG_TYPE_STRINGREF)
246 #define TAG_LINK_TEXT (0x1A | TAG_TYPE_STRINGREF)
247 #define TAG_APPHELP_TITLE (0x1B | TAG_TYPE_STRINGREF)
248 #define TAG_APPHELP_CONTACT (0x1C | TAG_TYPE_STRINGREF)
249 #define TAG_SXS_MANIFEST (0x1D | TAG_TYPE_STRINGREF)
250 #define TAG_DATA_STRING (0x1E | TAG_TYPE_STRINGREF)
251 #define TAG_MSI_TRANSFORM_FILE (0x1F | TAG_TYPE_STRINGREF)
252 #define TAG_16BIT_MODULE_NAME (0x20 | TAG_TYPE_STRINGREF)
253 #define TAG_LAYER_DISPLAYNAME (0x21 | TAG_TYPE_STRINGREF)
254 #define TAG_COMPILER_VERSION (0x22 | TAG_TYPE_STRINGREF)
255 #define TAG_ACTION_TYPE (0x23 | TAG_TYPE_STRINGREF)
256 #define TAG_EXPORT_NAME (0x24 | TAG_TYPE_STRINGREF)
257 #define TAG_URL (0x25 | TAG_TYPE_STRINGREF)
258
259 /* TAG_TYPE_LIST */
260 #define TAG_DATABASE (0x1 | TAG_TYPE_LIST)
261 #define TAG_LIBRARY (0x2 | TAG_TYPE_LIST)
262 #define TAG_INEXCLUD (0x3 | TAG_TYPE_LIST)
263 #define TAG_SHIM (0x4 | TAG_TYPE_LIST)
264 #define TAG_PATCH (0x5 | TAG_TYPE_LIST)
265 #define TAG_APP (0x6 | TAG_TYPE_LIST)
266 #define TAG_EXE (0x7 | TAG_TYPE_LIST)
267 #define TAG_MATCHING_FILE (0x8 | TAG_TYPE_LIST)
268 #define TAG_SHIM_REF (0x9| TAG_TYPE_LIST)
269 #define TAG_PATCH_REF (0xA | TAG_TYPE_LIST)
270 #define TAG_LAYER (0xB | TAG_TYPE_LIST)
271 #define TAG_FILE (0xC | TAG_TYPE_LIST)
272 #define TAG_APPHELP (0xD | TAG_TYPE_LIST)
273 #define TAG_LINK (0xE | TAG_TYPE_LIST)
274 #define TAG_DATA (0xF | TAG_TYPE_LIST)
275 #define TAG_MSI_TRANSFORM (0x10 | TAG_TYPE_LIST)
276 #define TAG_MSI_TRANSFORM_REF (0x11 | TAG_TYPE_LIST)
277 #define TAG_MSI_PACKAGE (0x12 | TAG_TYPE_LIST)
278 #define TAG_FLAG (0x13 | TAG_TYPE_LIST)
279 #define TAG_MSI_CUSTOM_ACTION (0x14 | TAG_TYPE_LIST)
280 #define TAG_FLAG_REF (0x15 | TAG_TYPE_LIST)
281 #define TAG_ACTION (0x16 | TAG_TYPE_LIST)
282 #define TAG_LOOKUP (0x17 | TAG_TYPE_LIST)
283 #define TAG_CONTEXT (0x18 | TAG_TYPE_LIST)
284 #define TAG_CONTEXT_REF (0x19 | TAG_TYPE_LIST)
285 #define TAG_SPC (0x20 | TAG_TYPE_LIST)
286 #define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST)
287 #define TAG_INDEXES (0x802 | TAG_TYPE_LIST)
288 #define TAG_INDEX (0x803 | TAG_TYPE_LIST)
289
290 /* TAG_TYPE_STRING */
291 #define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING)
292
293 /* TAG_TYPE_BINARY */
294 #define TAG_PATCH_BITS (0x2 | TAG_TYPE_BINARY)
295 #define TAG_FILE_BITS (0x3 | TAG_TYPE_BINARY)
296 #define TAG_EXE_ID (0x4 | TAG_TYPE_BINARY)
297 #define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY)
298 #define TAG_MSI_PACKAGE_ID (0x6 | TAG_TYPE_BINARY)
299 #define TAG_DATABASE_ID (0x7 | TAG_TYPE_BINARY)
300 #define TAG_CONTEXT_PLATFORM_ID (0x8 | TAG_TYPE_BINARY)
301 #define TAG_CONTEXT_BRANCH_ID (0x9 | TAG_TYPE_BINARY)
302 #define TAG_FIX_ID (0x10 | TAG_TYPE_BINARY)
303 #define TAG_APP_ID (0x11 | TAG_TYPE_BINARY)
304 #define TAG_INDEX_BITS (0x801 | TAG_TYPE_BINARY)
305
306 #ifdef __cplusplus
307 } // extern "C"
308 #endif
309
310 #endif // APPHELP_H