mirror of
https://github.com/reactos/reactos.git
synced 2025-07-15 14:04:03 +00:00
Cleaned up NtSetValueKey() and NtQueryValueKey().
Made CmiScanKeyForValue() more robust. svn path=/trunk/; revision=7602
This commit is contained in:
parent
bc5e5cf2fd
commit
46059ee5d0
2 changed files with 145 additions and 156 deletions
|
@ -1012,8 +1012,10 @@ NtQueryKey(IN HANDLE KeyHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT1("Not handling 0x%x\n", KeyInformationClass);
|
DPRINT1("Not handling 0x%x\n", KeyInformationClass);
|
||||||
|
Status = STATUS_INVALID_INFO_CLASS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,7 +1059,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ObReferenceObjectByHandle() failed with status %x\n", Status);
|
DPRINT1("ObReferenceObjectByHandle() failed with status %x\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,7 +1073,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
||||||
KeyCell = KeyObject->KeyCell;
|
KeyCell = KeyObject->KeyCell;
|
||||||
RegistryHive = KeyObject->RegistryHive;
|
RegistryHive = KeyObject->RegistryHive;
|
||||||
|
|
||||||
/* Get Value block of interest */
|
/* Get value cell by name */
|
||||||
Status = CmiScanKeyForValue(RegistryHive,
|
Status = CmiScanKeyForValue(RegistryHive,
|
||||||
KeyCell,
|
KeyCell,
|
||||||
ValueName,
|
ValueName,
|
||||||
|
@ -1080,13 +1082,10 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("CmiScanKeyForValue() failed with status %x\n", Status);
|
DPRINT("CmiScanKeyForValue() failed with status %x\n", Status);
|
||||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
goto ByeBye;
|
||||||
KeLeaveCriticalRegion();
|
|
||||||
ObDereferenceObject(KeyObject);
|
|
||||||
return(Status);
|
|
||||||
}
|
}
|
||||||
else if (ValueCell != NULL)
|
|
||||||
{
|
Status = STATUS_SUCCESS;
|
||||||
switch (KeyValueInformationClass)
|
switch (KeyValueInformationClass)
|
||||||
{
|
{
|
||||||
case KeyValueBasicInformation:
|
case KeyValueBasicInformation:
|
||||||
|
@ -1206,16 +1205,14 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT1("Not handling 0x%x\n", KeyValueInformationClass);
|
DPRINT1("Not handling 0x%x\n", KeyValueInformationClass);
|
||||||
|
Status = STATUS_INVALID_INFO_CLASS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ByeBye:;
|
||||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
ObDereferenceObject(KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
|
@ -1274,17 +1271,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
||||||
ValueName,
|
ValueName,
|
||||||
&ValueCell,
|
&ValueCell,
|
||||||
&ValueCellOffset);
|
&ValueCellOffset);
|
||||||
if (!NT_SUCCESS(Status))
|
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||||
{
|
|
||||||
DPRINT("Value not found. Status 0x%X\n", Status);
|
|
||||||
|
|
||||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
|
||||||
KeLeaveCriticalRegion();
|
|
||||||
ObDereferenceObject(KeyObject);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ValueCell == NULL)
|
|
||||||
{
|
{
|
||||||
DPRINT("Allocate new value cell\n");
|
DPRINT("Allocate new value cell\n");
|
||||||
Status = CmiAddValueToKey(RegistryHive,
|
Status = CmiAddValueToKey(RegistryHive,
|
||||||
|
@ -1305,7 +1292,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
||||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
ObDereferenceObject(KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("DataSize %lu\n", DataSize);
|
DPRINT("DataSize %lu\n", DataSize);
|
||||||
|
@ -1371,7 +1358,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
ObDereferenceObject(KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
|
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
|
||||||
|
@ -1400,7 +1387,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
||||||
|
|
||||||
DPRINT("Return Status 0x%X\n", Status);
|
DPRINT("Return Status 0x%X\n", Status);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2714,18 +2714,20 @@ CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
|
||||||
IN PKEY_CELL KeyCell,
|
IN PKEY_CELL KeyCell,
|
||||||
IN PUNICODE_STRING ValueName,
|
IN PUNICODE_STRING ValueName,
|
||||||
OUT PVALUE_CELL *ValueCell,
|
OUT PVALUE_CELL *ValueCell,
|
||||||
OUT BLOCK_OFFSET *VBOffset)
|
OUT BLOCK_OFFSET *ValueCellOffset)
|
||||||
{
|
{
|
||||||
PVALUE_LIST_CELL ValueListCell;
|
PVALUE_LIST_CELL ValueListCell;
|
||||||
PVALUE_CELL CurValueCell;
|
PVALUE_CELL CurValueCell;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
*ValueCell = NULL;
|
*ValueCell = NULL;
|
||||||
|
if (ValueCellOffset != NULL)
|
||||||
|
*ValueCellOffset = (BLOCK_OFFSET)-1;
|
||||||
|
|
||||||
/* The key does not have any values */
|
/* The key does not have any values */
|
||||||
if (KeyCell->ValueListOffset == (BLOCK_OFFSET)-1)
|
if (KeyCell->ValueListOffset == (BLOCK_OFFSET)-1)
|
||||||
{
|
{
|
||||||
return STATUS_SUCCESS;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueListCell = CmiGetCell (RegistryHive, KeyCell->ValueListOffset, NULL);
|
ValueListCell = CmiGetCell (RegistryHive, KeyCell->ValueListOffset, NULL);
|
||||||
|
@ -2755,14 +2757,14 @@ CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
|
||||||
(BOOLEAN)((CurValueCell->Flags & REG_VALUE_NAME_PACKED) ? TRUE : FALSE)))
|
(BOOLEAN)((CurValueCell->Flags & REG_VALUE_NAME_PACKED) ? TRUE : FALSE)))
|
||||||
{
|
{
|
||||||
*ValueCell = CurValueCell;
|
*ValueCell = CurValueCell;
|
||||||
if (VBOffset)
|
if (ValueCellOffset != NULL)
|
||||||
*VBOffset = ValueListCell->ValueOffset[i];
|
*ValueCellOffset = ValueListCell->ValueOffset[i];
|
||||||
//DPRINT("Found value %s\n", ValueName);
|
//DPRINT("Found value %s\n", ValueName);
|
||||||
break;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue