17#define MAX_LAYER_LENGTH 256
18#define LAYER_APPLY_TO_SYSTEM_EXES 1
19#define LAYER_UNK_FLAG2 2
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}
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"
66 if (newLength >
String->Str.MaximumLength)
69 String->Str.MaximumLength = newLength *
sizeof(
WCHAR);
99 WCHAR tmp[] = {
'A',
':',
'\\',0 };
114 SHIM_INFO(
"\"%S\" not a full path we can operate on.\n",
Path);
146 SignMedia = SignMedia << 1 ^ FindData.nFileSizeLow;
207 SHIM_ERR(
"Unable to acquire user registry key, Error: 0x%lx\n",
Status);
222 SHIM_ERR(
"Unable to open Key \"%wZ\" Status 0x%lx\n", FullPath,
Status);
246 *
pdwBytes = PartialInfo->DataLength;
250 SHIM_INFO(
"Failed to read value info from Key \"%wZ\" Status 0x%lx\n", &FullKey,
Status);
274 SHIM_INFO(
"Failed to delete value from Key \"%wZ\" Status 0x%lx\n", &FullKey,
Status);
322 WCHAR tmp[] = {
'A',
':',
'\\', 0 };
337 SHIM_INFO(
"\"%S\" not a full path we can operate on.\n",
Path);
368 DWORD dwBytes, dwTotal = 0;
371 SHIM_ERR(
"NULL parameter passed for wszPath or pdwBytes.\n");
383 dwTotal = dwBytes -
sizeof(
WCHAR);
390 dwBytes -=
sizeof(
WCHAR);
391 dwTotal +=
sizeof(
WCHAR);
400 dwTotal += dwBytes -
sizeof(
WCHAR);
405 dwTotal -=
sizeof(
WCHAR);
409 dwTotal +=
sizeof(
WCHAR);
444 SHIM_INFO(
"Failed to write a value to Key \"%wZ\" Status 0x%lx\n", &FullKey,
Status);
471 DWORD dwBytes =
sizeof(fullLayer), dwWriteFlags = 0;
490 SHIM_ERR(
"Only one layer can be passed in at a time.\n");
494 SHIM_ERR(
"Flags cannot be passed in with the layer name.\n");
501 dwBytes =
sizeof(fullLayer);
509 else if (*
start ==
'!')
PRTL_UNICODE_STRING_BUFFER Path
DWORD SdbpStrsize(PCWSTR string)
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
BOOL WINAPI FindClose(HANDLE hFindFile)
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
GLuint GLuint GLsizei GLenum type
GLenum GLuint GLint GLint layer
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
@ ProcessWow64Information
BOOL WINAPI SdbSetPermLayerKeys(PCWSTR wszPath, PCWSTR wszLayers, BOOL bMachine)
static ACCESS_MASK g_QueryFlag
BOOL SdbpGetPermLayersInternal(PUNICODE_STRING FullPath, PWSTR pwszLayers, PDWORD pdwBytes, BOOL bMachine)
struct SDB_TMP_STR * PSDB_TMP_STR
void SdbpResizeTempStr(PSDB_TMP_STR String, WORD newLength)
BOOL SdbpIsPathOnRemovableMedia(PCWSTR Path)
#define LAYER_APPLY_TO_SYSTEM_EXES
BOOL SdbpMatchLayer(PCWSTR start, PCWSTR end, PCWSTR compare)
NTSTATUS SdbpOpenKey(PUNICODE_STRING FullPath, BOOL bMachine, ACCESS_MASK Access, PHANDLE KeyHandle)
#define APPCOMPAT_LAYER_KEY
void SdbpInitTempStr(PSDB_TMP_STR String)
BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable)
BOOL SdbpAppendLayer(PWSTR target, DWORD len, PCWSTR layer, PCWSTR end)
BOOL SdbpBuildSignMediaId(PSDB_TMP_STR LongPath)
BOOL WINAPI AllowPermLayer(PCWSTR Path)
BOOL SdbDeletePermLayerKeys(PCWSTR wszPath, BOOL bMachine)
void SdbpFreeTempStr(PSDB_TMP_STR String)
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
BOOL SdbpGetLongPathName(PCWSTR wszPath, PSDB_TMP_STR Result)
#define DISALLOWED_LAYER_CHARS
ACCESS_MASK Wow64QueryFlag(void)
BOOL SdbpResolvePath(PSDB_TMP_STR LongPath, PCWSTR wszPath)
static PCWSTR BOOL bMachine
static PWSTR PDWORD pdwBytes
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
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)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
@ KeyValuePartialInformation
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
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)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FILE_ATTRIBUTE_DIRECTORY
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#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)
DWORD SdbpStrlen(PCWSTR string)
#define SHIM_INFO(fmt,...)
#define SHIM_ERR(fmt,...)
_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)
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
STRSAFEAPI StringCbCatNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToAppend)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
WCHAR FixedBuffer[MAX_PATH]
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
DWORD WINAPI GetLastError(void)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
_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