Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers...
[reactos.git] / dll / appcompat / apphelp / sdbapi.c
1 /*
2 * PROJECT: ReactOS Application compatibility module
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Sdb low level glue layer
5 * COPYRIGHT: Copyright 2011 André Hentschel
6 * Copyright 2013 Mislav Blaževic
7 * Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
8 */
9
10 #include "ntndk.h"
11 #include "strsafe.h"
12 #include "apphelp.h"
13 #include "sdbstringtable.h"
14
15
16 static const GUID GUID_DATABASE_MSI = {0xd8ff6d16,0x6a3a,0x468a, {0x8b,0x44,0x01,0x71,0x4d,0xdc,0x49,0xea}};
17 static const GUID GUID_DATABASE_SHIM = {0x11111111,0x1111,0x1111, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}};
18 static const GUID GUID_DATABASE_DRIVERS = {0xf9ab2228,0x3312,0x4a73, {0xb6,0xf9,0x93,0x6d,0x70,0xe1,0x12,0xef}};
19
20 static HANDLE SdbpHeap(void);
21
22 #if SDBAPI_DEBUG_ALLOC
23
24 /* dbgheap.c */
25 void SdbpInsertAllocation(PVOID address, SIZE_T size, int line, const char* file);
26 void SdbpUpdateAllocation(PVOID address, PVOID newaddress, SIZE_T size, int line, const char* file);
27 void SdbpRemoveAllocation(PVOID address, int line, const char* file);
28 void SdbpDebugHeapInit(HANDLE privateHeapPtr);
29 void SdbpDebugHeapDeinit(void);
30
31 #endif
32
33 static HANDLE g_Heap;
34 void SdbpHeapInit(void)
35 {
36 g_Heap = RtlCreateHeap(HEAP_GROWABLE, NULL, 0, 0x10000, NULL, NULL);
37 #if SDBAPI_DEBUG_ALLOC
38 SdbpDebugHeapInit(g_Heap);
39 #endif
40 }
41
42 void SdbpHeapDeinit(void)
43 {
44 #if SDBAPI_DEBUG_ALLOC
45 SdbpDebugHeapDeinit();
46 #endif
47 RtlDestroyHeap(g_Heap);
48 }
49
50 static HANDLE SdbpHeap(void)
51 {
52 return g_Heap;
53 }
54
55 LPVOID SdbpAlloc(SIZE_T size
56 #if SDBAPI_DEBUG_ALLOC
57 , int line, const char* file
58 #endif
59 )
60 {
61 LPVOID mem = RtlAllocateHeap(SdbpHeap(), HEAP_ZERO_MEMORY, size);
62 #if SDBAPI_DEBUG_ALLOC
63 SdbpInsertAllocation(mem, size, line, file);
64 #endif
65 return mem;
66 }
67
68 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize
69 #if SDBAPI_DEBUG_ALLOC
70 , int line, const char* file
71 #endif
72 )
73 {
74 LPVOID newmem = RtlReAllocateHeap(SdbpHeap(), HEAP_ZERO_MEMORY, mem, size);
75 #if SDBAPI_DEBUG_ALLOC
76 SdbpUpdateAllocation(mem, newmem, size, line, file);
77 #endif
78 return newmem;
79 }
80
81 void SdbpFree(LPVOID mem
82 #if SDBAPI_DEBUG_ALLOC
83 , int line, const char* file
84 #endif
85 )
86 {
87 #if SDBAPI_DEBUG_ALLOC
88 SdbpRemoveAllocation(mem, line, file);
89 #endif
90 RtlFreeHeap(SdbpHeap(), 0, mem);
91 }
92
93 PDB WINAPI SdbpCreate(LPCWSTR path, PATH_TYPE type, BOOL write)
94 {
95 NTSTATUS Status;
96 IO_STATUS_BLOCK io;
97 OBJECT_ATTRIBUTES attr;
98 UNICODE_STRING str;
99 PDB pdb;
100
101 if (type == DOS_PATH)
102 {
103 if (!RtlDosPathNameToNtPathName_U(path, &str, NULL, NULL))
104 return NULL;
105 }
106 else
107 {
108 RtlInitUnicodeString(&str, path);
109 }
110
111 /* SdbAlloc zeroes the memory. */
112 pdb = (PDB)SdbAlloc(sizeof(DB));
113 if (!pdb)
114 {
115 SHIM_ERR("Failed to allocate memory for shim database\n");
116 return NULL;
117 }
118
119 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, NULL, NULL);
120
121 Status = NtCreateFile(&pdb->file, (write ? FILE_GENERIC_WRITE : FILE_GENERIC_READ )| SYNCHRONIZE,
122 &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
123 write ? FILE_SUPERSEDE : FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
124
125 pdb->for_write = write;
126
127 if (type == DOS_PATH)
128 RtlFreeUnicodeString(&str);
129
130 if (!NT_SUCCESS(Status))
131 {
132 SdbCloseDatabase(pdb);
133 SHIM_ERR("Failed to create shim database file: %lx\n", Status);
134 return NULL;
135 }
136
137 return pdb;
138 }
139
140 void WINAPI SdbpFlush(PDB pdb)
141 {
142 IO_STATUS_BLOCK io;
143 NTSTATUS Status;
144
145 ASSERT(pdb->for_write);
146 Status = NtWriteFile(pdb->file, NULL, NULL, NULL, &io,
147 pdb->data, pdb->write_iter, NULL, NULL);
148 if( !NT_SUCCESS(Status))
149 SHIM_WARN("failed with 0x%lx\n", Status);
150 }
151
152 DWORD SdbpStrlen(PCWSTR string)
153 {
154 return wcslen(string);
155 }
156
157 DWORD SdbpStrsize(PCWSTR string)
158 {
159 return (SdbpStrlen(string) + 1) * sizeof(WCHAR);
160 }
161
162 PWSTR SdbpStrDup(LPCWSTR string)
163 {
164 PWSTR ret = SdbAlloc(SdbpStrsize(string));
165 wcscpy(ret, string);
166 return ret;
167 }
168
169
170 BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping)
171 {
172 NTSTATUS Status;
173 OBJECT_ATTRIBUTES ObjectAttributes;
174 IO_STATUS_BLOCK IoStatusBlock;
175 FILE_STANDARD_INFORMATION FileStandard;
176 UNICODE_STRING FileName;
177
178 RtlZeroMemory(mapping, sizeof(*mapping));
179
180 if(!RtlDosPathNameToNtPathName_U(path, &FileName, NULL, NULL))
181 {
182 RtlFreeUnicodeString(&FileName);
183 return FALSE;
184 }
185
186 InitializeObjectAttributes(&ObjectAttributes, &FileName, OBJ_CASE_INSENSITIVE, NULL, NULL);
187 Status = NtOpenFile(&mapping->file, GENERIC_READ | SYNCHRONIZE, &ObjectAttributes, &IoStatusBlock, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT);
188 RtlFreeUnicodeString(&FileName);
189
190 if (!NT_SUCCESS(Status))
191 {
192 SHIM_ERR("Failed to open file %S: 0x%lx\n", path, Status);
193 return FALSE;
194 }
195
196 Status = NtCreateSection(&mapping->section, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ, 0, 0, PAGE_READONLY, SEC_COMMIT, mapping->file);
197 if (!NT_SUCCESS(Status))
198 {
199 /* Special case */
200 if (Status == STATUS_MAPPED_FILE_SIZE_ZERO)
201 {
202 NtClose(mapping->file);
203 mapping->file = mapping->section = NULL;
204 return TRUE;
205 }
206 SHIM_ERR("Failed to create mapping for file: 0x%lx\n", Status);
207 goto err_out;
208 }
209
210 Status = NtQueryInformationFile(mapping->file, &IoStatusBlock, &FileStandard, sizeof(FileStandard), FileStandardInformation);
211 if (!NT_SUCCESS(Status))
212 {
213 SHIM_ERR("Failed to read file info for file: 0x%lx\n", Status);
214 goto err_out;
215 }
216
217 mapping->mapped_size = mapping->size = FileStandard.EndOfFile.LowPart;
218 Status = NtMapViewOfSection(mapping->section, NtCurrentProcess(), (PVOID*)&mapping->view, 0, 0, 0, &mapping->mapped_size, ViewUnmap, 0, PAGE_READONLY);
219 if (!NT_SUCCESS(Status))
220 {
221 SHIM_ERR("Failed to map view of file: 0x%lx\n", Status);
222 goto err_out;
223 }
224
225 return TRUE;
226
227 err_out:
228 if (!mapping->view)
229 {
230 if (mapping->section)
231 NtClose(mapping->section);
232 NtClose(mapping->file);
233 }
234 return FALSE;
235 }
236
237 void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping)
238 {
239 /* Prevent a VAD warning */
240 if (mapping->view)
241 NtUnmapViewOfSection(NtCurrentProcess(), mapping->view);
242 NtClose(mapping->section);
243 NtClose(mapping->file);
244 RtlZeroMemory(mapping, sizeof(*mapping));
245 }
246
247 BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type)
248 {
249 if ((tag & TAG_TYPE_MASK) != type)
250 return FALSE;
251 return TRUE;
252 }
253
254 BOOL WINAPI SdbpCheckTagIDType(PDB pdb, TAGID tagid, WORD type)
255 {
256 TAG tag = SdbGetTagFromTagID(pdb, tagid);
257 if (tag == TAG_NULL)
258 return FALSE;
259 return SdbpCheckTagType(tag, type);
260 }
261
262 PDB SdbpOpenDatabase(LPCWSTR path, PATH_TYPE type, PDWORD major, PDWORD minor)
263 {
264 IO_STATUS_BLOCK io;
265 FILE_STANDARD_INFORMATION fsi;
266 PDB pdb;
267 NTSTATUS Status;
268 BYTE header[12];
269
270 pdb = SdbpCreate(path, type, FALSE);
271 if (!pdb)
272 return NULL;
273
274 Status = NtQueryInformationFile(pdb->file, &io, &fsi, sizeof(FILE_STANDARD_INFORMATION), FileStandardInformation);
275 if (!NT_SUCCESS(Status))
276 {
277 SdbCloseDatabase(pdb);
278 SHIM_ERR("Failed to get shim database size: 0x%lx\n", Status);
279 return NULL;
280 }
281
282 pdb->size = fsi.EndOfFile.u.LowPart;
283 pdb->data = SdbAlloc(pdb->size);
284 Status = NtReadFile(pdb->file, NULL, NULL, NULL, &io, pdb->data, pdb->size, NULL, NULL);
285
286 if (!NT_SUCCESS(Status))
287 {
288 SdbCloseDatabase(pdb);
289 SHIM_ERR("Failed to open shim database file: 0x%lx\n", Status);
290 return NULL;
291 }
292
293 if (!SdbpReadData(pdb, &header, 0, 12))
294 {
295 SdbCloseDatabase(pdb);
296 SHIM_ERR("Failed to read shim database header\n");
297 return NULL;
298 }
299
300 if (memcmp(&header[8], "sdbf", 4) != 0)
301 {
302 SdbCloseDatabase(pdb);
303 SHIM_ERR("Shim database header is invalid\n");
304 return NULL;
305 }
306
307 *major = *(DWORD*)&header[0];
308 *minor = *(DWORD*)&header[4];
309
310 return pdb;
311 }
312
313
314 /**
315 * Opens specified shim database file.
316 *
317 * @param [in] path Path to the shim database.
318 * @param [in] type Type of path. Either DOS_PATH or NT_PATH.
319 *
320 * @return Success: Handle to the shim database, NULL otherwise.
321 */
322 PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type)
323 {
324 PDB pdb;
325 DWORD major, minor;
326
327 pdb = SdbpOpenDatabase(path, type, &major, &minor);
328 if (!pdb)
329 return NULL;
330
331 if (major != 2 && major != 3)
332 {
333 SdbCloseDatabase(pdb);
334 SHIM_ERR("Invalid shim database version\n");
335 return NULL;
336 }
337
338 pdb->stringtable = SdbFindFirstTag(pdb, TAGID_ROOT, TAG_STRINGTABLE);
339 if(!SdbGetDatabaseID(pdb, &pdb->database_id))
340 {
341 SHIM_INFO("Failed to get the database id\n");
342 }
343 return pdb;
344 }
345
346 /**
347 * Closes specified database and frees its memory.
348 *
349 * @param [in] pdb Handle to the shim database.
350 */
351 void WINAPI SdbCloseDatabase(PDB pdb)
352 {
353 if (!pdb)
354 return;
355
356 if (pdb->file)
357 NtClose(pdb->file);
358 if (pdb->string_buffer)
359 SdbCloseDatabase(pdb->string_buffer);
360 if (pdb->string_lookup)
361 SdbpTableDestroy(&pdb->string_lookup);
362 SdbFree(pdb->data);
363 SdbFree(pdb);
364 }
365
366 /**
367 * Parses a string to retrieve a GUID.
368 *
369 * @param [in] GuidString The string to parse.
370 * @param [out] Guid The resulting GUID.
371 *
372 * @return TRUE if it succeeds, FALSE if it fails.
373 */
374 BOOL WINAPI SdbGUIDFromString(PCWSTR GuidString, GUID *Guid)
375 {
376 UNICODE_STRING GuidString_u;
377 RtlInitUnicodeString(&GuidString_u, GuidString);
378 return NT_SUCCESS(RtlGUIDFromString(&GuidString_u, Guid));
379 }
380
381 /**
382 * Converts a GUID to a string.
383 *
384 * @param [in] Guid The GUID to convert.
385 * @param [out] GuidString The resulting string representation of Guid.
386 * @param [in] Length The length of GuidString.
387 *
388 * @return TRUE if it succeeds, FALSE if it fails.
389 */
390 BOOL WINAPI SdbGUIDToString(CONST GUID *Guid, PWSTR GuidString, SIZE_T Length)
391 {
392 UNICODE_STRING GuidString_u;
393 if(NT_SUCCESS(RtlStringFromGUID(Guid, &GuidString_u)))
394 {
395 HRESULT hr = StringCchCopyNW(GuidString, Length, GuidString_u.Buffer, GuidString_u.Length / 2);
396 RtlFreeUnicodeString(&GuidString_u);
397 return SUCCEEDED(hr);
398 }
399 return FALSE;
400 }
401
402 /**
403 * Checks if the specified GUID is a NULL GUID
404 *
405 * @param [in] Guid The GUID to check.
406 *
407 * @return TRUE if it is a NULL GUID.
408 */
409 BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid)
410 {
411 static GUID NullGuid = { 0 };
412 return !Guid || IsEqualGUID(&NullGuid, Guid);
413 }
414
415 /**
416 * Get the GUID from one of the standard databases.
417 *
418 * @param [in] Flags The ID to retrieve the guid from. (See SDB_DATABASE_MAIN_[xxx])
419 * @param [out] Guid The resulting GUID.
420 *
421 * @return TRUE if a known database ID.
422 */
423 BOOL WINAPI SdbGetStandardDatabaseGUID(DWORD Flags, GUID* Guid)
424 {
425 const GUID* copy_from = NULL;
426 switch(Flags & HID_DATABASE_TYPE_MASK)
427 {
428 case SDB_DATABASE_MAIN_MSI:
429 copy_from = &GUID_DATABASE_MSI;
430 break;
431 case SDB_DATABASE_MAIN_SHIM:
432 copy_from = &GUID_DATABASE_SHIM;
433 break;
434 case SDB_DATABASE_MAIN_DRIVERS:
435 copy_from = &GUID_DATABASE_DRIVERS;
436 break;
437 default:
438 SHIM_ERR("Cannot obtain database guid for databases other than main\n");
439 return FALSE;
440 }
441 if(Guid)
442 {
443 memcpy(Guid, copy_from, sizeof(GUID));
444 }
445 return TRUE;
446 }
447
448 /**
449 * Read the database version from the specified database.
450 *
451 * @param [in] database The database.
452 * @param [out] VersionHi The first part of the version number.
453 * @param [out] VersionLo The second part of the version number.
454 *
455 * @return TRUE if it succeeds or fails, FALSE if ???
456 */
457 BOOL WINAPI SdbGetDatabaseVersion(LPCWSTR database, PDWORD VersionHi, PDWORD VersionLo)
458 {
459 PDB pdb;
460
461 pdb = SdbpOpenDatabase(database, DOS_PATH, VersionHi, VersionLo);
462 if (pdb)
463 SdbCloseDatabase(pdb);
464
465 return TRUE;
466 }
467
468
469 /**
470 * Find the first named child tag.
471 *
472 * @param [in] database The database.
473 * @param [in] root The tag to start at
474 * @param [in] find The tag type to find
475 * @param [in] nametag The child of 'find' that contains the name
476 * @param [in] find_name The name to find
477 *
478 * @return The found tag, or TAGID_NULL on failure
479 */
480 TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
481 {
482 TAGID iter;
483
484 iter = SdbFindFirstTag(pdb, root, find);
485
486 while (iter != TAGID_NULL)
487 {
488 TAGID tmp = SdbFindFirstTag(pdb, iter, nametag);
489 if (tmp != TAGID_NULL)
490 {
491 LPCWSTR name = SdbGetStringTagPtr(pdb, tmp);
492 if (name && !wcsicmp(name, find_name))
493 return iter;
494 }
495 iter = SdbFindNextTag(pdb, root, iter);
496 }
497 return TAGID_NULL;
498 }
499
500
501 /**
502 * Find a named layer in a multi-db.
503 *
504 * @param [in] hsdb The multi-database.
505 * @param [in] layerName The named tag to find.
506 *
507 * @return The layer, or TAGREF_NULL on failure
508 */
509 TAGREF WINAPI SdbGetLayerTagRef(HSDB hsdb, LPCWSTR layerName)
510 {
511 PDB pdb = hsdb->pdb;
512
513 TAGID database = SdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
514 if (database != TAGID_NULL)
515 {
516 TAGID layer = SdbFindFirstNamedTag(pdb, database, TAG_LAYER, TAG_NAME, layerName);
517 if (layer != TAGID_NULL)
518 {
519 TAGREF tr;
520 if (SdbTagIDToTagRef(hsdb, pdb, layer, &tr))
521 {
522 return tr;
523 }
524 }
525 }
526 return TAGREF_NULL;
527 }
528
529
530 /**
531 * Converts the specified string to an index key.
532 *
533 * @param [in] str The string which will be converted.
534 *
535 * @return The resulting index key
536 *
537 * @todo: Fix this for unicode strings.
538 */
539 LONGLONG WINAPI SdbMakeIndexKeyFromString(LPCWSTR str)
540 {
541 LONGLONG result = 0;
542 int shift = 56;
543
544 while (*str && shift >= 0)
545 {
546 WCHAR c = toupper(*(str++));
547
548 if (c & 0xff)
549 {
550 result |= (((LONGLONG)(c & 0xff)) << shift);
551 shift -= 8;
552 }
553
554 if (shift < 0)
555 break;
556
557 c >>= 8;
558
559 if (c & 0xff)
560 {
561 result |= (((LONGLONG)(c & 0xff)) << shift);
562 shift -= 8;
563 }
564 }
565
566 return result;
567 }
568
569
570 /**
571 * Converts specified tag into a string.
572 *
573 * @param [in] tag The tag which will be converted to a string.
574 *
575 * @return Success: Pointer to the string matching specified tag, or L"InvalidTag" on failure.
576 *
577 */
578 LPCWSTR WINAPI SdbTagToString(TAG tag)
579 {
580 switch (tag)
581 {
582 case TAG_NULL: return L"NULL";
583
584 /* TAG_TYPE_NULL */
585 case TAG_INCLUDE: return L"INCLUDE";
586 case TAG_GENERAL: return L"GENERAL";
587 case TAG_MATCH_LOGIC_NOT: return L"MATCH_LOGIC_NOT";
588 case TAG_APPLY_ALL_SHIMS: return L"APPLY_ALL_SHIMS";
589 case TAG_USE_SERVICE_PACK_FILES: return L"USE_SERVICE_PACK_FILES";
590 case TAG_MITIGATION_OS: return L"MITIGATION_OS";
591 case TAG_BLOCK_UPGRADE: return L"BLOCK_UPGRADE";
592 case TAG_INCLUDEEXCLUDEDLL: return L"INCLUDEEXCLUDEDLL";
593 case TAG_RAC_EVENT_OFF: return L"RAC_EVENT_OFF";
594 case TAG_TELEMETRY_OFF: return L"TELEMETRY_OFF";
595 case TAG_SHIM_ENGINE_OFF: return L"SHIM_ENGINE_OFF";
596 case TAG_LAYER_PROPAGATION_OFF: return L"LAYER_PROPAGATION_OFF";
597 case TAG_REINSTALL_UPGRADE: return L"REINSTALL_UPGRADE";
598
599 /* TAG_TYPE_WORD */
600 case TAG_MATCH_MODE: return L"MATCH_MODE";
601 case TAG_TAG: return L"TAG";
602 case TAG_INDEX_TAG: return L"INDEX_TAG";
603 case TAG_INDEX_KEY: return L"INDEX_KEY";
604
605 /* TAG_TYPE_DWORD */
606 case TAG_SIZE: return L"SIZE";
607 case TAG_OFFSET: return L"OFFSET";
608 case TAG_CHECKSUM: return L"CHECKSUM";
609 case TAG_SHIM_TAGID: return L"SHIM_TAGID";
610 case TAG_PATCH_TAGID: return L"PATCH_TAGID";
611 case TAG_MODULE_TYPE: return L"MODULE_TYPE";
612 case TAG_VERDATEHI: return L"VERDATEHI";
613 case TAG_VERDATELO: return L"VERDATELO";
614 case TAG_VERFILEOS: return L"VERFILEOS";
615 case TAG_VERFILETYPE: return L"VERFILETYPE";
616 case TAG_PE_CHECKSUM: return L"PE_CHECKSUM";
617 case TAG_PREVOSMAJORVER: return L"PREVOSMAJORVER";
618 case TAG_PREVOSMINORVER: return L"PREVOSMINORVER";
619 case TAG_PREVOSPLATFORMID: return L"PREVOSPLATFORMID";
620 case TAG_PREVOSBUILDNO: return L"PREVOSBUILDNO";
621 case TAG_PROBLEMSEVERITY: return L"PROBLEMSEVERITY";
622 case TAG_LANGID: return L"LANGID";
623 case TAG_VER_LANGUAGE: return L"VER_LANGUAGE";
624 case TAG_ENGINE: return L"ENGINE";
625 case TAG_HTMLHELPID: return L"HTMLHELPID";
626 case TAG_INDEX_FLAGS: return L"INDEX_FLAGS";
627 case TAG_FLAGS: return L"FLAGS";
628 case TAG_DATA_VALUETYPE: return L"DATA_VALUETYPE";
629 case TAG_DATA_DWORD: return L"DATA_DWORD";
630 case TAG_LAYER_TAGID: return L"LAYER_TAGID";
631 case TAG_MSI_TRANSFORM_TAGID: return L"MSI_TRANSFORM_TAGID";
632 case TAG_LINKER_VERSION: return L"LINKER_VERSION";
633 case TAG_LINK_DATE: return L"LINK_DATE";
634 case TAG_UPTO_LINK_DATE: return L"UPTO_LINK_DATE";
635 case TAG_OS_SERVICE_PACK: return L"OS_SERVICE_PACK";
636 case TAG_FLAG_TAGID: return L"FLAG_TAGID";
637 case TAG_RUNTIME_PLATFORM: return L"RUNTIME_PLATFORM";
638 case TAG_OS_SKU: return L"OS_SKU";
639 case TAG_OS_PLATFORM: return L"OS_PLATFORM";
640 case TAG_APP_NAME_RC_ID: return L"APP_NAME_RC_ID";
641 case TAG_VENDOR_NAME_RC_ID: return L"VENDOR_NAME_RC_ID";
642 case TAG_SUMMARY_MSG_RC_ID: return L"SUMMARY_MSG_RC_ID";
643 case TAG_VISTA_SKU: return L"VISTA_SKU";
644 case TAG_DESCRIPTION_RC_ID: return L"DESCRIPTION_RC_ID";
645 case TAG_PARAMETER1_RC_ID: return L"PARAMETER1_RC_ID";
646 case TAG_CONTEXT_TAGID: return L"CONTEXT_TAGID";
647 case TAG_EXE_WRAPPER: return L"EXE_WRAPPER";
648 case TAG_URL_ID: return L"URL_ID";
649 case TAG_TAGID: return L"TAGID";
650
651 /* TAG_TYPE_QWORD */
652 case TAG_TIME: return L"TIME";
653 case TAG_BIN_FILE_VERSION: return L"BIN_FILE_VERSION";
654 case TAG_BIN_PRODUCT_VERSION: return L"BIN_PRODUCT_VERSION";
655 case TAG_MODTIME: return L"MODTIME";
656 case TAG_FLAG_MASK_KERNEL: return L"FLAG_MASK_KERNEL";
657 case TAG_UPTO_BIN_PRODUCT_VERSION: return L"UPTO_BIN_PRODUCT_VERSION";
658 case TAG_DATA_QWORD: return L"DATA_QWORD";
659 case TAG_FLAG_MASK_USER: return L"FLAG_MASK_USER";
660 case TAG_FLAGS_NTVDM1: return L"FLAGS_NTVDM1";
661 case TAG_FLAGS_NTVDM2: return L"FLAGS_NTVDM2";
662 case TAG_FLAGS_NTVDM3: return L"FLAGS_NTVDM3";
663 case TAG_FLAG_MASK_SHELL: return L"FLAG_MASK_SHELL";
664 case TAG_UPTO_BIN_FILE_VERSION: return L"UPTO_BIN_FILE_VERSION";
665 case TAG_FLAG_MASK_FUSION: return L"FLAG_MASK_FUSION";
666 case TAG_FLAG_PROCESSPARAM: return L"FLAG_PROCESSPARAM";
667 case TAG_FLAG_LUA: return L"FLAG_LUA";
668 case TAG_FLAG_INSTALL: return L"FLAG_INSTALL";
669
670 /* TAG_TYPE_STRINGREF */
671 case TAG_NAME: return L"NAME";
672 case TAG_DESCRIPTION: return L"DESCRIPTION";
673 case TAG_MODULE: return L"MODULE";
674 case TAG_API: return L"API";
675 case TAG_VENDOR: return L"VENDOR";
676 case TAG_APP_NAME: return L"APP_NAME";
677 case TAG_COMMAND_LINE: return L"COMMAND_LINE";
678 case TAG_COMPANY_NAME: return L"COMPANY_NAME";
679 case TAG_DLLFILE: return L"DLLFILE";
680 case TAG_WILDCARD_NAME: return L"WILDCARD_NAME";
681 case TAG_PRODUCT_NAME: return L"PRODUCT_NAME";
682 case TAG_PRODUCT_VERSION: return L"PRODUCT_VERSION";
683 case TAG_FILE_DESCRIPTION: return L"FILE_DESCRIPTION";
684 case TAG_FILE_VERSION: return L"FILE_VERSION";
685 case TAG_ORIGINAL_FILENAME: return L"ORIGINAL_FILENAME";
686 case TAG_INTERNAL_NAME: return L"INTERNAL_NAME";
687 case TAG_LEGAL_COPYRIGHT: return L"LEGAL_COPYRIGHT";
688 case TAG_16BIT_DESCRIPTION: return L"16BIT_DESCRIPTION";
689 case TAG_APPHELP_DETAILS: return L"APPHELP_DETAILS";
690 case TAG_LINK_URL: return L"LINK_URL";
691 case TAG_LINK_TEXT: return L"LINK_TEXT";
692 case TAG_APPHELP_TITLE: return L"APPHELP_TITLE";
693 case TAG_APPHELP_CONTACT: return L"APPHELP_CONTACT";
694 case TAG_SXS_MANIFEST: return L"SXS_MANIFEST";
695 case TAG_DATA_STRING: return L"DATA_STRING";
696 case TAG_MSI_TRANSFORM_FILE: return L"MSI_TRANSFORM_FILE";
697 case TAG_16BIT_MODULE_NAME: return L"16BIT_MODULE_NAME";
698 case TAG_LAYER_DISPLAYNAME: return L"LAYER_DISPLAYNAME";
699 case TAG_COMPILER_VERSION: return L"COMPILER_VERSION";
700 case TAG_ACTION_TYPE: return L"ACTION_TYPE";
701 case TAG_EXPORT_NAME: return L"EXPORT_NAME";
702 case TAG_URL: return L"URL";
703
704 /* TAG_TYPE_LIST */
705 case TAG_DATABASE: return L"DATABASE";
706 case TAG_LIBRARY: return L"LIBRARY";
707 case TAG_INEXCLUD: return L"INEXCLUDE";
708 case TAG_SHIM: return L"SHIM";
709 case TAG_PATCH: return L"PATCH";
710 case TAG_APP: return L"APP";
711 case TAG_EXE: return L"EXE";
712 case TAG_MATCHING_FILE: return L"MATCHING_FILE";
713 case TAG_SHIM_REF: return L"SHIM_REF";
714 case TAG_PATCH_REF: return L"PATCH_REF";
715 case TAG_LAYER: return L"LAYER";
716 case TAG_FILE: return L"FILE";
717 case TAG_APPHELP: return L"APPHELP";
718 case TAG_LINK: return L"LINK";
719 case TAG_DATA: return L"DATA";
720 case TAG_MSI_TRANSFORM: return L"MSI_TRANSFORM";
721 case TAG_MSI_TRANSFORM_REF: return L"MSI_TRANSFORM_REF";
722 case TAG_MSI_PACKAGE: return L"MSI_PACKAGE";
723 case TAG_FLAG: return L"FLAG";
724 case TAG_MSI_CUSTOM_ACTION: return L"MSI_CUSTOM_ACTION";
725 case TAG_FLAG_REF: return L"FLAG_REF";
726 case TAG_ACTION: return L"ACTION";
727 case TAG_LOOKUP: return L"LOOKUP";
728 case TAG_CONTEXT: return L"CONTEXT";
729 case TAG_CONTEXT_REF: return L"CONTEXT_REF";
730 case TAG_SPC: return L"SPC";
731 case TAG_STRINGTABLE: return L"STRINGTABLE";
732 case TAG_INDEXES: return L"INDEXES";
733 case TAG_INDEX: return L"INDEX";
734
735 /* TAG_TYPE_STRING */
736 case TAG_STRINGTABLE_ITEM: return L"STRINGTABLE_ITEM";
737
738 /* TAG_TYPE_BINARY */
739 case TAG_PATCH_BITS: return L"PATCH_BITS";
740 case TAG_FILE_BITS: return L"FILE_BITS";
741 case TAG_EXE_ID: return L"EXE_ID";
742 case TAG_DATA_BITS: return L"DATA_BITS";
743 case TAG_MSI_PACKAGE_ID: return L"MSI_PACKAGE_ID";
744 case TAG_DATABASE_ID: return L"DATABASE_ID";
745 case TAG_CONTEXT_PLATFORM_ID: return L"CONTEXT_PLATFORM_ID";
746 case TAG_CONTEXT_BRANCH_ID: return L"CONTEXT_BRANCH_ID";
747 case TAG_FIX_ID: return L"FIX_ID";
748 case TAG_APP_ID: return L"APP_ID";
749 case TAG_INDEX_BITS: return L"INDEX_BITS";
750
751 break;
752 }
753 return L"InvalidTag";
754 }