ReactOS  0.4.11-dev-791-gf6f1255
layer.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Application compatibility module
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Registry layer manipulation functions
5  * COPYRIGHT: Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #define WIN32_NO_STATUS
9 #include "windef.h"
10 #include "winbase.h"
11 #include "strsafe.h"
12 #include <ntndk.h>
13 #include "apphelp.h"
14 
15 #define GPLK_USER 1
16 #define GPLK_MACHINE 2
17 #define MAX_LAYER_LENGTH 256
18 #define LAYER_APPLY_TO_SYSTEM_EXES 1
19 #define LAYER_UNK_FLAG2 2
20 
21 #ifndef REG_SZ
22 #define REG_SZ 1
23 #endif
24 
25 #if defined(__GNUC__)
26 #define APPCOMPAT_LAYER_KEY (const WCHAR[]){'\\','S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p','C','o','m','p','a','t','F','l','a','g','s','\\','L','a','y','e','r','s',0}
27 #define REGISTRY_MACHINE (const WCHAR[]){'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e',0}
28 #define SPACE_ONLY (const WCHAR[]){' ',0}
29 #define DISALLOWED_LAYER_CHARS (const WCHAR[]){' ','#','!',0}
30 #define LAYER_SEPARATORS (const WCHAR[]){' ','\t',0}
31 #define SIGN_MEDIA_FMT (const WCHAR[]){'S','I','G','N','.','M','E','D','I','A','=','%','X',' ','%','s',0}
32 
33 #else
34 #define APPCOMPAT_LAYER_KEY L"\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"
35 #define REGISTRY_MACHINE L"\\Registry\\Machine"
36 #define SPACE_ONLY L" "
37 #define DISALLOWED_LAYER_CHARS L" #!"
38 #define LAYER_SEPARATORS L" \t"
39 #define SIGN_MEDIA_FMT L"SIGN.MEDIA=%X %s"
40 #endif
41 
42 /* Fixme: use RTL_UNICODE_STRING_BUFFER */
43 typedef struct SDB_TMP_STR
44 {
48 
49 void SdbpInitTempStr(PSDB_TMP_STR String)
50 {
51  String->Str.Buffer = String->FixedBuffer;
52  String->Str.Length = 0;
53  String->Str.MaximumLength = sizeof(String->FixedBuffer);
54 }
55 
56 void SdbpFreeTempStr(PSDB_TMP_STR String)
57 {
58  if (String->Str.Buffer != String->FixedBuffer)
59  {
60  SdbFree(String->Str.Buffer);
61  }
62 }
63 
64 void SdbpResizeTempStr(PSDB_TMP_STR String, WORD newLength)
65 {
66  if (newLength > String->Str.MaximumLength)
67  {
68  SdbpFreeTempStr(String);
69  String->Str.MaximumLength = newLength * sizeof(WCHAR);
70  String->Str.Buffer = SdbAlloc(String->Str.MaximumLength);
71  String->Str.Length = 0;
72  }
73 }
74 
75 BOOL SdbpGetLongPathName(PCWSTR wszPath, PSDB_TMP_STR Result)
76 {
77  DWORD max = Result->Str.MaximumLength / 2;
78  DWORD ret = GetLongPathNameW(wszPath, Result->Str.Buffer, max);
79  if (ret)
80  {
81  if (ret >= max)
82  {
83  SdbpResizeTempStr(Result, ret);
84  max = Result->Str.MaximumLength / 2;
85  ret = GetLongPathNameW(wszPath, Result->Str.Buffer, max);
86  }
87  if (ret && ret < max)
88  {
89  Result->Str.Length = ret * 2;
90  return TRUE;
91  }
92  }
93  SHIM_ERR("Failed to convert short path to long path error 0x%lx\n", GetLastError());
94  return FALSE;
95 }
96 
98 {
99  WCHAR tmp[] = { 'A',':','\\',0 };
100  ULONG type;
101  if (!Path || Path[0] == UNICODE_NULL)
102  {
103  SHIM_ERR("Invalid argument\n");
104  return FALSE;
105  }
106  switch (Path[1])
107  {
108  case L':':
109  break;
110  case L'\\':
111  SHIM_INFO("\"%S\" is a network path.\n", Path);
112  return FALSE;
113  default:
114  SHIM_INFO("\"%S\" not a full path we can operate on.\n", Path);
115  return FALSE;
116  }
117  tmp[0] = Path[0];
118  type = GetDriveTypeW(tmp);
119 
120  return type == DRIVE_REMOVABLE || type == DRIVE_CDROM;
121 }
122 
123 /* Convert a path on removable media to 'SIGN.MEDIA=%X filename' */
124 BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
125 {
126  SDB_TMP_STR Scratch;
127  PWCHAR Ptr;
128 
129  SdbpInitTempStr(&Scratch);
130  SdbpResizeTempStr(&Scratch, LongPath->Str.Length / sizeof(WCHAR) + 30);
131  StringCbCopyNW(Scratch.Str.Buffer, Scratch.Str.MaximumLength, LongPath->Str.Buffer, LongPath->Str.Length);
132  Ptr = wcsrchr(LongPath->Str.Buffer, '\\');
133  if (Ptr)
134  {
135  HANDLE FindHandle;
136  WIN32_FIND_DATAW FindData;
137  Ptr[1] = '*';
138  Ptr[2] = '\0';
139  FindHandle = FindFirstFileW(LongPath->Str.Buffer, &FindData);
140  if (FindHandle != INVALID_HANDLE_VALUE)
141  {
142  DWORD SignMedia = 0;
143  do
144  {
145  if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && FindData.nFileSizeLow)
146  SignMedia = SignMedia << 1 ^ FindData.nFileSizeLow;
147  } while (FindNextFileW(FindHandle, &FindData));
148 
149  FindClose(FindHandle);
150  SdbpResizeTempStr(LongPath, (LongPath->Str.Length >> 1) + 20);
151  StringCbPrintfW(LongPath->Str.Buffer, LongPath->Str.MaximumLength, SIGN_MEDIA_FMT, SignMedia, Scratch.Str.Buffer + 3);
152  LongPath->Str.Length = (USHORT)SdbpStrlen(LongPath->Str.Buffer) * sizeof(WCHAR);
153  SdbpFreeTempStr(&Scratch);
154  return TRUE;
155  }
156  }
157  SdbpFreeTempStr(&Scratch);
158  SdbpFreeTempStr(LongPath);
159  return FALSE;
160 }
161 
162 /* Convert a given path to a long or media path */
163 BOOL SdbpResolvePath(PSDB_TMP_STR LongPath, PCWSTR wszPath)
164 {
165  SdbpInitTempStr(LongPath);
166  if (!SdbpGetLongPathName(wszPath, LongPath))
167  {
168  SdbpFreeTempStr(LongPath);
169  return FALSE;
170  }
171  if (SdbpIsPathOnRemovableMedia(LongPath->Str.Buffer))
172  {
173  return SdbpBuildSignMediaId(LongPath);
174  }
175  return TRUE;
176 }
177 
178 static ACCESS_MASK g_QueryFlag = 0xffffffff;
180 {
181  if (g_QueryFlag == 0xffffffff)
182  {
183  ULONG_PTR wow64_ptr = 0;
185  g_QueryFlag = (NT_SUCCESS(Status) && wow64_ptr != 0) ? KEY_WOW64_64KEY : 0;
186  }
187  return g_QueryFlag;
188 }
189 
191 {
192  UNICODE_STRING BasePath;
193  const WCHAR* LayersKey = APPCOMPAT_LAYER_KEY;
196  FullPath->Buffer = NULL;
197  FullPath->Length = FullPath->MaximumLength = 0;
198  if (bMachine)
199  {
201  }
202  else
203  {
204  Status = RtlFormatCurrentUserKeyPath(&BasePath);
205  if (!NT_SUCCESS(Status))
206  {
207  SHIM_ERR("Unable to acquire user registry key, Error: 0x%lx\n", Status);
208  return Status;
209  }
210  }
211  FullPath->MaximumLength = (USHORT)(BasePath.Length + SdbpStrsize(LayersKey));
212  FullPath->Buffer = SdbAlloc(FullPath->MaximumLength);
213  FullPath->Length = 0;
214  RtlAppendUnicodeStringToString(FullPath, &BasePath);
215  if (!bMachine)
216  RtlFreeUnicodeString(&BasePath);
217  RtlAppendUnicodeToString(FullPath, LayersKey);
218 
219  Status = NtOpenKey(KeyHandle, Access | QueryFlag(), &ObjectLayer);
220  if (!NT_SUCCESS(Status))
221  {
222  SHIM_ERR("Unable to open Key \"%wZ\" Status 0x%lx\n", FullPath, Status);
223  SdbFree(FullPath->Buffer);
224  FullPath->Buffer = NULL;
225  }
226  return Status;
227 }
228 
229 
231 {
232  UNICODE_STRING FullKey;
233  ULONG ValueBuffer[(MAX_LAYER_LENGTH * sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG) - 1) / sizeof(ULONG)];
234  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
235  ULONG Length = 0;
238 
239  Status = SdbpOpenKey(&FullKey, bMachine, KEY_QUERY_VALUE, &KeyHandle);
240  if (NT_SUCCESS(Status))
241  {
242  Status = NtQueryValueKey(KeyHandle, FullPath, KeyValuePartialInformation, PartialInfo, sizeof(ValueBuffer), &Length);
243  if (NT_SUCCESS(Status))
244  {
245  StringCbCopyNW(pwszLayers, *pdwBytes, (PCWSTR)PartialInfo->Data, PartialInfo->DataLength);
246  *pdwBytes = PartialInfo->DataLength;
247  }
248  else
249  {
250  SHIM_INFO("Failed to read value info from Key \"%wZ\" Status 0x%lx\n", &FullKey, Status);
251  }
252  NtClose(KeyHandle);
253  SdbFree(FullKey.Buffer);
254  }
255  return NT_SUCCESS(Status);
256 }
257 
259 {
260  UNICODE_STRING FullKey;
261  SDB_TMP_STR LongPath;
264 
265  if (!SdbpResolvePath(&LongPath, wszPath))
266  return FALSE;
267 
268  Status = SdbpOpenKey(&FullKey, bMachine, KEY_SET_VALUE, &KeyHandle);
269  if (NT_SUCCESS(Status))
270  {
271  Status = NtDeleteValueKey(KeyHandle, &LongPath.Str);
272  if (!NT_SUCCESS(Status))
273  {
274  SHIM_INFO("Failed to delete value from Key \"%wZ\" Status 0x%lx\n", &FullKey, Status);
275  /* This is what we want, so if the key didnt exist, we should not fail :) */
276  if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
277  Status = STATUS_SUCCESS;
278  }
279  NtClose(KeyHandle);
280  SdbFree(FullKey.Buffer);
281  }
282  SdbpFreeTempStr(&LongPath);
283  return NT_SUCCESS(Status);
284 }
285 
287 {
288  size_t len;
289  if (!end)
290  return !wcsicmp(start, compare);
291  len = end - start;
292  return wcslen(compare) == len && !_wcsnicmp(start, compare, len);
293 }
294 
296 {
298  if (target[0])
299  Status = StringCbCatW(target, len, SPACE_ONLY);
300 
301  if (NT_SUCCESS(Status))
302  {
303  if (end)
304  Status = StringCbCatNW(target, len, layer, (end - layer) * sizeof(WCHAR));
305  else
306  Status = StringCbCatW(target, len, layer);
307  }
308 
309  return NT_SUCCESS(Status);
310 }
311 
312 
321 {
322  WCHAR tmp[] = { 'A',':','\\', 0 };
323  ULONG type;
324  if (!Path)
325  {
326  SHIM_ERR("Invalid argument\n");
327  return FALSE;
328  }
329  switch (Path[1])
330  {
331  case L':':
332  break;
333  case L'\\':
334  SHIM_INFO("\"%S\" is a network path.\n", Path);
335  return FALSE;
336  default:
337  SHIM_INFO("\"%S\" not a full path we can operate on.\n", Path);
338  return FALSE;
339  }
340  tmp[0] = Path[0];
341  type = GetDriveTypeW(tmp);
342  if (type == DRIVE_REMOTE)
343  {
344  /* The logging here indicates that it does not like a CDROM or removable media, but it only
345  seems to bail out on a media that reports it is remote...
346  I have included correct logging, I doubt anyone would parse the logging, so this shouldnt break anything. */
347  SHIM_INFO("\"%S\" is on a remote drive.\n", Path);
348  return FALSE;
349  }
350  return TRUE;
351 }
352 
365 {
366  BOOL Result = FALSE;
367  SDB_TMP_STR LongPath;
368  DWORD dwBytes, dwTotal = 0;
369  if (!wszPath || !pdwBytes)
370  {
371  SHIM_ERR("NULL parameter passed for wszPath or pdwBytes.\n");
372  return FALSE;
373  }
374 
375  if (!SdbpResolvePath(&LongPath, wszPath))
376  return FALSE;
377  dwBytes = *pdwBytes;
378  if (dwFlags & GPLK_MACHINE)
379  {
380  if (SdbpGetPermLayersInternal(&LongPath.Str, pwszLayers, &dwBytes, TRUE))
381  {
382  Result = TRUE;
383  dwTotal = dwBytes - sizeof(WCHAR); /* Compensate for the nullterm. */
384  pwszLayers += dwTotal / sizeof(WCHAR);
385  dwBytes = *pdwBytes - dwBytes;
386  if (dwFlags & GPLK_USER)
387  {
388  *(pwszLayers++) = L' ';
389  *pwszLayers = L'\0';
390  dwBytes -= sizeof(WCHAR);
391  dwTotal += sizeof(WCHAR);
392  }
393  }
394  }
395  if (dwFlags & GPLK_USER)
396  {
397  if (SdbpGetPermLayersInternal(&LongPath.Str, pwszLayers, &dwBytes, FALSE))
398  {
399  Result = TRUE;
400  dwTotal += dwBytes - sizeof(WCHAR); /* Compensate for the nullterm. */
401  }
402  else if (dwTotal > 0 && pwszLayers[-1] == L' ')
403  {
404  pwszLayers[-1] = '\0';
405  dwTotal -= sizeof(WCHAR);
406  }
407  }
408  if (dwTotal)
409  dwTotal += sizeof(WCHAR);
410  *pdwBytes = dwTotal;
411  SdbpFreeTempStr(&LongPath);
412  return Result;
413 }
414 
426 {
427  UNICODE_STRING FullKey;
428  SDB_TMP_STR LongPath;
431 
432  if (!wszLayers || *wszLayers == '\0')
433  return SdbDeletePermLayerKeys(wszPath, bMachine);
434 
435  if (!SdbpResolvePath(&LongPath, wszPath))
436  return FALSE;
437 
438  Status = SdbpOpenKey(&FullKey, bMachine, KEY_SET_VALUE, &KeyHandle);
439  if (NT_SUCCESS(Status))
440  {
441  Status = NtSetValueKey(KeyHandle, &LongPath.Str, 0, REG_SZ, (PVOID)wszLayers, SdbpStrsize(wszLayers));
442  if (!NT_SUCCESS(Status))
443  {
444  SHIM_INFO("Failed to write a value to Key \"%wZ\" Status 0x%lx\n", &FullKey, Status);
445  if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
446  Status = STATUS_SUCCESS;
447  }
448  NtClose(KeyHandle);
449  SdbFree(FullKey.Buffer);
450  }
451  SdbpFreeTempStr(&LongPath);
452  return NT_SUCCESS(Status);
453 }
454 
468 {
469  WCHAR fullLayer[MAX_LAYER_LENGTH] = { 0 };
470  WCHAR newLayer[MAX_LAYER_LENGTH] = { 0 };
471  DWORD dwBytes = sizeof(fullLayer), dwWriteFlags = 0;
472  PWSTR start, p;
473 
474  if (!wszLayer)
475  {
476  SHIM_ERR("Invalid argument\n");
477  return FALSE;
478  }
479  if (dwFlags & ~(LAYER_APPLY_TO_SYSTEM_EXES | LAYER_UNK_FLAG2))
480  {
481  SHIM_ERR("Invalid flags\n");
482  return FALSE;
483  }
484  p = wcspbrk(wszLayer, DISALLOWED_LAYER_CHARS);
485  if (p)
486  {
487  switch (*p)
488  {
489  case ' ':
490  SHIM_ERR("Only one layer can be passed in at a time.\n");
491  return FALSE;
492  case '#':
493  case '!':
494  SHIM_ERR("Flags cannot be passed in with the layer name.\n");
495  return FALSE;
496  }
497  }
498  if (!SdbGetPermLayerKeys(wszPath, fullLayer, &dwBytes, bMachine ? GPLK_MACHINE : GPLK_USER))
499  {
500  fullLayer[0] = '\0';
501  dwBytes = sizeof(fullLayer);
502  }
503 
504  start = fullLayer;
505  while (*start == '!' || *start == '#' || *start == ' ' || *start == '\t')
506  {
507  if (*start == '#')
508  dwWriteFlags |= LAYER_APPLY_TO_SYSTEM_EXES;
509  else if (*start == '!')
510  dwWriteFlags |= LAYER_UNK_FLAG2;
511  start++;
512  }
513  if (bEnable)
514  dwWriteFlags |= dwFlags;
515  else
516  dwWriteFlags &= ~dwFlags;
517 
518  p = newLayer;
519  if (dwWriteFlags & LAYER_UNK_FLAG2)
520  *(p++) = '!';
521  if (dwWriteFlags & LAYER_APPLY_TO_SYSTEM_EXES)
522  *(p++) = '#';
523 
524  do
525  {
526  while (*start == ' ' || *start == '\t')
527  ++start;
528 
529  if (*start == '\0')
530  break;
531  p = wcspbrk(start, LAYER_SEPARATORS);
532  if (!SdbpMatchLayer(start, p, wszLayer))
533  {
534  SdbpAppendLayer(newLayer, sizeof(newLayer), start, p);
535  }
536  start = p + 1;
537  } while (p);
538 
539  if (bEnable && wszLayer[0])
540  {
541  SdbpAppendLayer(newLayer, sizeof(newLayer), wszLayer, NULL);
542  }
543 
544  return SdbSetPermLayerKeys(wszPath, newLayer, bMachine);
545 }
DWORD *typedef PVOID
Definition: winlogon.h:61
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
Definition: bug.cpp:7
BOOL SdbDeletePermLayerKeys(PCWSTR wszPath, BOOL bMachine)
Definition: layer.c:258
#define REGISTRY_MACHINE
Definition: layer.c:35
#define LAYER_UNK_FLAG2
Definition: layer.c:19
#define max(a, b)
Definition: svc.c:63
unsigned short WORD
Definition: ntddk_ex.h:93
#define TRUE
Definition: types.h:120
#define RTL_INIT_OBJECT_ATTRIBUTES(n, a)
#define GPLK_USER
Definition: layer.c:15
#define KEY_SET_VALUE
Definition: nt_native.h:1017
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4693
USHORT MaximumLength
Definition: env_spec_w32.h:370
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
#define APPCOMPAT_LAYER_KEY
Definition: layer.c:34
#define GPLK_MACHINE
Definition: layer.c:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
static ACCESS_MASK g_QueryFlag
Definition: layer.c:178
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define SPACE_ONLY
Definition: layer.c:36
void SdbpFreeTempStr(PSDB_TMP_STR String)
Definition: layer.c:56
NTSTATUS NTAPI NtQueryInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:59
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
PVOID *typedef PWSTR
Definition: winlogon.h:66
ACCESS_MASK QueryFlag(void)
Definition: layer.c:179
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WCHAR FixedBuffer[MAX_PATH]
Definition: layer.c:46
STRSAFEAPI StringCbCatNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToAppend)
Definition: strsafe.h:424
GLuint GLuint end
Definition: gl.h:1545
_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
BOOL SdbpAppendLayer(PWSTR target, DWORD len, PCWSTR layer, PCWSTR end)
Definition: layer.c:295
uint16_t * PWCHAR
Definition: typedefs.h:54
#define WCHAR
Definition: msvc.h:43
DWORD SdbpStrsize(PCWSTR string)
Definition: sdbapi.c:157
#define SdbFree(mem)
Definition: sdbpapi.h:37
DWORD DWORD
Definition: winlogon.h:84
NTSTATUS SdbpOpenKey(PUNICODE_STRING FullPath, BOOL bMachine, ACCESS_MASK Access, PHANDLE KeyHandle)
Definition: layer.c:190
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define DISALLOWED_LAYER_CHARS
Definition: layer.c:37
#define DRIVE_REMOVABLE
Definition: winbase.h:248
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define SdbAlloc(size)
Definition: sdbpapi.h:35
void SdbpResizeTempStr(PSDB_TMP_STR String, WORD newLength)
Definition: layer.c:64
CHAR16 * String
Definition: acefiex.h:201
#define DRIVE_REMOTE
Definition: winbase.h:250
static PCWSTR wszLayer
Definition: layerapi.c:35
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
static PWSTR pwszLayers
Definition: layerapi.c:34
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
#define SIGN_MEDIA_FMT
Definition: layer.c:39
BOOL SdbpGetLongPathName(PCWSTR wszPath, PSDB_TMP_STR Result)
Definition: layer.c:75
UNICODE_STRING Str
Definition: layer.c:45
BOOL SdbpResolvePath(PSDB_TMP_STR LongPath, PCWSTR wszPath)
Definition: layer.c:163
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:994
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable)
Definition: layer.c:467
BOOL SdbpMatchLayer(PCWSTR start, PCWSTR end, PCWSTR compare)
Definition: layer.c:286
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1455
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI RtlFormatCurrentUserKeyPath(_Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length)) PUNICODE_STRING KeyPath)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
void SdbpInitTempStr(PSDB_TMP_STR String)
Definition: layer.c:49
BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
Definition: layer.c:124
#define MAX_PATH
Definition: compat.h:26
struct SDB_TMP_STR SDB_TMP_STR
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:34
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3393
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
int ret
static const WCHAR L[]
Definition: oid.c:1087
VOID UINTN Length
Definition: acefiex.h:744
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define LAYER_APPLY_TO_SYSTEM_EXES
Definition: layer.c:18
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI SdbSetPermLayerKeys(PCWSTR wszPath, PCWSTR wszLayers, BOOL bMachine)
Definition: layer.c:425
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define WINAPI
Definition: msvc.h:20
#define wcsicmp
Definition: string.h:1152
Status
Definition: gdiplustypes.h:24
struct SDB_TMP_STR * PSDB_TMP_STR
DWORD SdbpStrlen(PCWSTR string)
Definition: sdbapi.c:152
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
BOOL SdbpGetPermLayersInternal(PUNICODE_STRING FullPath, PWSTR pwszLayers, PDWORD pdwBytes, BOOL bMachine)
Definition: layer.c:230
DWORD *typedef HANDLE
Definition: winlogon.h:61
PRTL_UNICODE_STRING_BUFFER Path
_In_ BOOL bEnable
Definition: winddi.h:3426
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
unsigned short USHORT
Definition: pedump.c:61
GLuint start
Definition: gl.h:1545
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
#define DRIVE_CDROM
Definition: winbase.h:251
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
DWORD * PDWORD
Definition: pedump.c:68
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
const uint16_t * PCWSTR
Definition: typedefs.h:55
static PCWSTR wszLayers
Definition: layerapi.c:33
GLfloat GLfloat p
Definition: glext.h:8902
return STATUS_SUCCESS
Definition: btrfs.c:2710
#define MAX_LAYER_LENGTH
Definition: layer.c:17
BOOL SdbpIsPathOnRemovableMedia(PCWSTR Path)
Definition: layer.c:97
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PCWSTR BOOL bMachine
Definition: layerapi.c:33
ULONG ACCESS_MASK
Definition: nt_native.h:40
BOOL WINAPI AllowPermLayer(PCWSTR Path)
Definition: layer.c:320
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define LAYER_SEPARATORS
Definition: layer.c:38