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)
3295 TRACE(
"RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3296 hKey, lpSubKey, phkResult);
3301 if (!
hKey && !lpSubKey)
3331 TRACE(
"RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3332 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3340 RtlInitEmptyUnicodeString(&SubKeyString,
NULL, 0);
3369 TRACE(
"RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3370 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3376 if (!
hKey && lpSubKey && phkResult)
3403 if (lpSubKey ==
NULL ||
wcscmp(lpSubKey,
L"\\") == 0)
3442 *phkResult = hAligned;
3474 const WCHAR UserClassesKeyPrefix[] =
L"\\Registry\\User\\";
3475 const WCHAR UserClassesKeySuffix[] =
L"_Classes";
3510 if (TokenUserData ==
NULL)
3557 UserClassesKeyRoot.
Length = 0;
3559 sizeof(UserClassesKeyPrefix) +
3560 sizeof(UserClassesKeySuffix);
3572 UserClassesKeyPrefix);
3576 UserClassesKeySuffix);
3578 TRACE(
"RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3584 &UserClassesKeyRoot,
3621 LPDWORD lpcbSecurityDescriptor,
3631 if ((lpClass) && (!lpcClass))
3638 if (lpClass !=
NULL)
3643 cClass =
sizeof(ClassName) /
sizeof(
WCHAR);
3656 lpcbSecurityDescriptor,
3665 RtlInitEmptyAnsiString(&
AnsiString, lpClass, *lpcClass);
3675 if (lpcClass !=
NULL)
3700 LPDWORD lpcbSecurityDescriptor,
3706 ULONG ClassLength = 0;
3712 if ((lpClass) && (!lpcClass))
3724 if (lpClass !=
NULL)
3739 if (FullInfo ==
NULL)
3748 FullInfo = &FullInfoBuffer;
3751 if (lpcbSecurityDescriptor !=
NULL)
3752 *lpcbSecurityDescriptor = 0;
3759 TRACE(
"NtQueryKey() returned status 0x%X\n",
Status);
3767 if (lpcSubKeys !=
NULL)
3769 *lpcSubKeys = FullInfo->
SubKeys;
3773 if (lpcMaxSubKeyLen !=
NULL)
3779 if (lpcMaxClassLen !=
NULL)
3785 if (lpcValues !=
NULL)
3787 *lpcValues = FullInfo->
Values;
3791 if (lpcMaxValueNameLen !=
NULL)
3797 if (lpcMaxValueLen !=
NULL)
3802 if (lpcbSecurityDescriptor !=
NULL)
3810 lpcbSecurityDescriptor);
3811 TRACE(
"NtQuerySecurityObject() returned status 0x%X\n",
Status);
3814 if (lpftLastWriteTime !=
NULL)
3820 if (lpClass !=
NULL)
3840 if (lpcClass !=
NULL)
3846 if (lpClass !=
NULL)
3872 DWORD maxBytes = *ldwTotsize;
3876 if (maxBytes >= (1024*1024))
3881 TRACE(
"RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
3882 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3884 for (
i = 0;
i < num_vals;
i++)
3888 val_list[
i].ve_valuename,
3892 &val_list[
i].ve_valuelen);
3898 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3901 val_list[
i].ve_valuename,
3903 &val_list[
i].ve_type,
3905 &val_list[
i].ve_valuelen);
3936 DWORD maxBytes = *ldwTotsize;
3940 if (maxBytes >= (1024*1024))
3945 TRACE(
"RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
3946 hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
3948 for (
i = 0;
i < num_vals;
i++)
3952 val_list[
i].ve_valuename,
3956 &val_list[
i].ve_valuelen);
3962 if (lpValueBuf !=
NULL && *ldwTotsize + val_list[
i].ve_valuelen <= maxBytes)
3965 val_list[
i].ve_valuename,
3967 &val_list[
i].ve_type,
3969 &val_list[
i].ve_valuelen);
3994 OUT BOOL* bIsReflectionDisabled)
3996 FIXME(
"RegQueryReflectionKey(0x%p, 0x%p) UNIMPLEMENTED!\n",
3997 hBase, bIsReflectionDisabled);
4053 RtlInitEmptyUnicodeString(&
nameW,
NULL, 0);
4106 DataStr[*
count] =
'\0';
4137 TRACE(
"(%p,%s,%p,%p,%p,%p=%d)\n",
4161 total_size = info_size;
4165 buffer, total_size, &total_size );
4197 buf_ptr, total_size, &total_size );
4202 memcpy(
data, buf_ptr + info_size, total_size - info_size );
4314 RtlInitEmptyUnicodeString(&SubKey,
NULL, 0);
4315 RtlInitEmptyUnicodeString(&OldFile,
NULL, 0);
4316 RtlInitEmptyUnicodeString(&NewFile,
NULL, 0);
4395 if (lpSubKey !=
NULL && *lpSubKey != (
WCHAR)0)
4405 &KeyObjectAttributes);
4412 CloseRealKey =
TRUE;
4417 CloseRealKey =
FALSE;
4467 &OldObjectAttributes);
4622 lpSecurityAttributes);
4663 if (lpSecurityAttributes !=
NULL)
4733 lpSecurityAttributes,
4763 FIXME(
"RegSaveKeyExW(): Flags ignored!\n");
4767 lpSecurityAttributes);
4798 pSecurityDescriptor);
4834 if (lpValueName !=
NULL && lpValueName[0] !=
'\0')
4851 LONG bNoNulledStr = ((lpData[cbData-1] !=
'\0') ? 1 : 0);
4854 AnsiString.MaximumLength = cbData + bNoNulledStr;
4861 if (pValueName !=
NULL)
4883 if (pValueName !=
NULL)
4932 if((pwsData[cbData /
sizeof(
WCHAR) - 1] !=
L'\0') &&
4933 (pwsData[cbData /
sizeof(
WCHAR)] ==
L'\0'))
4936 cbData +=
sizeof(
WCHAR);
4994 if (lpSubKey && lpSubKey[0])
5031 if (dwType !=
REG_SZ || !lpData)
5042 if (lpSubKey && lpSubKey[0])