mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 02:13:36 +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;
|
||||
|
||||
default:
|
||||
DPRINT1("Not handling 0x%x\n", KeyInformationClass);
|
||||
Status = STATUS_INVALID_INFO_CLASS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1059,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ObReferenceObjectByHandle() failed with status %x\n", Status);
|
||||
DPRINT1("ObReferenceObjectByHandle() failed with status %x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1071,7 +1073,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
KeyCell = KeyObject->KeyCell;
|
||||
RegistryHive = KeyObject->RegistryHive;
|
||||
|
||||
/* Get Value block of interest */
|
||||
/* Get value cell by name */
|
||||
Status = CmiScanKeyForValue(RegistryHive,
|
||||
KeyCell,
|
||||
ValueName,
|
||||
|
@ -1080,13 +1082,10 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("CmiScanKeyForValue() failed with status %x\n", Status);
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return(Status);
|
||||
goto ByeBye;
|
||||
}
|
||||
else if (ValueCell != NULL)
|
||||
{
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
switch (KeyValueInformationClass)
|
||||
{
|
||||
case KeyValueBasicInformation:
|
||||
|
@ -1206,16 +1205,14 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("Not handling 0x%x\n", KeyValueInformationClass);
|
||||
Status = STATUS_INVALID_INFO_CLASS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
ByeBye:;
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -1274,17 +1271,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
ValueName,
|
||||
&ValueCell,
|
||||
&ValueCellOffset);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Value not found. Status 0x%X\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (ValueCell == NULL)
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
{
|
||||
DPRINT("Allocate new value cell\n");
|
||||
Status = CmiAddValueToKey(RegistryHive,
|
||||
|
@ -1305,7 +1292,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("DataSize %lu\n", DataSize);
|
||||
|
@ -1371,7 +1358,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
|
||||
|
@ -1400,7 +1387,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
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 PUNICODE_STRING ValueName,
|
||||
OUT PVALUE_CELL *ValueCell,
|
||||
OUT BLOCK_OFFSET *VBOffset)
|
||||
OUT BLOCK_OFFSET *ValueCellOffset)
|
||||
{
|
||||
PVALUE_LIST_CELL ValueListCell;
|
||||
PVALUE_CELL CurValueCell;
|
||||
ULONG i;
|
||||
|
||||
*ValueCell = NULL;
|
||||
if (ValueCellOffset != NULL)
|
||||
*ValueCellOffset = (BLOCK_OFFSET)-1;
|
||||
|
||||
/* The key does not have any values */
|
||||
if (KeyCell->ValueListOffset == (BLOCK_OFFSET)-1)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
ValueListCell = CmiGetCell (RegistryHive, KeyCell->ValueListOffset, NULL);
|
||||
|
@ -2755,14 +2757,14 @@ CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
|
|||
(BOOLEAN)((CurValueCell->Flags & REG_VALUE_NAME_PACKED) ? TRUE : FALSE)))
|
||||
{
|
||||
*ValueCell = CurValueCell;
|
||||
if (VBOffset)
|
||||
*VBOffset = ValueListCell->ValueOffset[i];
|
||||
if (ValueCellOffset != NULL)
|
||||
*ValueCellOffset = ValueListCell->ValueOffset[i];
|
||||
//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