ReactOS 0.4.16-dev-2284-g3529151
hsdb.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Application compatibility module
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Shim matching / data (un)packing
5 * COPYRIGHT: Copyright 2011 André Hentschel
6 * Copyright 2013 Mislav Blaževic
7 * Copyright 2015-2025 Mark Jansen <mark.jansen@reactos.org>
8 */
9
10#define WIN32_NO_STATUS
11#include "windows.h"
12#include "ntndk.h"
13#include "strsafe.h"
14#include "apphelp.h"
15#include "compat_undoc.h"
16
17#define MAX_LAYER_LENGTH 256
18#define GPLK_USER 1
19#define GPLK_MACHINE 2
20
21typedef struct _ShimData
22{
28 // Start ReactOS specific
30#ifdef _M_AMD64
32#endif
34
35#define SHIMDATA_MAGIC 0xAC0DEDAB
36#define REACTOS_COMPATVERSION_IGNOREMANIFEST 0xffffffff
37
41C_ASSERT(offsetof(ShimData, dwRosProcessCompatVersion) == offsetof(ReactOS_ShimData, dwRosProcessCompatVersion));
42#ifdef _M_AMD64
44#endif
45
47{
50}
51
52/* Given a 'MATCHING_FILE' tag and an ATTRINFO array,
53 check all tags defined in the MATCHING_FILE against the ATTRINFO */
54static BOOL SdbpMatchFileAttributes(PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
55{
57
58 for (child = SdbGetFirstChild(pdb, matching_file);
59 child != TAGID_NULL; child = SdbGetNextChild(pdb, matching_file, child))
60 {
62 DWORD n;
63
64 /* Already handled! */
65 if (tag == TAG_NAME)
66 continue;
67
71 {
72 SHIM_WARN("Unimplemented TAG_UPTO_XXXXX\n");
73 continue;
74 }
75
76 for (n = 0; n < attr_count; ++n)
77 {
79 if (attr->flags == ATTRIBUTE_AVAILABLE && attr->type == tag)
80 {
81 DWORD dwval;
82 WCHAR* lpval;
83 QWORD qwval;
84 switch (tag & TAG_TYPE_MASK)
85 {
86 case TAG_TYPE_DWORD:
87 dwval = SdbReadDWORDTag(pdb, child, 0);
88 if (dwval != attr->dwattr)
89 return FALSE;
90 break;
93 if (!lpval || _wcsicmp(attr->lpattr, lpval))
94 return FALSE;
95 break;
96 case TAG_TYPE_QWORD:
97 qwval = SdbReadQWORDTag(pdb, child, 0);
98 if (qwval != attr->qwattr)
99 return FALSE;
100 break;
101 default:
102 SHIM_WARN("Unhandled type 0x%x MATCHING_FILE\n", (tag & TAG_TYPE_MASK));
103 return FALSE;
104 }
105 }
106 }
107 if (n == attr_count)
108 SHIM_WARN("Unhandled tag %ws in MATCHING_FILE\n", SdbTagToString(tag));
109 }
110 return TRUE;
111}
112
113/* Given an 'exe' tag and an ATTRINFO array (for the main file),
114 verify that the main file and any additional files match */
115static BOOL WINAPI SdbpMatchExe(PDB pdb, TAGID exe, const WCHAR* dir, PATTRINFO main_attribs, DWORD main_attr_count)
116{
117 RTL_UNICODE_STRING_BUFFER FullPathName = { { 0 } };
118 WCHAR FullPathBuffer[MAX_PATH];
119 UNICODE_STRING UnicodeDir;
120 TAGID matching_file;
122 DWORD attr_count;
123 BOOL IsMatch = FALSE;
124
125 RtlInitUnicodeString(&UnicodeDir, dir);
126 RtlInitBuffer(&FullPathName.ByteBuffer, (PUCHAR)FullPathBuffer, sizeof(FullPathBuffer));
127
128 for (matching_file = SdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE);
129 matching_file != TAGID_NULL; matching_file = SdbFindNextTag(pdb, exe, matching_file))
130 {
131 TAGID tagName = SdbFindFirstTag(pdb, matching_file, TAG_NAME);
133 USHORT Len;
134
136
137 if (!Name.Buffer)
138 goto Cleanup;
139
140 /* An '*' here means use the main executable' */
141 if (!wcscmp(Name.Buffer, L"*"))
142 {
143 /* We already have these attributes, so we do not need to retrieve them */
144 if (!SdbpMatchFileAttributes(pdb, matching_file, main_attribs, main_attr_count))
145 goto Cleanup;
146 continue;
147 }
148
149 /* Technically, one UNICODE_NULL and one path separator. */
150 Len = UnicodeDir.Length + Name.Length + sizeof(UNICODE_NULL) + sizeof(UNICODE_NULL);
151 if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &FullPathName.ByteBuffer, Len)))
152 goto Cleanup;
153
154 if (Len > FullPathName.ByteBuffer.Size)
155 goto Cleanup;
156
157 RtlInitEmptyUnicodeString(&FullPathName.String, (PWCHAR)FullPathName.ByteBuffer.Buffer, FullPathName.ByteBuffer.Size);
158
159 RtlCopyUnicodeString(&FullPathName.String, &UnicodeDir);
160 RtlAppendUnicodeToString(&FullPathName.String, L"\\");
162
163 /* If the file does not exist, do not bother trying to read it's attributes */
164 if (!SdbpFileExists(FullPathName.String.Buffer))
165 goto Cleanup;
166
167 /* Do we have some attributes from the previous iteration? */
168 if (attribs)
170
171 if (!SdbGetFileAttributes(FullPathName.String.Buffer, &attribs, &attr_count))
172 goto Cleanup;
173
174 if (!SdbpMatchFileAttributes(pdb, matching_file, attribs, attr_count))
175 goto Cleanup;
176 }
177
178 IsMatch = TRUE;
179
180Cleanup:
181 RtlFreeBuffer(&FullPathName.ByteBuffer);
182 if (attribs)
184
185 return IsMatch;
186}
187
188/* Add a database guid to the query result */
190{
191 size_t n;
192
193 for (n = 0; n < _countof(result->rgGuidDB); ++n)
194 {
195 if (!memcmp(&result->rgGuidDB[n], &pdb->database_id, sizeof(pdb->database_id)))
196 return;
197
198 if (result->dwCustomSDBMap & (1<<n))
199 continue;
200
201 memcpy(&result->rgGuidDB[n], &pdb->database_id, sizeof(result->rgGuidDB[n]));
202 result->dwCustomSDBMap |= (1<<n);
203 return;
204 }
205}
206
207/* Add one layer to the query result */
209{
210 size_t n;
211
212 for (n = 0; n < result->dwLayerCount; ++n)
213 {
214 if (result->atrLayers[n] == layer)
215 return FALSE;
216 }
217
218 if (n >= _countof(result->atrLayers))
219 return FALSE;
220
221 result->atrLayers[n] = layer;
222 result->dwLayerCount++;
223
224 return TRUE;
225}
226
227/* Translate a layer name to a tagref + add it to the query result */
229{
230 TAGID database, layer;
231 TAGREF tr;
232 PDB pdb = hsdb->pdb;
233
235 if (database == TAGID_NULL)
236 return FALSE;
237
239 if (layer == TAGID_NULL)
240 return FALSE;
241
242 if (!SdbTagIDToTagRef(hsdb, pdb, layer, &tr))
243 return FALSE;
244
246 return FALSE;
247
249 return TRUE;
250}
251
252/* Add all layers for the exe tag to the query result */
254{
256
257 while (layer != TAGID_NULL)
258 {
259 TAGREF tr;
261 DWORD tagId = SdbReadDWORDTag(pdb, layerIdTag, TAGID_NULL);
262
263 if (layerIdTag != TAGID_NULL &&
264 tagId != TAGID_NULL &&
265 SdbTagIDToTagRef(hsdb, pdb, tagId, &tr))
266 {
268 }
269 else
270 {
271 /* Try a name lookup */
272 TAGID layerTag = SdbFindFirstTag(pdb, layer, TAG_NAME);
273 if (layerTag != TAGID_NULL)
274 {
276 if (layerName)
277 {
279 }
280 }
281 }
282
283 layer = SdbFindNextTag(pdb, tagExe, layer);
284 }
285}
286
287/* Add an exe tag to the query result */
289{
290 size_t n;
291 TAGREF tr;
292
293 if (!SdbTagIDToTagRef(hsdb, pdb, tagExe, &tr))
294 return;
295
296 for (n = 0; n < result->dwExeCount; ++n)
297 {
298 if (result->atrExes[n] == tr)
299 return;
300 }
301
302 if (n >= _countof(result->atrExes))
303 return;
304
305 result->atrExes[n] = tr;
306 result->dwExeCount++;
307
308 SdbpAddExeLayers(hsdb, pdb, tagExe, result);
309
311}
312
313/* Add all named layers to the query result */
315{
317 ULONG Added = 0;
318
319 const PWSTR end = pwszLayers + (pdwBytes / sizeof(WCHAR));
320 while (start < end && (*start == L'!' || *start == L'#' || *start == L' ' || *start == L'\t'))
321 start++;
322
323 if (start == end)
324 return 0;
325
326 do
327 {
328 while (*start == L' ' || *start == L'\t')
329 ++start;
330
331 if (*start == UNICODE_NULL)
332 break;
333 p = wcspbrk(start, L" \t");
334
335 if (p)
336 *p = UNICODE_NULL;
337
339 Added++;
340
341 start = p + 1;
342 } while (start < end && p);
343
344 return Added;
345}
346
348{
349 static const UNICODE_STRING EnvKey = RTL_CONSTANT_STRING(L"__COMPAT_LAYER");
350 UNICODE_STRING EnvValue;
353
354 RtlInitEmptyUnicodeString(&EnvValue, Buffer, sizeof(Buffer));
355
356 Status = RtlQueryEnvironmentVariable_U(Environment, &EnvKey, &EnvValue);
357
358 if (!NT_SUCCESS(Status))
359 return FALSE;
360
361 return SdbpAddLayerMatches(hsdb, Buffer, EnvValue.Length, Result) > 0;
362}
363
364
365
376{
377 static const WCHAR shim[] = {'\\','s','y','s','m','a','i','n','.','s','d','b',0};
378 static const WCHAR msi[] = {'\\','m','s','i','m','a','i','n','.','s','d','b',0};
379 static const WCHAR drivers[] = {'\\','d','r','v','m','a','i','n','.','s','d','b',0};
381 WCHAR buffer[128];
382 HSDB hsdb;
383
384 hsdb = SdbAlloc(sizeof(SDB));
385 if (!hsdb)
386 return NULL;
387 hsdb->auto_loaded = 0;
388
389 /* Check for predefined databases */
391 {
393 {
394 case SDB_DATABASE_MAIN_SHIM: name = shim; break;
395 case SDB_DATABASE_MAIN_MSI: name = msi; break;
396 case SDB_DATABASE_MAIN_DRIVERS: name = drivers; break;
397 default:
398 SdbReleaseDatabase(hsdb);
399 return NULL;
400 }
404 }
405
406 hsdb->pdb = SdbOpenDatabase(path ? path : buffer, (flags & 0xF) - 1);
407
408 /* If database could not be loaded, a handle doesn't make sense either */
409 if (!hsdb->pdb)
410 {
411 SdbReleaseDatabase(hsdb);
412 return NULL;
413 }
414
415 return hsdb;
416}
417
424{
425 if (hsdb)
426 {
427 SdbCloseDatabase(hsdb->pdb);
428 SdbFree(hsdb);
429 }
430}
431
447{
448 BOOL ret = FALSE;
449 TAGID database, iter, name;
451 DWORD attr_count;
452 RTL_UNICODE_STRING_BUFFER DosApplicationName = { { 0 } };
453 WCHAR DosPathBuffer[MAX_PATH];
454 ULONG PathType = 0;
458 PDB pdb;
459
460 /* Load default database if one is not specified */
461 if (!hsdb)
462 {
463 /* To reproduce windows behaviour HID_DOS_PATHS needs
464 * to be specified when loading default database */
466 if (hsdb)
467 hsdb->auto_loaded = TRUE;
468 }
469
470 ZeroMemory(result, sizeof(*result));
471
472 /* No database could be loaded */
473 if (!hsdb || !path)
474 return FALSE;
475
476 /* We do not support multiple db's yet! */
477 pdb = hsdb->pdb;
478
479 RtlInitUnicodeString(&DosApplicationName.String, path);
480 RtlInitBuffer(&DosApplicationName.ByteBuffer, (PUCHAR)DosPathBuffer, sizeof(DosPathBuffer));
481 if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &DosApplicationName.ByteBuffer, DosApplicationName.String.MaximumLength)))
482 {
483 SHIM_ERR("Failed to convert allocate buffer.\n");
484 goto Cleanup;
485 }
486 /* Update the internal buffer to contain the string */
487 memcpy(DosApplicationName.ByteBuffer.Buffer, path, DosApplicationName.String.MaximumLength);
488 /* Make sure the string uses our internal buffer (we want to modify the buffer,
489 and RtlNtPathNameToDosPathName does not always modify the String to point to the Buffer)! */
490 DosApplicationName.String.Buffer = (PWSTR)DosApplicationName.ByteBuffer.Buffer;
491
492 if (!NT_SUCCESS(RtlNtPathNameToDosPathName(0, &DosApplicationName, &PathType, NULL)))
493 {
494 SHIM_ERR("Failed to convert %S to DOS Path.\n", path);
495 goto Cleanup;
496 }
497
498
499 /* Extract file name */
500 file_name = wcsrchr(DosApplicationName.String.Buffer, '\\');
501 if (!file_name)
502 {
503 SHIM_ERR("Failed to find Exe name in %wZ.\n", &DosApplicationName.String);
504 goto Cleanup;
505 }
506
507 /* We will use the buffer for exe name and directory. */
508 *(file_name++) = UNICODE_NULL;
509
510 /* DATABASE is list TAG which contains all executables */
512 if (database == TAGID_NULL)
513 {
514 goto Cleanup;
515 }
516
517 /*
518 * Instead of brute-force searching the 'entire' DB, we should:
519 * 1. Iterate over the Index TAG_EXE.TAG_WILDCARD_NAME
520 * 2. Search the index TAG_EXE.TAG_NAME (fallback to SdbFindFirstNamedTag)
521 * 3. Search the index TAG_EXE.TAG_16BIT_MODULE_NAME (fallback to SdbFindFirstNamedTag)
522 */
523
524
525 /* EXE is list TAG which contains data required to match executable */
526 for (iter = SdbFindFirstTag(pdb, database, TAG_EXE); iter != TAGID_NULL; iter = SdbFindNextTag(pdb, database, iter))
527 {
529 LPWSTR foundName = SdbGetStringTagPtr(pdb, name);
530 /* If this is a malformed DB, (no TAG_NAME), we should not crash. */
531 if (!foundName)
532 continue;
533
534 /* We only support full wildcard names for now */
535 BOOL isWildcard = foundName[0] == '*' && foundName[1] == UNICODE_NULL;
536
537 /* Check if exe name matches */
538 if (isWildcard || !_wcsicmp(foundName, file_name))
539 {
540 /* Get information about executable required to match it with database entry */
541 if (!attribs)
542 {
543 if (!SdbGetFileAttributes(path, &attribs, &attr_count))
544 goto Cleanup;
545 }
546
547
548 /* We have a null terminator before the application name, so DosApplicationName only contains the path. */
549 if (SdbpMatchExe(pdb, iter, DosApplicationName.String.Buffer, attribs, attr_count))
550 {
551 ret = TRUE;
552 SdbpAddExeMatch(hsdb, pdb, iter, result);
553 }
554 }
555 }
556
557 /* Restore the full path. */
558 *(--file_name) = L'\\';
559
560 dwSize = sizeof(wszLayers);
562 {
564 ret = TRUE;
565 }
566
568 {
570 {
571 ret = TRUE;
573 }
574 }
575
576Cleanup:
577 RtlFreeBuffer(&DosApplicationName.ByteBuffer);
578 if (attribs)
580 if (hsdb->auto_loaded)
581 SdbReleaseDatabase(hsdb);
582 return ret;
583}
584
593{
594 static WCHAR* default_dir = NULL;
595 static CONST WCHAR szAppPatch[] = {'\\','A','p','p','P','a','t','c','h',0};
596
597 /* In case function fails, path holds empty string */
598 if (size > 0)
599 *path = 0;
600
601 if (!default_dir)
602 {
603 WCHAR* tmp;
604 HRESULT hr = E_FAIL;
606 tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
607 if (tmp)
608 {
610 if (r && r < len)
611 {
612 hr = StringCchCatW(tmp, len+1, szAppPatch);
613 if (SUCCEEDED(hr))
614 {
615 if (InterlockedCompareExchangePointer((void**)&default_dir, tmp, NULL) == NULL)
616 tmp = NULL;
617 }
618 }
619 if (tmp)
620 SdbFree(tmp);
621 }
622 if (!default_dir)
623 {
624 SHIM_ERR("Unable to obtain default AppPatch directory (0x%x)\n", hr);
625 return hr;
626 }
627 }
628
629 if (!hsdb)
630 {
631 return StringCchCopyW(path, size, default_dir);
632 }
633 else
634 {
635 SHIM_ERR("Unimplemented for hsdb != NULL\n");
636 return E_NOTIMPL;
637 }
638}
639
640
652{
653 if (trWhich & 0xf0000000)
654 {
655 SHIM_ERR("Multiple shim databases not yet implemented!\n");
656 if (ppdb)
657 *ppdb = NULL;
658 if (ptiWhich)
660 return FALSE;
661 }
662
663 /* There seems to be no range checking on trWhich.. */
664 if (ppdb)
665 *ppdb = hsdb->pdb;
666 if (ptiWhich)
667 *ptiWhich = trWhich & 0x0fffffff;
668
669 return TRUE;
670}
671
683{
684 if (pdb != hsdb->pdb)
685 {
686 SHIM_ERR("Multiple shim databases not yet implemented!\n");
687 if (ptrWhich)
689 return FALSE;
690 }
691
692 if (ptrWhich)
693 *ptrWhich = tiWhich & 0x0fffffff;
694
695 return TRUE;
696}
697
698
699/* Convert a query result to shim data that will be loaded in the child process */
701{
703 HRESULT hr;
704 DWORD n;
705 BOOL bCloseDatabase = FALSE;
706
707 if (!pQueryResult || !ppData || !pdwSize)
708 {
709 SHIM_WARN("Invalid params: %p, %p, %p\n", pQueryResult, ppData, pdwSize);
710 return FALSE;
711 }
712
713 pData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ShimData));
714 if (!pData)
715 {
716 SHIM_WARN("Unable to allocate %d bytes\n", sizeof(ShimData));
717 return FALSE;
718 }
719
720 GetSystemWindowsDirectoryW(pData->szModule, _countof(pData->szModule));
721 hr = StringCchCatW(pData->szModule, _countof(pData->szModule), L"\\system32\\apphelp.dll");
722 if (!SUCCEEDED(hr))
723 {
724 SHIM_ERR("Unable to append module name (0x%x)\n", hr);
725 RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
726 return FALSE;
727 }
728
729 pData->dwSize = sizeof(*pData);
730 pData->dwMagic = SHIMDATA_MAGIC;
731 pData->Query = *pQueryResult;
732 pData->dwRosProcessCompatVersion = 0;
733 pData->szLayer[0] = UNICODE_NULL; /* TODO */
734
735 SHIM_INFO("\ndwFlags 0x%x\ndwMagic 0x%x\ntrExe 0x%x\ntrLayer 0x%x\n",
736 pData->Query.dwFlags, pData->dwMagic, pData->Query.atrExes[0], pData->Query.atrLayers[0]);
737
738 /* Database List */
739 /* 0x0 {GUID} NAME: Use to open HSDB */
740 if (hsdb == NULL)
741 {
743 bCloseDatabase = TRUE;
744 }
745
746 for (n = 0; n < pQueryResult->dwLayerCount; ++n)
747 {
748 DWORD dwValue = 0, dwType;
749 DWORD dwValueSize = sizeof(dwValue);
750 SHIM_INFO("Layer 0x%x\n", pQueryResult->atrLayers[n]);
751
752 if (SdbQueryData(hsdb, pQueryResult->atrLayers[n], L"SHIMVERSIONNT", &dwType, &dwValue, &dwValueSize) == ERROR_SUCCESS &&
753 dwType == REG_DWORD && dwValueSize == sizeof(dwValue))
754 {
756 dwValue = (dwValue % 100) | ((dwValue / 100) << 8);
757 if (dwValue > pData->dwRosProcessCompatVersion)
758 pData->dwRosProcessCompatVersion = dwValue;
759 }
760 }
761
762 if (pData->dwRosProcessCompatVersion)
763 SHIM_INFO("Setting ProcessCompatVersion 0x%x\n", pData->dwRosProcessCompatVersion);
764
765 if (bCloseDatabase)
766 SdbReleaseDatabase(hsdb);
767
768 *ppData = pData;
769 *pdwSize = pData->dwSize;
770
771 return TRUE;
772}
773
775{
776 ShimData* pShimData = pData;
777
778 if (!pShimData || pShimData->dwMagic != SHIMDATA_MAGIC || pShimData->dwSize < sizeof(ShimData))
779 return FALSE;
780
781 if (!pQueryResult)
782 return FALSE;
783
784 /* szLayer? */
785
786 *pQueryResult = pShimData->Query;
787 return TRUE;
788}
789
791{
792 if (!pData || pData->dwMagic != SHIMDATA_MAGIC)
793 return 0;
794
795 return pData->dwSize;
796}
797
798
813{
814 PDB pdb;
815 TAGID tiWhich, tiData;
816 DWORD dwResult;
817
818 if (!SdbTagRefToTagID(hsdb, trWhich, &pdb, &tiWhich))
819 {
820 SHIM_WARN("Unable to translate trWhich=0x%x\n", trWhich);
821 return ERROR_NOT_FOUND;
822 }
823
825
826 if (dwResult == ERROR_SUCCESS && ptrData)
827 SdbTagIDToTagRef(hsdb, pdb, tiData, ptrData);
828
829 return dwResult;
830}
831
832
846{
848}
static IN ULONG IN PWSTR OUT PCWSTR OUT PBOOLEAN OUT PATH_TYPE_AND_UNKNOWN * PathType
BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info)
Definition: sdbfileattr.c:214
#define SDB_DATABASE_MAIN_SHIM
Definition: apphelp.h:24
TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid)
Definition: sdbread.c:93
TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag)
Definition: sdbread.c:208
LPCWSTR WINAPI SdbTagToString(TAG tag)
Definition: sdbapi.c:771
#define SDB_DATABASE_MAIN_MSI
Definition: apphelp.h:23
TAGID WINAPI SdbGetFirstChild(PDB pdb, TAGID parent)
Definition: sdbread.c:142
DWORD WINAPI SdbQueryDataExTagID(PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData)
Definition: sdbapi.c:633
TAGID WINAPI SdbGetNextChild(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:171
TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
Definition: sdbapi.c:563
#define HID_DOS_PATHS
Definition: apphelp.h:19
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:146
#define HID_DATABASE_TYPE_MASK
Definition: apphelp.h:22
PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type)
Definition: sdbapi.c:329
#define SDBGMEF_IGNORE_ENVIRONMENT
Definition: apphelp.h:62
void WINAPI SdbCloseDatabase(PDB)
Definition: sdbapi.c:373
#define SDB_DATABASE_MAIN_DRIVERS
Definition: apphelp.h:25
QWORD WINAPI SdbReadQWORDTag(PDB pdb, TAGID tagid, QWORD ret)
Definition: sdbread.c:321
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:231
BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
Definition: sdbfileattr.c:239
DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret)
Definition: sdbread.c:305
#define SHIMREG_HAS_ENVIRONMENT
Definition: apphelp.h:59
LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid)
Definition: sdbread.c:375
DWORD TAGREF
DWORD TAGID
unsigned int dir
Definition: maze.c:112
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
Definition: bufpool.h:45
#define REACTOS_SHIMDATA_MAGIC
Definition: compat_undoc.h:19
static PDB pdb
Definition: db.cpp:173
static TAGREF LPCWSTR lpszDataName
Definition: db.cpp:176
#define TAG_LAYER
Definition: db.cpp:90
#define TAG_EXE
Definition: db.cpp:87
static TAGREF trWhich
Definition: db.cpp:172
#define TAGID_NULL
Definition: db.cpp:38
static PDB TAGID tiWhich
Definition: db.cpp:173
static TAGREF PDB TAGID * ptiWhich
Definition: db.cpp:172
static TAGREF PDB * ppdb
Definition: db.cpp:172
static LPCWSTR layerName
Definition: db.cpp:174
#define TAGID_ROOT
Definition: db.cpp:39
#define TAG_MATCHING_FILE
Definition: db.cpp:88
#define TAG_LAYER_TAGID
Definition: db.cpp:69
static TAGREF LPCWSTR LPDWORD lpdwDataType
Definition: db.cpp:176
static PDB TAGID TAGREF * ptrWhich
Definition: db.cpp:173
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:171
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:171
#define TAG_DATABASE
Definition: db.cpp:85
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD TAGREF * ptrData
Definition: db.cpp:177
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD lpcbBufferSize
Definition: db.cpp:176
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define Len
Definition: deflate.h:82
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2316
_ACRTIMP wchar_t *__cdecl wcspbrk(const wchar_t *, const wchar_t *)
Definition: wcs.c:2016
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
static const WCHAR Cleanup[]
Definition: register.c:80
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLenum GLsizei len
Definition: glext.h:6722
const GLint * attribs
Definition: glext.h:10538
#define SHIMDATA_MAGIC
Definition: hsdb.c:35
static BOOL SdbpAddNamedLayerMatch(HSDB hsdb, PCWSTR layerName, PSDBQUERYRESULT result)
Definition: hsdb.c:228
BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich)
Definition: hsdb.c:651
BOOL WINAPI SdbPackAppCompatData(HSDB hsdb, PSDBQUERYRESULT pQueryResult, PVOID *ppData, DWORD *pdwSize)
Definition: hsdb.c:700
static BOOL SdbpAddSingleLayerMatch(TAGREF layer, PSDBQUERYRESULT result)
Definition: hsdb.c:208
static void SdbpAddDatabaseGuid(PDB pdb, PSDBQUERYRESULT result)
Definition: hsdb.c:189
#define GPLK_USER
Definition: hsdb.c:18
BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result)
Definition: hsdb.c:445
struct _ShimData ShimData
static void SdbpAddExeMatch(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:288
#define REACTOS_COMPATVERSION_IGNOREMANIFEST
Definition: hsdb.c:36
HSDB WINAPI SdbInitDatabase(DWORD flags, LPCWSTR path)
Definition: hsdb.c:375
#define GPLK_MACHINE
Definition: hsdb.c:19
BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich)
Definition: hsdb.c:682
static BOOL SdbpMatchFileAttributes(PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
Definition: hsdb.c:54
static BOOL SdbpPropagateEnvLayers(HSDB hsdb, LPWSTR Environment, PSDBQUERYRESULT Result)
Definition: hsdb.c:347
void WINAPI SdbReleaseDatabase(HSDB hsdb)
Definition: hsdb.c:423
#define MAX_LAYER_LENGTH
Definition: hsdb.c:17
BOOL WINAPI SdbUnpackAppCompatData(HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult)
Definition: hsdb.c:774
static BOOL WINAPI SdbpMatchExe(PDB pdb, TAGID exe, const WCHAR *dir, PATTRINFO main_attribs, DWORD main_attr_count)
Definition: hsdb.c:115
DWORD WINAPI SdbQueryData(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
Definition: hsdb.c:845
static ULONG SdbpAddLayerMatches(HSDB hsdb, PWSTR pwszLayers, DWORD pdwBytes, PSDBQUERYRESULT result)
Definition: hsdb.c:314
static void SdbpAddExeLayers(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:253
DWORD WINAPI SdbQueryDataEx(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGREF *ptrData)
Definition: hsdb.c:812
static BOOL WINAPI SdbpFileExists(LPCWSTR path)
Definition: hsdb.c:46
DWORD WINAPI SdbGetAppCompatDataSize(ShimData *pData)
Definition: hsdb.c:790
HRESULT WINAPI SdbGetAppPatchDir(HSDB hsdb, LPWSTR path, DWORD size)
Definition: hsdb.c:592
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define C_ASSERT(e)
Definition: intsafe.h:73
static PCWSTR wszLayers
Definition: layerapi.c:34
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
static PWSTR pwszLayers
Definition: layerapi.c:35
if(dx< 0)
Definition: linetemp.h:194
#define ZeroMemory
Definition: minwinbase.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TAG_UPTO_BIN_FILE_VERSION
Definition: apphelp.c:62
#define TAG_UPTO_LINK_DATE
Definition: apphelp.c:57
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: apphelp.c:61
#define TAG_NULL
Definition: apphelp.c:45
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
Definition: env.c:37
LPCWSTR pszImageName
Definition: env.c:57
PSDBQUERYRESULT_VISTA PVOID * ppData
Definition: env.c:56
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPCWSTR file_name
Definition: protocol.c:147
static HWND child
Definition: cursoricon.c:298
static PVOID RtlGetCurrentDirectory_U_RtlpMsysDecoy
Definition: msys2.c:16
unsigned int UINT
Definition: ndis.h:50
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2498
NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(_In_opt_ PWSTR Environment, _In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value)
NTSYSAPI NTSTATUS NTAPI RtlNtPathNameToDosPathName(_In_ ULONG Flags, _Inout_ PRTL_UNICODE_STRING_BUFFER Path, _Out_opt_ PULONG PathType, _Out_opt_ PULONG Unknown)
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define UNICODE_NULL
#define CONST
Definition: pedump.c:81
unsigned short USHORT
Definition: pedump.c:61
#define REG_DWORD
Definition: sdbapi.c:615
DWORD SdbpStrlen(PCWSTR string)
Definition: sdbapi.c:152
#define SdbAlloc(size)
Definition: sdbpapi.h:35
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
#define SdbFree(mem)
Definition: sdbpapi.h:37
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77
#define SHIM_ERR(fmt,...)
Definition: sdbpapi.h:76
#define offsetof(TYPE, MEMBER)
#define TAGREF_NULL
Definition: sdbtypes.h:21
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109
UINT64 QWORD
Definition: shimdbg.c:104
#define TAG_TYPE_MASK
Definition: shimdbg.c:106
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
PUCHAR Buffer
Definition: rtltypes.h:1894
SIZE_T Size
Definition: rtltypes.h:1896
UNICODE_STRING String
Definition: rtltypes.h:1904
Definition: apphelp.h:30
BOOL auto_loaded
Definition: apphelp.h:32
PDB pdb
Definition: apphelp.h:31
Definition: hsdb.c:22
WCHAR szModule[MAX_PATH]
Definition: hsdb.c:23
DWORD dwRosProcessCompatVersion
Definition: hsdb.c:29
SDBQUERYRESULT Query
Definition: hsdb.c:26
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: hsdb.c:27
DWORD dwSize
Definition: hsdb.c:24
DWORD dwMagic
Definition: hsdb.c:25
Definition: fs_rec.h:143
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: cookie.c:202
Definition: name.c:39
TAGREF atrLayers[SDB_MAX_LAYERS]
Definition: ecma_167.h:138
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t * LPDWORD
Definition: typedefs.h:59
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_NAME
Definition: vfat.h:553
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define WINAPI
Definition: msvc.h:6
#define ERROR_NOT_FOUND
Definition: winerror.h:1014
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184