27#define MAX_DEFAULT_HANDLES 6
28#define REG_MAX_NAME_SIZE 256
29#define REG_MAX_DATA_SIZE 2048
44#define ClosePredefKey(Handle) \
45 if ((ULONG_PTR)Handle & 0x1) { \
48#define IsPredefKey(HKey) \
49 (((ULONG_PTR)(HKey) & 0xF0000000) == 0x80000000)
50#define GetPredefKeyIndex(HKey) \
51 ((ULONG_PTR)(HKey) & 0x0FFFFFFF)
72 TRACE(
"RegInitialize()\n");
95 TRACE(
"RegCleanup()\n");
143 WARN(
"MapDefaultHandle() no handle creator\n");
161 TRACE(
"MapDefaultKey (Key %x)\n",
Key);
242 TRACE(
"OpenClassesRootKey()\n");
270 TRACE(
"OpenLocalMachineKey()\n");
293 TRACE(
"OpenUsersKey()\n");
311 RTL_CONSTANT_STRING(
L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current");
313 TRACE(
"OpenCurrentConfigKey()\n");
384 if (hNewHKey ==
NULL)
457 } REGP_COPY_KEYS, *PREGP_COPY_KEYS;
460 PREGP_COPY_KEYS copyKeys, newCopyKeys;
483 sizeof(REGP_COPY_KEYS));
484 if (copyKeys !=
NULL)
486 copyKeys->hKeySrc = hKeySrc;
487 copyKeys->hKeyDest = hKeyDest;
489 ©Keys->ListEntry);
508 &BufferSizeRequired);
523 Info.KeyValue->TitleIndex,
526 Info.KeyValue->DataLength);
585 &BufferSizeRequired);
624 Info.KeyNode->TitleIndex,
632 sizeof(REGP_COPY_KEYS));
633 if (newCopyKeys !=
NULL)
637 newCopyKeys->hKeyDest = NewKeyHandle;
639 &newCopyKeys->ListEntry);
703 if (copyKeys->hKeySrc != hKeySrc)
707 if (copyKeys->hKeyDest != hKeyDest)
757 if (lpSubKey !=
NULL)
818 if (lpSubKey !=
NULL &&
847 if (lpMachineName !=
NULL &&
877 if (!lpMachineName || !*lpMachineName)
888 if( lpMachineName[0] ==
'\\' && lpMachineName[1] ==
'\\')
893 if (!
_wcsicmp(lpMachineName, compName))
920 DWORD *lpdwDisposition)
926 ULONG FullNameLength;
948 LocalObjectAttributes.
ObjectName = &LocalKeyName;
949 FullNameLength = LocalKeyName.
Length /
sizeof(
WCHAR);
951 LocalKeyHandle =
NULL;
968 &LocalObjectAttributes,
973 TRACE(
"NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName,
Status);
993 if (
Length == FullNameLength)
1001 (
PULONG)lpdwDisposition);
1007 &LocalObjectAttributes,
1012 TRACE(
"NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName,
Status);
1044 RtlInitEmptyUnicodeString(&ClassString,
NULL, 0);
1045 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
1072 lpSecurityAttributes,
1109 TRACE(
"RegCreateKeyExW() called\n");
1130 lpSecurityAttributes,
1151 (lpClass ==
NULL)?
NULL : &ClassString,
1315 ERR(
"Wow64 not yet supported!\n");
1318 ERR(
"Wow64 not yet supported!\n");
1371 if (lpSubKey !=
NULL)
1432 if (lpSubKey !=
NULL &&
1438 if (lpValueName !=
NULL &&
1464 } REGP_DEL_KEYS, *PREG_DEL_KEYS;
1467 PREG_DEL_KEYS delKeys, newDelKeys;
1471 PREG_DEL_KEYS KeyDelRoot;
1484 sizeof(REGP_DEL_KEYS));
1485 if (KeyDelRoot !=
NULL)
1487 KeyDelRoot->KeyHandle =
hKey;
1489 &KeyDelRoot->ListEntry);
1531 Status2 =
NtOpenKey(&newDelKeys->KeyHandle,
1541 &newDelKeys->ListEntry);
1553 if (newDelKeys !=
NULL)
1558 goto ReadFirstSubKey;
1564 goto SubKeyFailureNoFree;
1569 PREG_DEL_KEYS newDelKeys2;
1578 if (newDelKeys2 !=
NULL)
1580 newDelKeys = newDelKeys2;
1584 goto ReadFirstSubKey;
1597 if (newDelKeys !=
NULL)
1609 if (newDelKeys !=
NULL)
1634 if (delKeys->KeyHandle !=
hKey)
1680 if (lpSubKey !=
NULL)
1706 Status = RegpDeleteTree(CurKey);
1747 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1782 dwMaxLen =
max(dwMaxSubkeyLen, dwMaxValueLen);
1783 if (dwMaxLen >
sizeof(szNameBuf)/
sizeof(
WCHAR))
1820 if (lpszName != szNameBuf)
1843 if (lpSubKey !=
NULL &&
1866 FIXME(
"RegDisableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1879 FIXME(
"RegEnableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1923 if (cbExpect && cbData != cbExpect)
1974 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1984 if (pszSubKey && pszSubKey[0])
2011 &dwType, pvBuf, &cbData);
2044 if (pszSubKey && pszSubKey[0])
2080 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
2090 if (pszSubKey && pszSubKey[0])
2116 &dwType, pvBuf, &cbData);
2148 if (pszSubKey && pszSubKey[0])
2156 if (pdwType) *pdwType = dwType;
2187 if (lpSubKey !=
NULL)
2257 if (lpSubKey !=
NULL)
2451 DWORD NameLength, ClassLength;
2457 NameLength = *lpcbName;
2459 if (NameBuffer ==
NULL)
2470 ClassLength = *lpcbClass;
2472 if (ClassBuffer ==
NULL)
2497 if (NameLength > *lpcbName)
2498 lpName[*lpcbName] =
'\0';
2503 if (ClassLength > *lpcbClass)
2504 lpClass[*lpcbClass] =
'\0';
2543 ULONG ClassLength = 0;
2600 if (KeyInfo ==
NULL)
2612 TRACE(
"NtEnumerateKey() returned status 0x%X\n",
Status);
2619 if (lpClass ==
NULL)
2621 if (KeyInfo->Basic.NameLength > NameLength)
2628 KeyInfo->Basic.Name,
2629 KeyInfo->Basic.NameLength);
2630 *lpcbName = (
DWORD)(KeyInfo->Basic.NameLength /
sizeof(
WCHAR));
2636 if (KeyInfo->Node.NameLength > NameLength ||
2637 KeyInfo->Node.ClassLength > ClassLength)
2645 KeyInfo->Node.NameLength);
2646 *lpcbName = KeyInfo->Node.NameLength /
sizeof(
WCHAR);
2649 (
PVOID)((
ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset),
2650 KeyInfo->Node.ClassLength);
2651 *lpcbClass = (
DWORD)(KeyInfo->Node.ClassLength /
sizeof(
WCHAR));
2652 lpClass[*lpcbClass] = 0;
2658 if (lpClass ==
NULL)
2660 lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart;
2661 lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart;
2665 lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart;
2666 lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart;
2699 DWORD NameBufferSize, NameLength;
2705 if (!
lpName || !lpcbName)
2708 if ((lpData && !lpcbData) || lpdwReserved)
2713 hKey,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, &NameBufferSize,
NULL,
NULL,
NULL);
2722 if (NameBuffer ==
NULL)
2733 NameLength = *lpcbName;
2746 NameOverflow =
TRUE;
2754 DWORD DataBufferSize = *lpcbData *
sizeof(
WCHAR);
2773 *lpcbData = DataBufferSize /
sizeof(
WCHAR);
2787 if ((
DataLength > *lpcbData) && (DataStr[*lpcbData - 1] !=
'\0'))
2788 DataStr[*lpcbData] =
'\0';
2867 TRACE(
"(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
2870 if (!
value || !val_count)
2899 total_size =
min(
sizeof(
buffer), total_size );
2902 buffer, total_size, &total_size );
2918 buf_ptr, total_size, &total_size );
2925 if (
info->NameLength/
sizeof(
WCHAR) >= *val_count)
2931 *val_count =
info->NameLength /
sizeof(
WCHAR);
2932 value[*val_count] = 0;
3010 LPDWORD lpcbSecurityDescriptor)
3024 TRACE(
"MapDefaultKey() failed (Status %lx)\n",
Status);
3030 pSecurityDescriptor,
3031 *lpcbSecurityDescriptor,
3032 lpcbSecurityDescriptor);
3038 WARN(
"NtQuerySecurityObject() failed (Status %lx)\n",
Status);
3174 DWORD dwNotifyFilter,
3258 TRACE(
"RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
3259 hKey, lpSubKey, phkResult);
3264 if (!
hKey && !lpSubKey)
3292 TRACE(
"RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3293 hKey, lpSubKey, phkResult);
3298 if (!
hKey && !lpSubKey)
3328 TRACE(
"RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3329 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3337 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
3366 TRACE(
"RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3367 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3373 if (!
hKey && lpSubKey && phkResult)
3400 if (lpSubKey ==
NULL ||
wcscmp(lpSubKey,
L"\\") == 0)
3439 *phkResult = hAligned;
3471 const WCHAR UserClassesKeyPrefix[] =
L"\\Registry\\User\\";
3472 const WCHAR UserClassesKeySuffix[] =
L"_Classes";
3507 if (TokenUserData ==
NULL)
3554 UserClassesKeyRoot.
Length = 0;
3556 sizeof(UserClassesKeyPrefix) +
3557 sizeof(UserClassesKeySuffix);
3569 UserClassesKeyPrefix);
3573 UserClassesKeySuffix);
3575 TRACE(
"RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3581 &UserClassesKeyRoot,
3618 LPDWORD lpcbSecurityDescriptor,
3628 if ((lpClass) && (!lpcClass))
3635 if (lpClass !=
NULL)
3640 cClass =
sizeof(ClassName) /
sizeof(
WCHAR);
3653 lpcbSecurityDescriptor,
3662 RtlInitEmptyAnsiString(&
AnsiString, lpClass, *lpcClass);
3672 if (lpcClass !=
NULL)
3697 LPDWORD lpcbSecurityDescriptor,
3703 ULONG ClassLength = 0;
3709 if ((lpClass) && (!lpcClass))
3721 if (lpClass !=
NULL)
3736 if (FullInfo ==
NULL)
3745 FullInfo = &FullInfoBuffer;
3748 if (lpcbSecurityDescriptor !=
NULL)
3749 *lpcbSecurityDescriptor = 0;
3756 TRACE(
"NtQueryKey() returned status 0x%X\n",
Status);
3764 if (lpcSubKeys !=
NULL)
3766 *lpcSubKeys = FullInfo->
SubKeys;
3770 if (lpcMaxSubKeyLen !=
NULL)
3776 if (lpcMaxClassLen !=
NULL)
3782 if (lpcValues !=
NULL)
3784 *lpcValues = FullInfo->
Values;
3788 if (lpcMaxValueNameLen !=
NULL)
3794 if (lpcMaxValueLen !=
NULL)
3799 if (lpcbSecurityDescriptor !=
NULL)
3807 lpcbSecurityDescriptor);
3808 TRACE(
"NtQuerySecurityObject() returned status 0x%X\n",
Status);
3811 if (lpftLastWriteTime !=
NULL)
3817 if (lpClass !=
NULL)
3837 if (lpcClass !=
NULL)
3843 if (lpClass !=
NULL)
3869 DWORD maxBytes = *ldwTotsize;
3873 if (maxBytes >= (1024*1024))
3878 TRACE(
"RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
3879 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3881 for (
i = 0;
i < num_vals;
i++)
3885 val_list[
i].ve_valuename,
3889 &val_list[
i].ve_valuelen);
3895 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3898 val_list[
i].ve_valuename,
3900 &val_list[
i].ve_type,
3902 &val_list[
i].ve_valuelen);
3933 DWORD maxBytes = *ldwTotsize;
3937 if (maxBytes >= (1024*1024))
3942 TRACE(
"RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
3943 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3945 for (
i = 0;
i < num_vals;
i++)
3949 val_list[
i].ve_valuename,
3953 &val_list[
i].ve_valuelen);
3959 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3962 val_list[
i].ve_valuename,
3964 &val_list[
i].ve_type,
3966 &val_list[
i].ve_valuelen);
3991 OUT BOOL* bIsReflectionDisabled)
3993 FIXME(
"RegQueryReflectionKey(0x%p, 0x%p) UNIMPLEMENTED!\n",
3994 hBase, bIsReflectionDisabled);
4050 RtlInitEmptyUnicodeString(&
nameW,
NULL, 0);
4103 DataStr[*
count] =
'\0';
4134 TRACE(
"(%p,%s,%p,%p,%p,%p=%d)\n",
4158 total_size = info_size;
4162 buffer, total_size, &total_size );
4194 buf_ptr, total_size, &total_size );
4199 memcpy(
data, buf_ptr + info_size, total_size - info_size );
4311 RtlInitEmptyUnicodeString(&SubKey,
NULL, 0);
4312 RtlInitEmptyUnicodeString(&OldFile,
NULL, 0);
4313 RtlInitEmptyUnicodeString(&NewFile,
NULL, 0);
4392 if (lpSubKey !=
NULL && *lpSubKey != (
WCHAR)0)
4402 &KeyObjectAttributes);
4409 CloseRealKey =
TRUE;
4414 CloseRealKey =
FALSE;
4464 &OldObjectAttributes);
4619 lpSecurityAttributes);
4660 if (lpSecurityAttributes !=
NULL)