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");
325#ifndef _ADVAPI32_VISTA_
385 if (hNewHKey ==
NULL)
459 } REGP_COPY_KEYS, *PREGP_COPY_KEYS;
462 PREGP_COPY_KEYS copyKeys, newCopyKeys;
485 sizeof(REGP_COPY_KEYS));
486 if (copyKeys !=
NULL)
488 copyKeys->hKeySrc = hKeySrc;
489 copyKeys->hKeyDest = hKeyDest;
491 ©Keys->ListEntry);
510 &BufferSizeRequired);
525 Info.KeyValue->TitleIndex,
528 Info.KeyValue->DataLength);
588 &BufferSizeRequired);
627 Info.KeyNode->TitleIndex,
635 sizeof(REGP_COPY_KEYS));
636 if (newCopyKeys !=
NULL)
640 newCopyKeys->hKeyDest = NewKeyHandle;
642 &newCopyKeys->ListEntry);
707 if (copyKeys->hKeySrc != hKeySrc)
711 if (copyKeys->hKeyDest != hKeyDest)
761 if (lpSubKey !=
NULL)
808#ifndef _ADVAPI32_VISTA_
823 if (lpSubKey !=
NULL &&
852 if (lpMachineName !=
NULL &&
882 if (!lpMachineName || !*lpMachineName)
893 if( lpMachineName[0] ==
'\\' && lpMachineName[1] ==
'\\')
898 if (!
_wcsicmp(lpMachineName, compName))
925 DWORD *lpdwDisposition)
931 ULONG FullNameLength;
953 LocalObjectAttributes.
ObjectName = &LocalKeyName;
954 FullNameLength = LocalKeyName.
Length /
sizeof(
WCHAR);
956 LocalKeyHandle =
NULL;
973 &LocalObjectAttributes,
978 TRACE(
"NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName,
Status);
998 if (
Length == FullNameLength)
1006 (
PULONG)lpdwDisposition);
1012 &LocalObjectAttributes,
1017 TRACE(
"NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName,
Status);
1049 RtlInitEmptyUnicodeString(&ClassString,
NULL, 0);
1050 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
1077 lpSecurityAttributes,
1114 TRACE(
"RegCreateKeyExW() called\n");
1135 lpSecurityAttributes,
1156 (lpClass ==
NULL)?
NULL : &ClassString,
1320 ERR(
"Wow64 not yet supported!\n");
1323 ERR(
"Wow64 not yet supported!\n");
1378 if (hSubKey !=
hKey)
1399 if (lpSubKey !=
NULL &&
1405 if (lpValueName !=
NULL &&
1431 } REGP_DEL_KEYS, *PREG_DEL_KEYS;
1434 PREG_DEL_KEYS delKeys, newDelKeys;
1438 PREG_DEL_KEYS KeyDelRoot;
1451 sizeof(REGP_DEL_KEYS));
1452 if (KeyDelRoot !=
NULL)
1454 KeyDelRoot->KeyHandle =
hKey;
1456 &KeyDelRoot->ListEntry);
1498 Status2 =
NtOpenKey(&newDelKeys->KeyHandle,
1508 &newDelKeys->ListEntry);
1520 if (newDelKeys !=
NULL)
1525 goto ReadFirstSubKey;
1531 goto SubKeyFailureNoFree;
1536 PREG_DEL_KEYS newDelKeys2;
1545 if (newDelKeys2 !=
NULL)
1547 newDelKeys = newDelKeys2;
1551 goto ReadFirstSubKey;
1564 if (newDelKeys !=
NULL)
1576 if (newDelKeys !=
NULL)
1601 if (delKeys->KeyHandle !=
hKey)
1647 if (lpSubKey !=
NULL)
1673 Status = RegpDeleteTree(CurKey);
1715 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1750 dwMaxLen =
max(dwMaxSubkeyLen, dwMaxValueLen);
1751 if (dwMaxLen >
sizeof(szNameBuf)/
sizeof(
WCHAR))
1788 if (lpszName != szNameBuf)
1811 if (lpSubKey !=
NULL &&
1825#ifndef _ADVAPI32_VISTA_
1835 FIXME(
"RegDisableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1848 FIXME(
"RegEnableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1892 if (cbExpect && cbData != cbExpect)
1943 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1953 if (pszSubKey && pszSubKey[0])
1980 &dwType, pvBuf, &cbData);
2013 if (pszSubKey && pszSubKey[0])
2049 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
2059 if (pszSubKey && pszSubKey[0])
2085 &dwType, pvBuf, &cbData);
2117 if (pszSubKey && pszSubKey[0])
2125 if (pdwType) *pdwType = dwType;
2157 if (lpSubKey !=
NULL)
2202#ifndef _ADVAPI32_VISTA_
2228 if (lpSubKey !=
NULL)
2431 DWORD NameLength, ClassLength;
2437 NameLength = *lpcbName;
2439 if (NameBuffer ==
NULL)
2450 ClassLength = *lpcbClass;
2452 if (ClassBuffer ==
NULL)
2477 if (NameLength > *lpcbName)
2478 lpName[*lpcbName] =
'\0';
2483 if (ClassLength > *lpcbClass)
2484 lpClass[*lpcbClass] =
'\0';
2523 ULONG ClassLength = 0;
2580 if (KeyInfo ==
NULL)
2592 TRACE(
"NtEnumerateKey() returned status 0x%X\n",
Status);
2599 if (lpClass ==
NULL)
2601 if (KeyInfo->Basic.NameLength > NameLength)
2608 KeyInfo->Basic.Name,
2609 KeyInfo->Basic.NameLength);
2610 *lpcbName = (
DWORD)(KeyInfo->Basic.NameLength /
sizeof(
WCHAR));
2616 if (KeyInfo->Node.NameLength > NameLength ||
2617 KeyInfo->Node.ClassLength > ClassLength)
2625 KeyInfo->Node.NameLength);
2626 *lpcbName = KeyInfo->Node.NameLength /
sizeof(
WCHAR);
2629 (
PVOID)((
ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset),
2630 KeyInfo->Node.ClassLength);
2631 *lpcbClass = (
DWORD)(KeyInfo->Node.ClassLength /
sizeof(
WCHAR));
2632 lpClass[*lpcbClass] = 0;
2638 if (lpClass ==
NULL)
2640 lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart;
2641 lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart;
2645 lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart;
2646 lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart;
2679 DWORD NameBufferSize, NameLength;
2685 if (!
lpName || !lpcbName)
2688 if ((lpData && !lpcbData) || lpdwReserved)
2693 hKey,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, &NameBufferSize,
NULL,
NULL,
NULL);
2702 if (NameBuffer ==
NULL)
2713 NameLength = *lpcbName;
2726 NameOverflow =
TRUE;
2734 DWORD DataBufferSize = *lpcbData *
sizeof(
WCHAR);
2753 *lpcbData = DataBufferSize /
sizeof(
WCHAR);
2767 if ((
DataLength > *lpcbData) && (DataStr[*lpcbData - 1] !=
'\0'))
2768 DataStr[*lpcbData] =
'\0';
2847 TRACE(
"(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
2850 if (!
value || !val_count)
2879 total_size =
min(
sizeof(
buffer), total_size );
2882 buffer, total_size, &total_size );
2898 buf_ptr, total_size, &total_size );
2905 if (
info->NameLength/
sizeof(
WCHAR) >= *val_count)
2911 *val_count =
info->NameLength /
sizeof(
WCHAR);
2912 value[*val_count] = 0;
2990 LPDWORD lpcbSecurityDescriptor)
3004 TRACE(
"MapDefaultKey() failed (Status %lx)\n",
Status);
3010 pSecurityDescriptor,
3011 *lpcbSecurityDescriptor,
3012 lpcbSecurityDescriptor);
3018 WARN(
"NtQuerySecurityObject() failed (Status %lx)\n",
Status);
3154 DWORD dwNotifyFilter,
3238 TRACE(
"RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
3239 hKey, lpSubKey, phkResult);
3244 if (!
hKey && !lpSubKey)
3272 TRACE(
"RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3273 hKey, lpSubKey, phkResult);
3278 if (!
hKey && !lpSubKey)
3308 TRACE(
"RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3309 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3317 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
3347 TRACE(
"RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3348 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3354 if (!
hKey && lpSubKey && phkResult)
3381 if (lpSubKey ==
NULL ||
wcscmp(lpSubKey,
L"\\") == 0)
3402 SubKeyString = AlignedString;
3403 SubKeyStringAllocated =
TRUE;
3419 if (SubKeyStringAllocated)
3446 const WCHAR UserClassesKeyPrefix[] =
L"\\Registry\\User\\";
3447 const WCHAR UserClassesKeySuffix[] =
L"_Classes";
3482 if (TokenUserData ==
NULL)
3529 UserClassesKeyRoot.
Length = 0;
3531 sizeof(UserClassesKeyPrefix) +
3532 sizeof(UserClassesKeySuffix);
3544 UserClassesKeyPrefix);
3548 UserClassesKeySuffix);
3550 TRACE(
"RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3556 &UserClassesKeyRoot,
3593 LPDWORD lpcbSecurityDescriptor,
3603 if ((lpClass) && (!lpcClass))
3610 if (lpClass !=
NULL)
3615 cClass =
sizeof(ClassName) /
sizeof(
WCHAR);
3628 lpcbSecurityDescriptor,
3637 RtlInitEmptyAnsiString(&
AnsiString, lpClass, *lpcClass);
3647 if (lpcClass !=
NULL)
3672 LPDWORD lpcbSecurityDescriptor,
3678 ULONG ClassLength = 0;
3684 if ((lpClass) && (!lpcClass))
3699 lpcSubKeys, lpcMaxSubKeyLen, lpcMaxClassLen,
3700 lpcValues, lpcMaxValueNameLen, lpcMaxValueLen,
3701 lpcbSecurityDescriptor, lpftLastWriteTime);
3706 if (lpClass !=
NULL)
3721 if (FullInfo ==
NULL)
3730 FullInfo = &FullInfoBuffer;
3733 if (lpcbSecurityDescriptor !=
NULL)
3734 *lpcbSecurityDescriptor = 0;
3741 TRACE(
"NtQueryKey() returned status 0x%X\n",
Status);
3749 if (lpcSubKeys !=
NULL)
3751 *lpcSubKeys = FullInfo->
SubKeys;
3755 if (lpcMaxSubKeyLen !=
NULL)
3761 if (lpcMaxClassLen !=
NULL)
3767 if (lpcValues !=
NULL)
3769 *lpcValues = FullInfo->
Values;
3773 if (lpcMaxValueNameLen !=
NULL)
3779 if (lpcMaxValueLen !=
NULL)
3784 if (lpcbSecurityDescriptor !=
NULL)
3792 lpcbSecurityDescriptor);
3793 TRACE(
"NtQuerySecurityObject() returned status 0x%X\n",
Status);
3796 if (lpftLastWriteTime !=
NULL)
3802 if (lpClass !=
NULL)
3822 if (lpcClass !=
NULL)
3828 if (lpClass !=
NULL)
3854 DWORD maxBytes = *ldwTotsize;
3858 if (maxBytes >= (1024*1024))
3863 TRACE(
"RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
3864 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3866 for (
i = 0;
i < num_vals;
i++)
3870 val_list[
i].ve_valuename,
3874 &val_list[
i].ve_valuelen);
3880 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3883 val_list[
i].ve_valuename,
3885 &val_list[
i].ve_type,
3887 &val_list[
i].ve_valuelen);
3918 DWORD maxBytes = *ldwTotsize;
3922 if (maxBytes >= (1024*1024))
3927 TRACE(
"RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
3928 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3930 for (
i = 0;
i < num_vals;
i++)
3934 val_list[
i].ve_valuename,
3938 &val_list[
i].ve_valuelen);
3944 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3947 val_list[
i].ve_valuename,
3949 &val_list[
i].ve_type,
3951 &val_list[
i].ve_valuelen);
3976 OUT BOOL* bIsReflectionDisabled)
3978 FIXME(
"RegQueryReflectionKey(0x%p, 0x%p) UNIMPLEMENTED!\n",
3979 hBase, bIsReflectionDisabled);
4035 RtlInitEmptyUnicodeString(&
nameW,
NULL, 0);
4088 DataStr[*
count] =
'\0';
4119 TRACE(
"(%p,%s,%p,%p,%p,%p=%d)\n",
4143 total_size = info_size;
4147 buffer, total_size, &total_size );
4179 buf_ptr, total_size, &total_size );
4184 memcpy(
data, buf_ptr + info_size, total_size - info_size );
4296 RtlInitEmptyUnicodeString(&SubKey,
NULL, 0);
4297 RtlInitEmptyUnicodeString(&OldFile,
NULL, 0);
4298 RtlInitEmptyUnicodeString(&NewFile,
NULL, 0);
4377 if (lpSubKey !=
NULL && *lpSubKey != (
WCHAR)0)
4387 &KeyObjectAttributes);
4394 CloseRealKey =
TRUE;
4399 CloseRealKey =
FALSE;
4449 &OldObjectAttributes);
4604 lpSecurityAttributes);
4645 if (lpSecurityAttributes !=
NULL)
4715 lpSecurityAttributes,