ReactOS 0.4.16-dev-122-g325d74c
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-2019 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 */
43typedef struct SDB_TMP_STR
44{
48
50{
51 String->Str.Buffer = String->FixedBuffer;
52 String->Str.Length = 0;
53 String->Str.MaximumLength = sizeof(String->FixedBuffer);
54}
55
57{
58 if (String->Str.Buffer != String->FixedBuffer)
59 {
60 SdbFree(String->Str.Buffer);
61 }
62}
63
65{
66 if (newLength > String->Str.MaximumLength)
67 {
69 String->Str.MaximumLength = newLength * sizeof(WCHAR);
70 String->Str.Buffer = SdbAlloc(String->Str.MaximumLength);
71 String->Str.Length = 0;
72 }
73}
74
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 {
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' */
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 */
164{
165 SdbpInitTempStr(LongPath);
166 if (!SdbpGetLongPathName(wszPath, LongPath))
167 {
168 SdbpFreeTempStr(LongPath);
169 return FALSE;
170 }
172 {
173 return SdbpBuildSignMediaId(LongPath);
174 }
175 return TRUE;
176}
177
178static 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 {
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 | Wow64QueryFlag(), &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
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 }
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
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 :) */
278 }
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])
300
301 if (NT_SUCCESS(Status))
302 {
303 if (end)
304 Status = StringCbCatNW(target, len, layer, (end - layer) * sizeof(WCHAR));
305 else
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
439 if (NT_SUCCESS(Status))
440 {
442 if (!NT_SUCCESS(Status))
443 {
444 SHIM_INFO("Failed to write a value to Key \"%wZ\" Status 0x%lx\n", &FullKey, Status);
447 }
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 }
480 {
481 SHIM_ERR("Invalid flags\n");
482 return FALSE;
483 }
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;
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}
PRTL_UNICODE_STRING_BUFFER Path
DWORD SdbpStrsize(PCWSTR string)
Definition: sdbapi.c:157
LONG NTSTATUS
Definition: precomp.h:26
#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 INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define wcsicmp
Definition: compat.h:15
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1456
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
unsigned short WORD
Definition: ntddk_ex.h:93
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLenum GLsizei len
Definition: glext.h:6722
GLenum target
Definition: glext.h:7315
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
@ ProcessWow64Information
Definition: winternl.h:396
BOOL WINAPI SdbSetPermLayerKeys(PCWSTR wszPath, PCWSTR wszLayers, BOOL bMachine)
Definition: layer.c:425
static ACCESS_MASK g_QueryFlag
Definition: layer.c:178
#define LAYER_UNK_FLAG2
Definition: layer.c:19
BOOL SdbpGetPermLayersInternal(PUNICODE_STRING FullPath, PWSTR pwszLayers, PDWORD pdwBytes, BOOL bMachine)
Definition: layer.c:230
struct SDB_TMP_STR * PSDB_TMP_STR
#define GPLK_USER
Definition: layer.c:15
void SdbpResizeTempStr(PSDB_TMP_STR String, WORD newLength)
Definition: layer.c:64
BOOL SdbpIsPathOnRemovableMedia(PCWSTR Path)
Definition: layer.c:97
#define LAYER_APPLY_TO_SYSTEM_EXES
Definition: layer.c:18
BOOL SdbpMatchLayer(PCWSTR start, PCWSTR end, PCWSTR compare)
Definition: layer.c:286
NTSTATUS SdbpOpenKey(PUNICODE_STRING FullPath, BOOL bMachine, ACCESS_MASK Access, PHANDLE KeyHandle)
Definition: layer.c:190
#define GPLK_MACHINE
Definition: layer.c:16
#define SIGN_MEDIA_FMT
Definition: layer.c:39
#define APPCOMPAT_LAYER_KEY
Definition: layer.c:34
#define REGISTRY_MACHINE
Definition: layer.c:35
void SdbpInitTempStr(PSDB_TMP_STR String)
Definition: layer.c:49
BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable)
Definition: layer.c:467
#define LAYER_SEPARATORS
Definition: layer.c:38
BOOL SdbpAppendLayer(PWSTR target, DWORD len, PCWSTR layer, PCWSTR end)
Definition: layer.c:295
BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
Definition: layer.c:124
BOOL WINAPI AllowPermLayer(PCWSTR Path)
Definition: layer.c:320
BOOL SdbDeletePermLayerKeys(PCWSTR wszPath, BOOL bMachine)
Definition: layer.c:258
void SdbpFreeTempStr(PSDB_TMP_STR String)
Definition: layer.c:56
#define MAX_LAYER_LENGTH
Definition: layer.c:17
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
#define REG_SZ
Definition: layer.c:22
BOOL SdbpGetLongPathName(PCWSTR wszPath, PSDB_TMP_STR Result)
Definition: layer.c:75
#define DISALLOWED_LAYER_CHARS
Definition: layer.c:37
#define SPACE_ONLY
Definition: layer.c:36
ACCESS_MASK Wow64QueryFlag(void)
Definition: layer.c:179
BOOL SdbpResolvePath(PSDB_TMP_STR LongPath, PCWSTR wszPath)
Definition: layer.c:163
static PCWSTR BOOL bMachine
Definition: layerapi.c:34
static PCWSTR wszLayer
Definition: layerapi.c:36
static PCWSTR wszLayers
Definition: layerapi.c:34
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
static PWSTR pwszLayers
Definition: layerapi.c:35
#define DRIVE_CDROM
Definition: machpc98.h:119
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI RtlFormatCurrentUserKeyPath(_Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length)) PUNICODE_STRING KeyPath)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
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
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
Definition: nt_native.h:1657
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)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define RTL_INIT_OBJECT_ATTRIBUTES(n, a)
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
DWORD * PDWORD
Definition: pedump.c:68
unsigned short USHORT
Definition: pedump.c:61
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_ERR(fmt,...)
Definition: sdbpapi.h:76
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
_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)
#define STATUS_SUCCESS
Definition: shellext.h:65
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
STRSAFEAPI StringCbCatNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToAppend)
Definition: strsafe.h:424
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
WCHAR FixedBuffer[MAX_PATH]
Definition: layer.c:46
UNICODE_STRING Str
Definition: layer.c:45
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bug.cpp:8
#define max(a, b)
Definition: svc.c:63
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DRIVE_REMOTE
Definition: winbase.h:253
#define DRIVE_REMOVABLE
Definition: winbase.h:251
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ BOOL bEnable
Definition: winddi.h:3426
#define WINAPI
Definition: msvc.h:6
_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
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180