- Fixed the enumeration of subkeys for which doesn't exist a hash entry.

- Fixed the enumeration of the length of all sub key and class names.

svn path=/trunk/; revision=5935
This commit is contained in:
Hartmut Birr 2003-08-30 14:49:03 +00:00
parent 249cdd634d
commit ee8ef2cacf
2 changed files with 34 additions and 77 deletions

View file

@ -443,12 +443,10 @@ NTSTATUS
CmiFlushRegistryHive(PREGISTRY_HIVE RegistryHive); CmiFlushRegistryHive(PREGISTRY_HIVE RegistryHive);
ULONG ULONG
CmiGetMaxNameLength(IN PREGISTRY_HIVE RegistryHive, CmiGetMaxNameLength(IN PKEY_OBJECT KeyObject);
IN PKEY_CELL KeyCell);
ULONG ULONG
CmiGetMaxClassLength(IN PREGISTRY_HIVE RegistryHive, CmiGetMaxClassLength(IN PKEY_OBJECT KeyObject);
IN PKEY_CELL KeyCell);
ULONG ULONG
CmiGetMaxValueNameLength(IN PREGISTRY_HIVE RegistryHive, CmiGetMaxValueNameLength(IN PREGISTRY_HIVE RegistryHive,

View file

@ -315,7 +315,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
CurKey = KeyObject->SubKeys[i]; CurKey = KeyObject->SubKeys[i];
if (CurKey->RegistryHive == CmiVolatileHive) if (CurKey->RegistryHive == CmiVolatileHive)
{ {
if (Index-- == KeyObject->NumberOfSubKeys) if (Index-- == KeyCell->NumberOfSubKeys)
break; break;
} }
} }
@ -472,10 +472,8 @@ NtEnumerateKey(IN HANDLE KeyHandle,
sizeof(WCHAR); sizeof(WCHAR);
FullInformation->ClassLength = SubKeyCell->ClassSize; FullInformation->ClassLength = SubKeyCell->ClassSize;
FullInformation->SubKeys = SubKeyCell->NumberOfSubKeys; FullInformation->SubKeys = SubKeyCell->NumberOfSubKeys;
FullInformation->MaxNameLen = FullInformation->MaxNameLen = CmiGetMaxNameLength(KeyObject);
CmiGetMaxNameLength(RegistryHive, SubKeyCell); FullInformation->MaxClassLen = CmiGetMaxClassLength(KeyObject);
FullInformation->MaxClassLen =
CmiGetMaxClassLength(RegistryHive, SubKeyCell);
FullInformation->Values = SubKeyCell->NumberOfValues; FullInformation->Values = SubKeyCell->NumberOfValues;
FullInformation->MaxValueNameLen = FullInformation->MaxValueNameLen =
CmiGetMaxValueNameLength(RegistryHive, SubKeyCell); CmiGetMaxValueNameLength(RegistryHive, SubKeyCell);
@ -521,6 +519,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
PKEY_CELL KeyCell; PKEY_CELL KeyCell;
PVALUE_CELL ValueCell; PVALUE_CELL ValueCell;
PDATA_CELL DataCell; PDATA_CELL DataCell;
ULONG NameSize;
PKEY_VALUE_BASIC_INFORMATION ValueBasicInformation; PKEY_VALUE_BASIC_INFORMATION ValueBasicInformation;
PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInformation; PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInformation;
PKEY_VALUE_FULL_INFORMATION ValueFullInformation; PKEY_VALUE_FULL_INFORMATION ValueFullInformation;
@ -573,16 +572,12 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
switch (KeyValueInformationClass) switch (KeyValueInformationClass)
{ {
case KeyValueBasicInformation: case KeyValueBasicInformation:
NameSize = ValueCell->NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) + NameSize *= sizeof(WCHAR);
(ValueCell->NameSize + 1) * sizeof(WCHAR);
}
else
{
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) +
ValueCell->NameSize + sizeof(WCHAR);
} }
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) + NameSize;
if (Length < *ResultLength) if (Length < *ResultLength)
{ {
Status = STATUS_BUFFER_OVERFLOW; Status = STATUS_BUFFER_OVERFLOW;
@ -593,23 +588,18 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
KeyValueInformation; KeyValueInformation;
ValueBasicInformation->TitleIndex = 0; ValueBasicInformation->TitleIndex = 0;
ValueBasicInformation->Type = ValueCell->DataType; ValueBasicInformation->Type = ValueCell->DataType;
ValueBasicInformation->NameLength = NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
ValueBasicInformation->NameLength =
(ValueCell->NameSize + 1) * sizeof(WCHAR);
CmiCopyPackedName(ValueBasicInformation->Name, CmiCopyPackedName(ValueBasicInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueBasicInformation->Name[ValueCell->NameSize] = 0;
} }
else else
{ {
ValueBasicInformation->NameLength =
ValueCell->NameSize + sizeof(WCHAR);
RtlCopyMemory(ValueBasicInformation->Name, RtlCopyMemory(ValueBasicInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize * sizeof(WCHAR)); NameSize);
ValueBasicInformation->Name[ValueCell->NameSize / sizeof(WCHAR)] = 0;
} }
} }
break; break;
@ -646,18 +636,13 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
break; break;
case KeyValueFullInformation: case KeyValueFullInformation:
NameSize = ValueCell->NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
*ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) + NameSize *= sizeof(WCHAR);
(ValueCell->NameSize + 1) * sizeof(WCHAR) +
(ValueCell->DataSize & LONG_MAX);
} }
else
{
*ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) + *ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) +
ValueCell->NameSize + sizeof(WCHAR) + NameSize + (ValueCell->DataSize & LONG_MAX);
(ValueCell->DataSize & LONG_MAX);
}
if (Length < *ResultLength) if (Length < *ResultLength)
{ {
Status = STATUS_BUFFER_OVERFLOW; Status = STATUS_BUFFER_OVERFLOW;
@ -668,24 +653,18 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
KeyValueInformation; KeyValueInformation;
ValueFullInformation->TitleIndex = 0; ValueFullInformation->TitleIndex = 0;
ValueFullInformation->Type = ValueCell->DataType; ValueFullInformation->Type = ValueCell->DataType;
ValueFullInformation->NameLength = NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
ValueFullInformation->NameLength =
(ValueCell->NameSize + 1) * sizeof(WCHAR);
CmiCopyPackedName(ValueFullInformation->Name, CmiCopyPackedName(ValueFullInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueFullInformation->Name[ValueCell->NameSize] = 0;
} }
else else
{ {
ValueFullInformation->NameLength =
ValueCell->NameSize + sizeof(WCHAR);
RtlCopyMemory(ValueFullInformation->Name, RtlCopyMemory(ValueFullInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueFullInformation->Name[ValueCell->NameSize / sizeof(WCHAR)] = 0;
} }
ValueFullInformation->DataOffset = ValueFullInformation->DataOffset =
(ULONG)ValueFullInformation->Name - (ULONG)ValueFullInformation + (ULONG)ValueFullInformation->Name - (ULONG)ValueFullInformation +
@ -849,7 +828,7 @@ NtQueryKey(IN HANDLE KeyHandle,
PKEY_CELL KeyCell; PKEY_CELL KeyCell;
NTSTATUS Status; NTSTATUS Status;
DPRINT("KH %x KIC %x KI %x L %d RL %x\n", DPRINT("NtQueryKey(KH %x KIC %x KI %x L %d RL %x)\n",
KeyHandle, KeyHandle,
KeyInformationClass, KeyInformationClass,
KeyInformation, KeyInformation,
@ -978,10 +957,8 @@ NtQueryKey(IN HANDLE KeyHandle,
FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - sizeof(WCHAR); FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - sizeof(WCHAR);
FullInformation->ClassLength = KeyCell->ClassSize; FullInformation->ClassLength = KeyCell->ClassSize;
FullInformation->SubKeys = KeyCell->NumberOfSubKeys; FullInformation->SubKeys = KeyCell->NumberOfSubKeys;
FullInformation->MaxNameLen = FullInformation->MaxNameLen = CmiGetMaxNameLength(KeyObject);
CmiGetMaxNameLength(RegistryHive, KeyCell); FullInformation->MaxClassLen = CmiGetMaxClassLength(KeyObject);
FullInformation->MaxClassLen =
CmiGetMaxClassLength(RegistryHive, KeyCell);
FullInformation->Values = KeyCell->NumberOfValues; FullInformation->Values = KeyCell->NumberOfValues;
FullInformation->MaxValueNameLen = FullInformation->MaxValueNameLen =
CmiGetMaxValueNameLength(RegistryHive, KeyCell); CmiGetMaxValueNameLength(RegistryHive, KeyCell);
@ -1019,6 +996,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG NameSize;
PKEY_OBJECT KeyObject; PKEY_OBJECT KeyObject;
PREGISTRY_HIVE RegistryHive; PREGISTRY_HIVE RegistryHive;
PKEY_CELL KeyCell; PKEY_CELL KeyCell;
@ -1072,16 +1050,12 @@ NtQueryValueKey(IN HANDLE KeyHandle,
switch (KeyValueInformationClass) switch (KeyValueInformationClass)
{ {
case KeyValueBasicInformation: case KeyValueBasicInformation:
NameSize = ValueCell->NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) + NameSize *= sizeof(WCHAR);
(ValueCell->NameSize + 1) * sizeof(WCHAR);
}
else
{
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) +
ValueCell->NameSize + sizeof(WCHAR);
} }
*ResultLength = sizeof(KEY_VALUE_BASIC_INFORMATION) + NameSize;
if (Length < *ResultLength) if (Length < *ResultLength)
{ {
Status = STATUS_BUFFER_TOO_SMALL; Status = STATUS_BUFFER_TOO_SMALL;
@ -1092,23 +1066,18 @@ NtQueryValueKey(IN HANDLE KeyHandle,
KeyValueInformation; KeyValueInformation;
ValueBasicInformation->TitleIndex = 0; ValueBasicInformation->TitleIndex = 0;
ValueBasicInformation->Type = ValueCell->DataType; ValueBasicInformation->Type = ValueCell->DataType;
ValueBasicInformation->NameLength = NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
ValueBasicInformation->NameLength =
(ValueCell->NameSize + 1) * sizeof(WCHAR);
CmiCopyPackedName(ValueBasicInformation->Name, CmiCopyPackedName(ValueBasicInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueBasicInformation->Name[ValueCell->NameSize] = 0;
} }
else else
{ {
ValueBasicInformation->NameLength =
ValueCell->NameSize + sizeof(WCHAR);
RtlCopyMemory(ValueBasicInformation->Name, RtlCopyMemory(ValueBasicInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize * sizeof(WCHAR)); ValueCell->NameSize * sizeof(WCHAR));
ValueBasicInformation->Name[ValueCell->NameSize / sizeof(WCHAR)] = 0;
} }
} }
break; break;
@ -1144,18 +1113,13 @@ NtQueryValueKey(IN HANDLE KeyHandle,
break; break;
case KeyValueFullInformation: case KeyValueFullInformation:
NameSize = ValueCell->NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
*ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) + NameSize *= sizeof(WCHAR);
(ValueCell->NameSize + 1) * sizeof(WCHAR) +
(ValueCell->DataSize & LONG_MAX);
} }
else
{
*ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) + *ResultLength = sizeof(KEY_VALUE_FULL_INFORMATION) +
ValueCell->NameSize + sizeof(WCHAR) + NameSize + (ValueCell->DataSize & LONG_MAX);
(ValueCell->DataSize & LONG_MAX);
}
if (Length < *ResultLength) if (Length < *ResultLength)
{ {
Status = STATUS_BUFFER_TOO_SMALL; Status = STATUS_BUFFER_TOO_SMALL;
@ -1166,23 +1130,18 @@ NtQueryValueKey(IN HANDLE KeyHandle,
KeyValueInformation; KeyValueInformation;
ValueFullInformation->TitleIndex = 0; ValueFullInformation->TitleIndex = 0;
ValueFullInformation->Type = ValueCell->DataType; ValueFullInformation->Type = ValueCell->DataType;
ValueFullInformation->NameLength = NameSize;
if (ValueCell->Flags & REG_VALUE_NAME_PACKED) if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{ {
ValueFullInformation->NameLength =
(ValueCell->NameSize + 1) * sizeof(WCHAR);
CmiCopyPackedName(ValueFullInformation->Name, CmiCopyPackedName(ValueFullInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueFullInformation->Name[ValueCell->NameSize] = 0;
} }
else else
{ {
ValueFullInformation->NameLength =
ValueCell->NameSize + sizeof(WCHAR);
RtlCopyMemory(ValueFullInformation->Name, RtlCopyMemory(ValueFullInformation->Name,
ValueCell->Name, ValueCell->Name,
ValueCell->NameSize); ValueCell->NameSize);
ValueFullInformation->Name[ValueCell->NameSize / sizeof(WCHAR)] = 0;
} }
ValueFullInformation->DataOffset = ValueFullInformation->DataOffset =
(ULONG)ValueFullInformation->Name - (ULONG)ValueFullInformation + (ULONG)ValueFullInformation->Name - (ULONG)ValueFullInformation +