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");
1133 lpSecurityAttributes,
1154 (lpClass ==
NULL)?
NULL : &ClassString,
1318 ERR(
"Wow64 not yet supported!\n");
1321 ERR(
"Wow64 not yet supported!\n");
1374 if (lpSubKey !=
NULL)
1435 if (lpSubKey !=
NULL &&
1441 if (lpValueName !=
NULL &&
1467 } REGP_DEL_KEYS, *PREG_DEL_KEYS;
1470 PREG_DEL_KEYS delKeys, newDelKeys;
1474 PREG_DEL_KEYS KeyDelRoot;
1487 sizeof(REGP_DEL_KEYS));
1488 if (KeyDelRoot !=
NULL)
1490 KeyDelRoot->KeyHandle =
hKey;
1492 &KeyDelRoot->ListEntry);
1534 Status2 =
NtOpenKey(&newDelKeys->KeyHandle,
1544 &newDelKeys->ListEntry);
1556 if (newDelKeys !=
NULL)
1561 goto ReadFirstSubKey;
1567 goto SubKeyFailureNoFree;
1572 PREG_DEL_KEYS newDelKeys2;
1581 if (newDelKeys2 !=
NULL)
1583 newDelKeys = newDelKeys2;
1587 goto ReadFirstSubKey;
1600 if (newDelKeys !=
NULL)
1612 if (newDelKeys !=
NULL)
1619 SubKeyFailureNoFree:
1637 if (delKeys->KeyHandle !=
hKey)
1683 if (lpSubKey !=
NULL)
1709 Status = RegpDeleteTree(CurKey);
1750 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1785 dwMaxLen =
max(dwMaxSubkeyLen, dwMaxValueLen);
1786 if (dwMaxLen >
sizeof(szNameBuf)/
sizeof(
WCHAR))
1823 if (lpszName != szNameBuf)
1846 if (lpSubKey !=
NULL &&
1869 FIXME(
"RegDisableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1882 FIXME(
"RegEnableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1926 if (cbExpect && cbData != cbExpect)
1977 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1987 if (pszSubKey && pszSubKey[0])
2014 &dwType, pvBuf, &cbData);
2047 if (pszSubKey && pszSubKey[0])
2083 TRACE(
"(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
2093 if (pszSubKey && pszSubKey[0])
2119 &dwType, pvBuf, &cbData);
2151 if (pszSubKey && pszSubKey[0])
2159 if (pdwType) *pdwType = dwType;
2190 if (lpSubKey !=
NULL)
2260 if (lpSubKey !=
NULL)
2454 DWORD NameLength, ClassLength;
2460 NameLength = *lpcbName;
2462 if (NameBuffer ==
NULL)
2473 ClassLength = *lpcbClass;
2475 if (ClassBuffer ==
NULL)
2500 if (NameLength > *lpcbName)
2501 lpName[*lpcbName] =
'\0';
2506 if (ClassLength > *lpcbClass)
2507 lpClass[*lpcbClass] =
'\0';
2546 ULONG ClassLength = 0;
2603 if (KeyInfo ==
NULL)
2615 TRACE(
"NtEnumerateKey() returned status 0x%X\n",
Status);
2622 if (lpClass ==
NULL)
2624 if (KeyInfo->Basic.NameLength > NameLength)
2631 KeyInfo->Basic.Name,
2632 KeyInfo->Basic.NameLength);
2633 *lpcbName = (
DWORD)(KeyInfo->Basic.NameLength /
sizeof(
WCHAR));
2639 if (KeyInfo->Node.NameLength > NameLength ||
2640 KeyInfo->Node.ClassLength > ClassLength)
2648 KeyInfo->Node.NameLength);
2649 *lpcbName = KeyInfo->Node.NameLength /
sizeof(
WCHAR);
2652 (
PVOID)((
ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset),
2653 KeyInfo->Node.ClassLength);
2654 *lpcbClass = (
DWORD)(KeyInfo->Node.ClassLength /
sizeof(
WCHAR));
2655 lpClass[*lpcbClass] = 0;
2661 if (lpClass ==
NULL)
2663 lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart;
2664 lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart;
2668 lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart;
2669 lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart;
2702 DWORD NameBufferSize, NameLength;
2708 if (!
lpName || !lpcbName)
2711 if ((lpData && !lpcbData) || lpdwReserved)
2716 hKey,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, &NameBufferSize,
NULL,
NULL,
NULL);
2725 if (NameBuffer ==
NULL)
2736 NameLength = *lpcbName;
2749 NameOverflow =
TRUE;
2757 DWORD DataBufferSize = *lpcbData *
sizeof(
WCHAR);
2776 *lpcbData = DataBufferSize /
sizeof(
WCHAR);
2790 if ((
DataLength > *lpcbData) && (DataStr[*lpcbData - 1] !=
'\0'))
2791 DataStr[*lpcbData] =
'\0';
2870 TRACE(
"(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
2873 if (!
value || !val_count)
2902 total_size =
min(
sizeof(
buffer), total_size );
2905 buffer, total_size, &total_size );
2921 buf_ptr, total_size, &total_size );
2928 if (
info->NameLength/
sizeof(
WCHAR) >= *val_count)
2934 *val_count =
info->NameLength /
sizeof(
WCHAR);
2935 value[*val_count] = 0;
3013 LPDWORD lpcbSecurityDescriptor)
3027 TRACE(
"MapDefaultKey() failed (Status %lx)\n",
Status);
3033 pSecurityDescriptor,
3034 *lpcbSecurityDescriptor,
3035 lpcbSecurityDescriptor);
3041 WARN(
"NtQuerySecurityObject() failed (Status %lx)\n",
Status);
3177 DWORD dwNotifyFilter,
3261 TRACE(
"RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
3262 hKey, lpSubKey, phkResult);
3267 if (!
hKey && lpSubKey && phkResult)
3272 if (!lpSubKey || !*lpSubKey)
3300 TRACE(
"RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3301 hKey, lpSubKey, phkResult);
3306 if (!
hKey && lpSubKey && phkResult)
3311 if (!lpSubKey || !*lpSubKey)
3341 TRACE(
"RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3342 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3350 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
3379 TRACE(
"RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3380 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3438 *phkResult = hAligned;
3470 const WCHAR UserClassesKeyPrefix[] =
L"\\Registry\\User\\";
3471 const WCHAR UserClassesKeySuffix[] =
L"_Classes";
3506 if (TokenUserData ==
NULL)
3553 UserClassesKeyRoot.
Length = 0;
3555 sizeof(UserClassesKeyPrefix) +
3556 sizeof(UserClassesKeySuffix);
3568 UserClassesKeyPrefix);
3572 UserClassesKeySuffix);
3574 TRACE(
"RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3580 &UserClassesKeyRoot,
3617 LPDWORD lpcbSecurityDescriptor,
3627 if ((lpClass) && (!lpcClass))
3634 if (lpClass !=
NULL)
3639 cClass =
sizeof(ClassName) /
sizeof(
WCHAR);
3652 lpcbSecurityDescriptor,
3661 RtlInitEmptyAnsiString(&
AnsiString, lpClass, *lpcClass);
3671 if (lpcClass !=
NULL)
3696 LPDWORD lpcbSecurityDescriptor,
3702 ULONG ClassLength = 0;
3708 if ((lpClass) && (!lpcClass))
3720 if (lpClass !=
NULL)
3735 if (FullInfo ==
NULL)
3744 FullInfo = &FullInfoBuffer;
3747 if (lpcbSecurityDescriptor !=
NULL)
3748 *lpcbSecurityDescriptor = 0;
3755 TRACE(
"NtQueryKey() returned status 0x%X\n",
Status);
3763 if (lpcSubKeys !=
NULL)
3765 *lpcSubKeys = FullInfo->
SubKeys;
3769 if (lpcMaxSubKeyLen !=
NULL)
3775 if (lpcMaxClassLen !=
NULL)
3781 if (lpcValues !=
NULL)
3783 *lpcValues = FullInfo->
Values;
3787 if (lpcMaxValueNameLen !=
NULL)
3793 if (lpcMaxValueLen !=
NULL)
3798 if (lpcbSecurityDescriptor !=
NULL)
3806 lpcbSecurityDescriptor);
3807 TRACE(
"NtQuerySecurityObject() returned status 0x%X\n",
Status);
3810 if (lpftLastWriteTime !=
NULL)
3816 if (lpClass !=
NULL)
3836 if (lpcClass !=
NULL)
3842 if (lpClass !=
NULL)
3868 DWORD maxBytes = *ldwTotsize;
3872 if (maxBytes >= (1024*1024))
3877 TRACE(
"RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
3878 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3880 for (
i = 0;
i < num_vals;
i++)
3884 val_list[
i].ve_valuename,
3888 &val_list[
i].ve_valuelen);
3894 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3897 val_list[
i].ve_valuename,
3899 &val_list[
i].ve_type,
3901 &val_list[
i].ve_valuelen);
3932 DWORD maxBytes = *ldwTotsize;
3936 if (maxBytes >= (1024*1024))
3941 TRACE(
"RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
3942 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3944 for (
i = 0;
i < num_vals;
i++)
3948 val_list[
i].ve_valuename,
3952 &val_list[
i].ve_valuelen);
3958 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3961 val_list[
i].ve_valuename,
3963 &val_list[
i].ve_type,
3965 &val_list[
i].ve_valuelen);
3990 OUT BOOL* bIsReflectionDisabled)
3992 FIXME(
"RegQueryReflectionKey(0x%p, 0x%p) UNIMPLEMENTED!\n",
3993 hBase, bIsReflectionDisabled);
4049 RtlInitEmptyUnicodeString(&
nameW,
NULL, 0);
4101 DataStr[*
count] =
'\0';
4132 TRACE(
"(%p,%s,%p,%p,%p,%p=%d)\n",
4156 total_size = info_size;
4160 buffer, total_size, &total_size );
4192 buf_ptr, total_size, &total_size );
4197 memcpy(
data, buf_ptr + info_size, total_size - info_size );
4309 RtlInitEmptyUnicodeString(&SubKey,
NULL, 0);
4310 RtlInitEmptyUnicodeString(&OldFile,
NULL, 0);
4311 RtlInitEmptyUnicodeString(&NewFile,
NULL, 0);
4390 if (lpSubKey !=
NULL && *lpSubKey != (
WCHAR)0)
4400 &KeyObjectAttributes);
4407 CloseRealKey =
TRUE;
4412 CloseRealKey =
FALSE;
4462 &OldObjectAttributes);
4617 lpSecurityAttributes);
4658 if (lpSecurityAttributes !=
NULL)
4728 lpSecurityAttributes,
4758 FIXME(
"RegSaveKeyExW(): Flags ignored!\n");
4762 lpSecurityAttributes);
4793 pSecurityDescriptor);
4829 if (lpValueName !=
NULL && lpValueName[0] !=
'\0')
4846 LONG bNoNulledStr = ((lpData[cbData-1] !=
'\0') ? 1 : 0);
4849 AnsiString.MaximumLength = cbData + bNoNulledStr;
4856 if (pValueName !=
NULL)
4878 if (pValueName !=
NULL)
4927 if((pwsData[cbData /
sizeof(
WCHAR) - 1] !=
L'\0') &&
4928 (pwsData[cbData /
sizeof(
WCHAR)] ==
L'\0'))
4931 cbData +=
sizeof(
WCHAR);
4989 if (lpSubKey && lpSubKey[0])
5026 if (dwType !=
REG_SZ || !lpData)
5037 if (lpSubKey && lpSubKey[0])