ReactOS  0.4.14-dev-77-gd9e7c48
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-2019 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 
21 typedef struct _ShimData
22 {
28  DWORD dwRosProcessCompatVersion; // ReactOS specific
29 } ShimData;
30 
31 #define SHIMDATA_MAGIC 0xAC0DEDAB
32 #define REACTOS_COMPATVERSION_IGNOREMANIFEST 0xffffffff
33 
35 C_ASSERT(sizeof(ShimData) == sizeof(ReactOS_ShimData));
36 C_ASSERT(offsetof(ShimData, dwMagic) == offsetof(ReactOS_ShimData, dwMagic));
37 C_ASSERT(offsetof(ShimData, dwRosProcessCompatVersion) == offsetof(ReactOS_ShimData, dwRosProcessCompatVersion));
38 
39 
41 {
44 }
45 
46 /* Given a 'MATCHING_FILE' tag and an ATTRINFO array,
47  check all tags defined in the MATCHING_FILE against the ATTRINFO */
48 static BOOL SdbpMatchFileAttributes(PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
49 {
50  TAGID child;
51 
52  for (child = SdbGetFirstChild(pdb, matching_file);
53  child != TAGID_NULL; child = SdbGetNextChild(pdb, matching_file, child))
54  {
56  DWORD n;
57 
58  /* Already handled! */
59  if (tag == TAG_NAME)
60  continue;
61 
65  {
66  SHIM_WARN("Unimplemented TAG_UPTO_XXXXX\n");
67  continue;
68  }
69 
70  for (n = 0; n < attr_count; ++n)
71  {
72  PATTRINFO attr = attribs + n;
73  if (attr->flags == ATTRIBUTE_AVAILABLE && attr->type == tag)
74  {
75  DWORD dwval;
76  WCHAR* lpval;
77  QWORD qwval;
78  switch (tag & TAG_TYPE_MASK)
79  {
80  case TAG_TYPE_DWORD:
81  dwval = SdbReadDWORDTag(pdb, child, 0);
82  if (dwval != attr->dwattr)
83  return FALSE;
84  break;
85  case TAG_TYPE_STRINGREF:
86  lpval = SdbGetStringTagPtr(pdb, child);
87  if (!lpval || wcsicmp(attr->lpattr, lpval))
88  return FALSE;
89  break;
90  case TAG_TYPE_QWORD:
91  qwval = SdbReadQWORDTag(pdb, child, 0);
92  if (qwval != attr->qwattr)
93  return FALSE;
94  break;
95  default:
96  SHIM_WARN("Unhandled type 0x%x MATCHING_FILE\n", (tag & TAG_TYPE_MASK));
97  return FALSE;
98  }
99  }
100  }
101  if (n == attr_count)
102  SHIM_WARN("Unhandled tag %ws in MATCHING_FILE\n", SdbTagToString(tag));
103  }
104  return TRUE;
105 }
106 
107 /* Given an 'exe' tag and an ATTRINFO array (for the main file),
108  verify that the main file and any additional files match */
109 static BOOL WINAPI SdbpMatchExe(PDB pdb, TAGID exe, const WCHAR* dir, PATTRINFO main_attribs, DWORD main_attr_count)
110 {
111  RTL_UNICODE_STRING_BUFFER FullPathName = { { 0 } };
112  WCHAR FullPathBuffer[MAX_PATH];
113  UNICODE_STRING UnicodeDir;
114  TAGID matching_file;
116  DWORD attr_count;
117  BOOL IsMatch = FALSE;
118 
119  RtlInitUnicodeString(&UnicodeDir, dir);
120  RtlInitBuffer(&FullPathName.ByteBuffer, (PUCHAR)FullPathBuffer, sizeof(FullPathBuffer));
121 
122  for (matching_file = SdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE);
123  matching_file != TAGID_NULL; matching_file = SdbFindNextTag(pdb, exe, matching_file))
124  {
125  TAGID tagName = SdbFindFirstTag(pdb, matching_file, TAG_NAME);
127  USHORT Len;
128 
130 
131  if (!Name.Buffer)
132  goto Cleanup;
133 
134  /* An '*' here means use the main executable' */
135  if (!wcscmp(Name.Buffer, L"*"))
136  {
137  /* We already have these attributes, so we do not need to retrieve them */
138  if (!SdbpMatchFileAttributes(pdb, matching_file, main_attribs, main_attr_count))
139  goto Cleanup;
140  continue;
141  }
142 
143  /* Technically, one UNICODE_NULL and one path separator. */
144  Len = UnicodeDir.Length + Name.Length + sizeof(UNICODE_NULL) + sizeof(UNICODE_NULL);
145  if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &FullPathName.ByteBuffer, Len)))
146  goto Cleanup;
147 
148  if (Len > FullPathName.ByteBuffer.Size)
149  goto Cleanup;
150 
151  RtlInitEmptyUnicodeString(&FullPathName.String, (PWCHAR)FullPathName.ByteBuffer.Buffer, FullPathName.ByteBuffer.Size);
152 
153  RtlCopyUnicodeString(&FullPathName.String, &UnicodeDir);
154  RtlAppendUnicodeToString(&FullPathName.String, L"\\");
155  RtlAppendUnicodeStringToString(&FullPathName.String, &Name);
156 
157  /* If the file does not exist, do not bother trying to read it's attributes */
158  if (!SdbpFileExists(FullPathName.String.Buffer))
159  goto Cleanup;
160 
161  /* Do we have some attributes from the previous iteration? */
162  if (attribs)
164 
165  if (!SdbGetFileAttributes(FullPathName.String.Buffer, &attribs, &attr_count))
166  goto Cleanup;
167 
168  if (!SdbpMatchFileAttributes(pdb, matching_file, attribs, attr_count))
169  goto Cleanup;
170  }
171 
172  IsMatch = TRUE;
173 
174 Cleanup:
175  RtlFreeBuffer(&FullPathName.ByteBuffer);
176  if (attribs)
178 
179  return IsMatch;
180 }
181 
182 /* Add a database guid to the query result */
184 {
185  size_t n;
186 
187  for (n = 0; n < _countof(result->rgGuidDB); ++n)
188  {
189  if (!memcmp(&result->rgGuidDB[n], &pdb->database_id, sizeof(pdb->database_id)))
190  return;
191 
192  if (result->dwCustomSDBMap & (1<<n))
193  continue;
194 
195  memcpy(&result->rgGuidDB[n], &pdb->database_id, sizeof(result->rgGuidDB[n]));
196  result->dwCustomSDBMap |= (1<<n);
197  return;
198  }
199 }
200 
201 /* Add one layer to the query result */
203 {
204  size_t n;
205 
206  for (n = 0; n < result->dwLayerCount; ++n)
207  {
208  if (result->atrLayers[n] == layer)
209  return FALSE;
210  }
211 
212  if (n >= _countof(result->atrLayers))
213  return FALSE;
214 
215  result->atrLayers[n] = layer;
216  result->dwLayerCount++;
217 
218  return TRUE;
219 }
220 
221 /* Translate a layer name to a tagref + add it to the query result */
223 {
224  TAGID database, layer;
225  TAGREF tr;
226  PDB pdb = hsdb->pdb;
227 
229  if (database == TAGID_NULL)
230  return FALSE;
231 
233  if (layer == TAGID_NULL)
234  return FALSE;
235 
236  if (!SdbTagIDToTagRef(hsdb, pdb, layer, &tr))
237  return FALSE;
238 
240  return FALSE;
241 
243  return TRUE;
244 }
245 
246 /* Add all layers for the exe tag to the query result */
248 {
250 
251  while (layer != TAGID_NULL)
252  {
253  TAGREF tr;
255  DWORD tagId = SdbReadDWORDTag(pdb, layerIdTag, TAGID_NULL);
256 
257  if (layerIdTag != TAGID_NULL &&
258  tagId != TAGID_NULL &&
259  SdbTagIDToTagRef(hsdb, pdb, tagId, &tr))
260  {
262  }
263  else
264  {
265  /* Try a name lookup */
266  TAGID layerTag = SdbFindFirstTag(pdb, layer, TAG_NAME);
267  if (layerTag != TAGID_NULL)
268  {
270  if (layerName)
271  {
273  }
274  }
275  }
276 
277  layer = SdbFindNextTag(pdb, tagExe, layer);
278  }
279 }
280 
281 /* Add an exe tag to the query result */
283 {
284  size_t n;
285  TAGREF tr;
286 
287  if (!SdbTagIDToTagRef(hsdb, pdb, tagExe, &tr))
288  return;
289 
290  for (n = 0; n < result->dwExeCount; ++n)
291  {
292  if (result->atrExes[n] == tr)
293  return;
294  }
295 
296  if (n >= _countof(result->atrExes))
297  return;
298 
299  result->atrExes[n] = tr;
300  result->dwExeCount++;
301 
302  SdbpAddExeLayers(hsdb, pdb, tagExe, result);
303 
305 }
306 
307 /* Add all named layers to the query result */
309 {
310  PWSTR start = pwszLayers, p;
311  ULONG Added = 0;
312 
313  const PWSTR end = pwszLayers + (pdwBytes / sizeof(WCHAR));
314  while (start < end && (*start == L'!' || *start == L'#' || *start == L' ' || *start == L'\t'))
315  start++;
316 
317  if (start == end)
318  return 0;
319 
320  do
321  {
322  while (*start == L' ' || *start == L'\t')
323  ++start;
324 
325  if (*start == UNICODE_NULL)
326  break;
327  p = wcspbrk(start, L" \t");
328 
329  if (p)
330  *p = UNICODE_NULL;
331 
332  if (SdbpAddNamedLayerMatch(hsdb, start, result))
333  Added++;
334 
335  start = p + 1;
336  } while (start < end && p);
337 
338  return Added;
339 }
340 
342 {
343  static const UNICODE_STRING EnvKey = RTL_CONSTANT_STRING(L"__COMPAT_LAYER");
344  UNICODE_STRING EnvValue;
347 
348  RtlInitEmptyUnicodeString(&EnvValue, Buffer, sizeof(Buffer));
349 
350  Status = RtlQueryEnvironmentVariable_U(Environment, &EnvKey, &EnvValue);
351 
352  if (!NT_SUCCESS(Status))
353  return FALSE;
354 
355  return SdbpAddLayerMatches(hsdb, Buffer, EnvValue.Length, Result) > 0;
356 }
357 
358 
359 
370 {
371  static const WCHAR shim[] = {'\\','s','y','s','m','a','i','n','.','s','d','b',0};
372  static const WCHAR msi[] = {'\\','m','s','i','m','a','i','n','.','s','d','b',0};
373  static const WCHAR drivers[] = {'\\','d','r','v','m','a','i','n','.','s','d','b',0};
374  LPCWSTR name;
375  WCHAR buffer[128];
376  HSDB hsdb;
377 
378  hsdb = SdbAlloc(sizeof(SDB));
379  if (!hsdb)
380  return NULL;
381  hsdb->auto_loaded = 0;
382 
383  /* Check for predefined databases */
384  if ((flags & HID_DATABASE_TYPE_MASK) && path == NULL)
385  {
386  switch (flags & HID_DATABASE_TYPE_MASK)
387  {
388  case SDB_DATABASE_MAIN_SHIM: name = shim; break;
389  case SDB_DATABASE_MAIN_MSI: name = msi; break;
390  case SDB_DATABASE_MAIN_DRIVERS: name = drivers; break;
391  default:
392  SdbReleaseDatabase(hsdb);
393  return NULL;
394  }
398  }
399 
400  hsdb->pdb = SdbOpenDatabase(path ? path : buffer, (flags & 0xF) - 1);
401 
402  /* If database could not be loaded, a handle doesn't make sense either */
403  if (!hsdb->pdb)
404  {
405  SdbReleaseDatabase(hsdb);
406  return NULL;
407  }
408 
409  return hsdb;
410 }
411 
418 {
419  if (hsdb)
420  {
421  SdbCloseDatabase(hsdb->pdb);
422  SdbFree(hsdb);
423  }
424 }
425 
441 {
442  BOOL ret = FALSE;
443  TAGID database, iter, name;
445  DWORD attr_count;
446  RTL_UNICODE_STRING_BUFFER DosApplicationName = { { 0 } };
447  WCHAR DosPathBuffer[MAX_PATH];
448  ULONG PathType = 0;
451  DWORD dwSize;
452  PDB pdb;
453 
454  /* Load default database if one is not specified */
455  if (!hsdb)
456  {
457  /* To reproduce windows behaviour HID_DOS_PATHS needs
458  * to be specified when loading default database */
460  if (hsdb)
461  hsdb->auto_loaded = TRUE;
462  }
463 
464  ZeroMemory(result, sizeof(*result));
465 
466  /* No database could be loaded */
467  if (!hsdb || !path)
468  return FALSE;
469 
470  /* We do not support multiple db's yet! */
471  pdb = hsdb->pdb;
472 
473  RtlInitUnicodeString(&DosApplicationName.String, path);
474  RtlInitBuffer(&DosApplicationName.ByteBuffer, (PUCHAR)DosPathBuffer, sizeof(DosPathBuffer));
475  if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &DosApplicationName.ByteBuffer, DosApplicationName.String.MaximumLength)))
476  {
477  SHIM_ERR("Failed to convert allocate buffer.");
478  goto Cleanup;
479  }
480  /* Update the internal buffer to contain the string */
481  memcpy(DosApplicationName.ByteBuffer.Buffer, path, DosApplicationName.String.MaximumLength);
482  /* Make sure the string uses our internal buffer (we want to modify the buffer,
483  and RtlNtPathNameToDosPathName does not always modify the String to point to the Buffer)! */
484  DosApplicationName.String.Buffer = (PWSTR)DosApplicationName.ByteBuffer.Buffer;
485 
486  if (!NT_SUCCESS(RtlNtPathNameToDosPathName(0, &DosApplicationName, &PathType, NULL)))
487  {
488  SHIM_ERR("Failed to convert %S to DOS Path.", path);
489  goto Cleanup;
490  }
491 
492 
493  /* Extract file name */
494  file_name = wcsrchr(DosApplicationName.String.Buffer, '\\');
495  if (!file_name)
496  {
497  SHIM_ERR("Failed to find Exe name in %wZ.", &DosApplicationName.String);
498  goto Cleanup;
499  }
500 
501  /* We will use the buffer for exe name and directory. */
502  *(file_name++) = UNICODE_NULL;
503 
504  /* DATABASE is list TAG which contains all executables */
506  if (database == TAGID_NULL)
507  {
508  goto Cleanup;
509  }
510 
511  /* EXE is list TAG which contains data required to match executable */
512  iter = SdbFindFirstTag(pdb, database, TAG_EXE);
513 
514  /* Search for entry in database, we should look into indexing tags! */
515  while (iter != TAGID_NULL)
516  {
517  LPWSTR foundName;
518  /* Check if exe name matches */
519  name = SdbFindFirstTag(pdb, iter, TAG_NAME);
520  /* If this is a malformed DB, (no TAG_NAME), we should not crash. */
521  foundName = SdbGetStringTagPtr(pdb, name);
522  if (foundName && !wcsicmp(foundName, file_name))
523  {
524  /* Get information about executable required to match it with database entry */
525  if (!attribs)
526  {
527  if (!SdbGetFileAttributes(path, &attribs, &attr_count))
528  goto Cleanup;
529  }
530 
531 
532  /* We have a null terminator before the application name, so DosApplicationName only contains the path. */
533  if (SdbpMatchExe(pdb, iter, DosApplicationName.String.Buffer, attribs, attr_count))
534  {
535  ret = TRUE;
536  SdbpAddExeMatch(hsdb, pdb, iter, result);
537  }
538  }
539 
540  /* Continue iterating */
541  iter = SdbFindNextTag(pdb, database, iter);
542  }
543 
544  /* Restore the full path. */
545  *(--file_name) = L'\\';
546 
547  dwSize = sizeof(wszLayers);
549  {
551  ret = TRUE;
552  }
553 
555  {
557  {
558  ret = TRUE;
559  result->dwFlags |= SHIMREG_HAS_ENVIRONMENT;
560  }
561  }
562 
563 Cleanup:
564  RtlFreeBuffer(&DosApplicationName.ByteBuffer);
565  if (attribs)
567  if (hsdb->auto_loaded)
568  SdbReleaseDatabase(hsdb);
569  return ret;
570 }
571 
580 {
581  static WCHAR* default_dir = NULL;
582  static CONST WCHAR szAppPatch[] = {'\\','A','p','p','P','a','t','c','h',0};
583 
584  /* In case function fails, path holds empty string */
585  if (size > 0)
586  *path = 0;
587 
588  if (!default_dir)
589  {
590  WCHAR* tmp;
591  HRESULT hr = E_FAIL;
592  UINT len = GetSystemWindowsDirectoryW(NULL, 0) + SdbpStrlen(szAppPatch);
593  tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
594  if (tmp)
595  {
597  if (r && r < len)
598  {
599  hr = StringCchCatW(tmp, len+1, szAppPatch);
600  if (SUCCEEDED(hr))
601  {
602  if (InterlockedCompareExchangePointer((void**)&default_dir, tmp, NULL) == NULL)
603  tmp = NULL;
604  }
605  }
606  if (tmp)
607  SdbFree(tmp);
608  }
609  if (!default_dir)
610  {
611  SHIM_ERR("Unable to obtain default AppPatch directory (0x%x)\n", hr);
612  return hr;
613  }
614  }
615 
616  if (!hsdb)
617  {
618  return StringCchCopyW(path, size, default_dir);
619  }
620  else
621  {
622  SHIM_ERR("Unimplemented for hsdb != NULL\n");
623  return E_NOTIMPL;
624  }
625 }
626 
627 
639 {
640  if (trWhich & 0xf0000000)
641  {
642  SHIM_ERR("Multiple shim databases not yet implemented!\n");
643  if (ppdb)
644  *ppdb = NULL;
645  if (ptiWhich)
646  *ptiWhich = TAG_NULL;
647  return FALSE;
648  }
649 
650  /* There seems to be no range checking on trWhich.. */
651  if (ppdb)
652  *ppdb = hsdb->pdb;
653  if (ptiWhich)
654  *ptiWhich = trWhich & 0x0fffffff;
655 
656  return TRUE;
657 }
658 
670 {
671  if (pdb != hsdb->pdb)
672  {
673  SHIM_ERR("Multiple shim databases not yet implemented!\n");
674  if (ptrWhich)
676  return FALSE;
677  }
678 
679  if (ptrWhich)
680  *ptrWhich = tiWhich & 0x0fffffff;
681 
682  return TRUE;
683 }
684 
685 
686 /* Convert a query result to shim data that will be loaded in the child process */
688 {
689  ShimData* pData;
690  HRESULT hr;
691  DWORD n;
692  BOOL bCloseDatabase = FALSE;
693 
694  if (!pQueryResult || !ppData || !pdwSize)
695  {
696  SHIM_WARN("Invalid params: %p, %p, %p\n", pQueryResult, ppData, pdwSize);
697  return FALSE;
698  }
699 
700  pData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ShimData));
701  if (!pData)
702  {
703  SHIM_WARN("Unable to allocate %d bytes\n", sizeof(ShimData));
704  return FALSE;
705  }
706 
707  GetSystemWindowsDirectoryW(pData->szModule, _countof(pData->szModule));
708  hr = StringCchCatW(pData->szModule, _countof(pData->szModule), L"\\system32\\apphelp.dll");
709  if (!SUCCEEDED(hr))
710  {
711  SHIM_ERR("Unable to append module name (0x%x)\n", hr);
712  RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
713  return FALSE;
714  }
715 
716  pData->dwSize = sizeof(*pData);
717  pData->dwMagic = SHIMDATA_MAGIC;
718  pData->Query = *pQueryResult;
719  pData->dwRosProcessCompatVersion = 0;
720  pData->szLayer[0] = UNICODE_NULL; /* TODO */
721 
722  SHIM_INFO("\ndwFlags 0x%x\ndwMagic 0x%x\ntrExe 0x%x\ntrLayer 0x%x\n",
723  pData->Query.dwFlags, pData->dwMagic, pData->Query.atrExes[0], pData->Query.atrLayers[0]);
724 
725  /* Database List */
726  /* 0x0 {GUID} NAME: Use to open HSDB */
727  if (hsdb == NULL)
728  {
730  bCloseDatabase = TRUE;
731  }
732 
733  for (n = 0; n < pQueryResult->dwLayerCount; ++n)
734  {
735  DWORD dwValue = 0, dwType;
736  DWORD dwValueSize = sizeof(dwValue);
737  SHIM_INFO("Layer 0x%x\n", pQueryResult->atrLayers[n]);
738 
739  if (SdbQueryData(hsdb, pQueryResult->atrLayers[n], L"SHIMVERSIONNT", &dwType, &dwValue, &dwValueSize) == ERROR_SUCCESS &&
740  dwType == REG_DWORD && dwValueSize == sizeof(dwValue))
741  {
743  dwValue = (dwValue % 100) | ((dwValue / 100) << 8);
744  if (dwValue > pData->dwRosProcessCompatVersion)
745  pData->dwRosProcessCompatVersion = dwValue;
746  }
747  }
748 
749  if (pData->dwRosProcessCompatVersion)
750  SHIM_INFO("Setting ProcessCompatVersion 0x%x\n", pData->dwRosProcessCompatVersion);
751 
752  if (bCloseDatabase)
753  SdbReleaseDatabase(hsdb);
754 
755  *ppData = pData;
756  *pdwSize = pData->dwSize;
757 
758  return TRUE;
759 }
760 
762 {
763  ShimData* pShimData = pData;
764 
765  if (!pShimData || pShimData->dwMagic != SHIMDATA_MAGIC || pShimData->dwSize < sizeof(ShimData))
766  return FALSE;
767 
768  if (!pQueryResult)
769  return FALSE;
770 
771  /* szLayer? */
772 
773  *pQueryResult = pShimData->Query;
774  return TRUE;
775 }
776 
778 {
779  if (!pData || pData->dwMagic != SHIMDATA_MAGIC)
780  return 0;
781 
782  return pData->dwSize;
783 }
784 
785 
800 {
801  PDB pdb;
802  TAGID tiWhich, tiData;
803  DWORD dwResult;
804 
805  if (!SdbTagRefToTagID(hsdb, trWhich, &pdb, &tiWhich))
806  {
807  SHIM_WARN("Unable to translate trWhich=0x%x\n", trWhich);
808  return ERROR_NOT_FOUND;
809  }
810 
812 
813  if (dwResult == ERROR_SUCCESS && ptrData)
814  SdbTagIDToTagRef(hsdb, pdb, tiData, ptrData);
815 
816  return dwResult;
817 }
818 
819 
833 {
835 }
DWORD TAGREF
static TAGREF PDB * ppdb
Definition: db.cpp:169
const uint16_t * PCWSTR
Definition: typedefs.h:55
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
DWORD WINAPI SdbQueryDataEx(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGREF *ptrData)
Definition: hsdb.c:799
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
static LPCWSTR layerName
Definition: db.cpp:171
#define TRUE
Definition: types.h:120
#define SDBGMEF_IGNORE_ENVIRONMENT
Definition: apphelp.h:59
#define TAG_NAME
Definition: vfat.h:547
C_ASSERT(SHIMDATA_MAGIC==REACTOS_SHIMDATA_MAGIC)
static PDB pdb
Definition: db.cpp:170
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT WINAPI SdbGetAppPatchDir(HSDB hsdb, LPWSTR path, DWORD size)
Definition: hsdb.c:579
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: hsdb.c:21
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
SIZE_T Size
Definition: rtltypes.h:1809
USHORT MaximumLength
Definition: env_spec_w32.h:370
LPCWSTR pszImageName
Definition: env.c:55
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:168
#define TAG_LAYER_TAGID
Definition: db.cpp:67
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107
BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
Definition: sdbfileattr.c:239
DWORD dwMagic
Definition: hsdb.c:25
static ULONG SdbpAddLayerMatches(HSDB hsdb, PWSTR pwszLayers, DWORD pdwBytes, PSDBQUERYRESULT result)
Definition: hsdb.c:308
uint16_t * PWSTR
Definition: typedefs.h:54
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const GLint * attribs
Definition: glext.h:10538
#define _countof(array)
Definition: fontsub.cpp:30
#define TAG_DATABASE
Definition: db.cpp:83
DWORD dwRosProcessCompatVersion
Definition: hsdb.c:28
unsigned char * PUCHAR
Definition: retypes.h:3
DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret)
Definition: sdbread.c:305
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
static PDB TAGID tiWhich
Definition: db.cpp:170
LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid)
Definition: sdbread.c:375
GLdouble n
Definition: glext.h:7729
BOOL WINAPI SdbUnpackAppCompatData(HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult)
Definition: hsdb.c:761
BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result)
Definition: hsdb.c:439
static BOOL SdbpAddNamedLayerMatch(HSDB hsdb, PCWSTR layerName, PSDBQUERYRESULT result)
Definition: hsdb.c:222
Definition: ecma_167.h:138
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
#define REACTOS_COMPATVERSION_IGNOREMANIFEST
Definition: hsdb.c:32
GLuint GLuint end
Definition: gl.h:1545
uint16_t * PWCHAR
Definition: typedefs.h:54
#define TAGREF_NULL
Definition: sdbtypes.h:21
#define TAG_NULL
Definition: apphelp.c:43
#define TAG_TYPE_MASK
Definition: shimdbg.c:106
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
Definition: env.c:35
#define E_FAIL
Definition: ddrawi.h:102
static HWND child
Definition: cursoricon.c:298
#define TAG_MATCHING_FILE
Definition: db.cpp:86
#define SdbFree(mem)
Definition: sdbpapi.h:37
void WINAPI SdbReleaseDatabase(HSDB hsdb)
Definition: hsdb.c:417
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
Definition: apphelp.h:27
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich)
Definition: hsdb.c:638
#define SDB_DATABASE_MAIN_SHIM
Definition: apphelp.h:24
#define TAG_EXE
Definition: db.cpp:85
static IN ULONG IN PWSTR OUT PCWSTR OUT PBOOLEAN OUT PATH_TYPE_AND_UNKNOWN * PathType
#define SdbAlloc(size)
Definition: sdbpapi.h:35
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: hsdb.c:27
static TAGREF PDB TAGID * ptiWhich
Definition: db.cpp:169
DWORD WINAPI SdbGetAppCompatDataSize(ShimData *pData)
Definition: hsdb.c:777
static PDB TAGID TAGREF * ptrWhich
Definition: db.cpp:170
#define UNICODE_NULL
static TAGREF trWhich
Definition: db.cpp:169
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SDB_DATABASE_MAIN_MSI
Definition: apphelp.h:23
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
static BOOL WINAPI SdbpMatchExe(PDB pdb, TAGID exe, const WCHAR *dir, PATTRINFO main_attribs, DWORD main_attr_count)
Definition: hsdb.c:109
static BOOL SdbpMatchFileAttributes(PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
Definition: hsdb.c:48
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
QWORD WINAPI SdbReadQWORDTag(PDB pdb, TAGID tagid, QWORD ret)
Definition: sdbread.c:321
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
struct NameRec_ * Name
Definition: cdprocs.h:464
static void SdbpAddDatabaseGuid(PDB pdb, PSDBQUERYRESULT result)
Definition: hsdb.c:183
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:142
NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(_In_opt_ PWSTR Environment, _In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value)
LPCWSTR WINAPI SdbTagToString(TAG tag)
Definition: sdbapi.c:752
static PWSTR pwszLayers
Definition: layerapi.c:35
smooth NULL
Definition: ftsmooth.c:416
#define offsetof(TYPE, MEMBER)
static BOOL WINAPI SdbpFileExists(LPCWSTR path)
Definition: hsdb.c:40
_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:426
DWORD WINAPI SdbQueryDataExTagID(PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData)
Definition: sdbapi.c:614
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define SDB_DATABASE_MAIN_DRIVERS
Definition: apphelp.h:25
Definition: bufpool.h:45
unsigned int dir
Definition: maze.c:112
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD TAGREF * ptrData
Definition: db.cpp:174
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define REACTOS_SHIMDATA_MAGIC
Definition: compat_undoc.h:15
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:231
static BOOL SdbpAddSingleLayerMatch(TAGREF layer, PSDBQUERYRESULT result)
Definition: hsdb.c:202
DWORD dwSize
Definition: hsdb.c:24
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
GLsizeiptr size
Definition: glext.h:5919
TAGID WINAPI SdbGetNextChild(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:171
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:77
UINT64 QWORD
Definition: shimdbg.c:104
BOOL WINAPI SdbPackAppCompatData(HSDB hsdb, PSDBQUERYRESULT pQueryResult, PVOID *ppData, DWORD *pdwSize)
Definition: hsdb.c:687
static TAGREF LPCWSTR lpszDataName
Definition: db.cpp:173
#define MAX_PATH
Definition: compat.h:26
#define MAX_LAYER_LENGTH
Definition: hsdb.c:17
#define WINAPI
Definition: msvc.h:8
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD lpcbBufferSize
Definition: db.cpp:173
unsigned long DWORD
Definition: ntddk_ex.h:95
#define Len
Definition: deflate.h:82
Definition: cookie.c:170
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
GLbitfield flags
Definition: glext.h:7161
#define HID_DOS_PATHS
Definition: apphelp.h:19
TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag)
Definition: sdbread.c:208
PSDBQUERYRESULT_VISTA PVOID * ppData
Definition: env.c:54
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108
void WINAPI SdbCloseDatabase(PDB)
Definition: sdbapi.c:373
int ret
static const WCHAR L[]
Definition: oid.c:1250
UNICODE_STRING String
Definition: rtltypes.h:1817
WCHAR szModule[MAX_PATH]
Definition: hsdb.c:23
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR Cleanup[]
Definition: register.c:80
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: apphelp.c:59
#define wcsicmp
Definition: string.h:1152
#define GPLK_MACHINE
Definition: hsdb.c:19
Status
Definition: gdiplustypes.h:24
#define TAGID_NULL
Definition: db.cpp:36
DWORD SdbpStrlen(PCWSTR string)
Definition: sdbapi.c:152
DWORD WINAPI SdbQueryData(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
Definition: hsdb.c:832
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
TAGREF atrLayers[SDB_MAX_LAYERS]
static TAGREF LPCWSTR LPDWORD lpdwDataType
Definition: db.cpp:173
unsigned short USHORT
Definition: pedump.c:61
GLuint start
Definition: gl.h:1545
NTSYSAPI NTSTATUS NTAPI RtlNtPathNameToDosPathName(_In_ ULONG Flags, _Inout_ PRTL_UNICODE_STRING_BUFFER Path, _Out_opt_ PULONG PathType, _Out_opt_ PULONG Unknown)
#define E_NOTIMPL
Definition: ddrawi.h:99
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
Definition: services.c:325
BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info)
Definition: sdbfileattr.c:214
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2355
#define TAG_LAYER
Definition: db.cpp:88
TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
Definition: sdbapi.c:544
unsigned int UINT
Definition: ndis.h:50
#define TAG_UPTO_BIN_FILE_VERSION
Definition: apphelp.c:60
#define GPLK_USER
Definition: hsdb.c:18
#define TAGID_ROOT
Definition: db.cpp:37
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define ERROR_NOT_FOUND
Definition: winerror.h:690
TAGID WINAPI SdbGetFirstChild(PDB pdb, TAGID parent)
Definition: sdbread.c:142
Definition: fs_rec.h:142
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
BOOL auto_loaded
Definition: apphelp.h:29
BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich)
Definition: hsdb.c:669
static LPCWSTR file_name
Definition: protocol.c:146
Definition: name.c:36
SDBQUERYRESULT Query
Definition: hsdb.c:26
PUCHAR Buffer
Definition: rtltypes.h:1807
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PDB pdb
Definition: apphelp.h:28
#define TAG_UPTO_LINK_DATE
Definition: apphelp.c:55
static PCWSTR wszLayers
Definition: layerapi.c:34
DWORD TAGID
struct _ShimData ShimData
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid)
Definition: sdbread.c:93
HSDB WINAPI SdbInitDatabase(DWORD flags, LPCWSTR path)
Definition: hsdb.c:369
#define HID_DATABASE_TYPE_MASK
Definition: apphelp.h:22
GLuint64EXT * result
Definition: glext.h:11304
#define REG_DWORD
Definition: sdbapi.c:596
static BOOL SdbpPropagateEnvLayers(HSDB hsdb, LPWSTR Environment, PSDBQUERYRESULT Result)
Definition: hsdb.c:341
static void SdbpAddExeLayers(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:247
#define SHIMREG_HAS_ENVIRONMENT
Definition: apphelp.h:56
static void SdbpAddExeMatch(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:282
#define CONST
Definition: pedump.c:81
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type)
Definition: sdbapi.c:329
GLuint const GLchar * name
Definition: glext.h:6031
#define SHIMDATA_MAGIC
Definition: hsdb.c:31