25 ULONG total_size =
sizeof(kvi);
30 &kvi, total_size, &total_size);
48 ERR(
"NtQueryKey returned unexpected Status: 0x%08x\n",
Status);
54 if (NameInformation ==
NULL)
56 ERR(
"Failed to allocate %lu bytes\n", InfoLength);
63 RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation);
64 ERR(
"NtQueryKey failed: 0x%08x\n",
Status);
76 RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation);
77 ERR(
"RtlDuplicateUnicodeString failed: 0x%08x\n",
Status);
81 RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation);
98 ERR(
"NtQueryObject failed, Status %x08x\n",
Status);
143 ERR(
"Key name %S is invalid!\n",
KeyName.Buffer);
202 *PreferredKey =
hKey;
210 *PreferredKey =
hKey;
222 *PreferredKey =
hKey;
278 HKEY QueriedKey, TestKey;
297 lpSecurityAttributes,
326 lpSecurityAttributes,
332 if (QueriedKey !=
hKey)
338 if (QueriedKey !=
hKey)
354 lpSecurityAttributes,
358 if (QueriedKey !=
hKey)
408 if (QueriedKey !=
hKey)
430 if (QueriedKey !=
hKey)
472 if (QueriedKey !=
hKey)
493 if (QueriedKey !=
hKey)
521 if (hActualKey !=
hKey)
538 if (hActualKey !=
hKey)
581 if (QueriedKey !=
hKey)
602 if (QueriedKey !=
hKey)
652 if (QueriedKey !=
hKey)
656 if (QueriedKey !=
hKey)
673 if (QueriedKey !=
hKey)
692 HKEY PreferredKey, FallbackKey;
693 DWORD NumPreferredSubKeys;
694 DWORD MaxFallbackSubKeyLen;
728 if (PreferredKey !=
hKey)
751 if (dwIndex < NumPreferredSubKeys)
770 dwIndex -= NumPreferredSubKeys;
776 ERR(
"Could not query info of key %p (Err: %d)\n", FallbackKey,
ErrorCode);
780 MaxFallbackSubKeyLen++;
781 TRACE(
"Maxfallbacksubkeylen: %d\n", MaxFallbackSubKeyLen);
785 RtlGetProcessHeap(), 0, MaxFallbackSubKeyLen *
sizeof(
WCHAR));
786 if (!FallbackSubKeyName)
800 HKEY PreferredSubKey;
801 DWORD FallbackSubkeyLen = MaxFallbackSubKeyLen;
819 FallbackSubKeyName[FallbackSubkeyLen] =
L'\0';
837 ERR(
"Got error %d while querying for %s on HKCU side.\n",
ErrorCode, FallbackSubKeyName);
842 if (FallbackIndex == dwIndex)
860 if (PreferredKey !=
hKey)
862 if (FallbackKey !=
hKey)
864 if (FallbackSubKeyName)
865 RtlFreeHeap(RtlGetProcessHeap(), 0, FallbackSubKeyName);
883 HKEY PreferredKey, FallbackKey;
884 DWORD NumPreferredValues;
885 DWORD MaxFallbackValueNameLen;
919 if (PreferredKey !=
hKey)
954 if (dwIndex < NumPreferredValues)
973 dwIndex -= NumPreferredValues;
985 &MaxFallbackValueNameLen,
991 ERR(
"Could not query info of key %p (Err: %d)\n", FallbackKey,
ErrorCode);
995 MaxFallbackValueNameLen++;
996 TRACE(
"Maxfallbacksubkeylen: %d\n", MaxFallbackValueNameLen);
1000 RtlGetProcessHeap(), 0, MaxFallbackValueNameLen *
sizeof(
WCHAR));
1001 if (!FallbackValueName)
1015 DWORD FallbackValueNameLen = MaxFallbackValueNameLen;
1022 &FallbackValueNameLen,
1033 FallbackValueName[FallbackValueNameLen] =
L'\0';
1051 ERR(
"Got error %d while querying for %s on HKCU side.\n",
ErrorCode, FallbackValueName);
1056 if (FallbackIndex == dwIndex)
1074 if (PreferredKey !=
hKey)
1076 if (FallbackKey !=
hKey)
1078 if (FallbackValueName)
1079 RtlFreeHeap(RtlGetProcessHeap(), 0, FallbackValueName);
1101 HKEY PreferredKey, FallbackKey;
1103 DWORD OtherSubKeys = 0, OtherMaxSub = 0, OtherMaxClass = 0;
1104 DWORD OtherValues = 0, OtherMaxName = 0, OtherMaxVal = 0;
1115 &OtherSubKeys, &OtherMaxSub, &OtherMaxClass,
1116 &OtherValues, &OtherMaxName, &OtherMaxVal,
1117 lpcbSecurityDescriptor, lpftLastWriteTime);
1118 if (FallbackKey !=
hKey)
1126 lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen,
1127 lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen,
1128 lpcbSecurityDescriptor, lpftLastWriteTime);
1129 if (PreferredKey !=
hKey)
1134 *lpcSubKeys = (
err ? 0 : *lpcSubKeys) + OtherSubKeys;
1136 *lpcValues = (
err ? 0 : *lpcValues) + OtherValues;
1137 if (lpcbMaxSubKeyLen)
1138 *lpcbMaxSubKeyLen =
max((
err ? 0 : *lpcbMaxSubKeyLen), OtherMaxSub);
1139 if (lpcbMaxClassLen)
1140 *lpcbMaxClassLen =
max((
err ? 0 : *lpcbMaxClassLen), OtherMaxClass);
1141 if (lpcbMaxValueNameLen)
1142 *lpcbMaxValueNameLen =
max((
err ? 0 : *lpcbMaxValueNameLen), OtherMaxName);
1143 if (lpcbMaxValueLen)
1144 *lpcbMaxValueLen =
max((
err ? 0 : *lpcbMaxValueLen), OtherMaxVal);
NTSTATUS NtQueryObject(IN HANDLE Handle, IN OBJECT_INFO_CLASS ObjectInformationClass, OUT PVOID ObjectInformation, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define RegCloseKey(hKey)
#define ERROR_NOT_ENOUGH_MEMORY
#define NT_SUCCESS(StatCode)
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI RegDeleteKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
FORCEINLINE BOOL IsHKCRKey(_In_ HKEY hKey)
FORCEINLINE void MakeHKCRKey(_Inout_ HKEY *hKey)
#define ERROR_NO_MORE_ITEMS
#define ERROR_ACCESS_DENIED
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
LONG WINAPI QueryInfoHKCRKey(_In_ HKEY hKey, _Out_writes_to_opt_(*lpcchClass, *lpcchClass+1) LPWSTR lpClass, _Inout_opt_ LPDWORD lpcchClass, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPDWORD lpcSubKeys, _Out_opt_ LPDWORD lpcbMaxSubKeyLen, _Out_opt_ LPDWORD lpcbMaxClassLen, _Out_opt_ LPDWORD lpcValues, _Out_opt_ LPDWORD lpcbMaxValueNameLen, _Out_opt_ LPDWORD lpcbMaxValueLen, _Out_opt_ LPDWORD lpcbSecurityDescriptor, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI CreateHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
static BOOL ValueExists(_In_ HKEY hNormalKey, _In_ PUNICODE_STRING Name)
static LONG GetFallbackHKCRKey(_In_ HKEY hKey, _Out_ HKEY *MachineKey, _In_ BOOL MustCreate)
LONG WINAPI QueryHKCRValue(_In_ HKEY hKey, _In_ LPCWSTR Name, _In_ LPDWORD Reserved, _In_ LPDWORD Type, _In_ LPBYTE Data, _In_ LPDWORD Count)
LONG WINAPI EnumHKCRValue(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ PDWORD lpcbName, _Reserved_ PDWORD lpReserved, _Out_opt_ PDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ PDWORD lpcbData)
LONG WINAPI DeleteHKCRValue(_In_ HKEY hKey, _In_ PUNICODE_STRING ValueName)
static LONG GetKeySam(_In_ HKEY hKey, _Out_ REGSAM *RegSam)
LONG WINAPI SetHKCRValue(_In_ HKEY hKey, _In_ LPCWSTR Name, _In_ DWORD Reserved, _In_ DWORD Type, _In_ CONST BYTE *Data, _In_ DWORD DataSize)
static const UNICODE_STRING HKLM_ClassesPath
LONG WINAPI OpenHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _In_ PHKEY phkResult)
static LONG GetSubkeyInfoHelper(_In_ HKEY hKey, _Out_opt_ LPDWORD lpSubKeys, _Out_opt_ LPDWORD lpMaxSubKeyLen)
static LONG GetPreferredHKCRKey(_In_ HKEY hKey, _Out_ HKEY *PreferredKey)
LONG WINAPI DeleteHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM RegSam, _In_ DWORD Reserved)
static LONG GetKeyName(HKEY hKey, PUNICODE_STRING KeyName)
LONG WINAPI EnumHKCRKey(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define ERROR_FILE_NOT_FOUND
#define _Out_writes_to_opt_(size, count)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
_In_ NDIS_ERROR_CODE ErrorCode
@ KeyValuePartialInformation
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
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)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
NTSTATUS NTAPI NtQueryKey(IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, IN ULONG Length, OUT PULONG ResultLength)
#define STATUS_BUFFER_TOO_SMALL
#define RTL_CONSTANT_STRING(s)
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Reserved_ PVOID Reserved
#define ERROR_INTERNAL_ERROR
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_USER