mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed wrong interpretation of value cell size in NtSetValueKey().
svn path=/trunk/; revision=3105
This commit is contained in:
parent
7c5d3bb9ef
commit
e6b5136b65
2 changed files with 93 additions and 93 deletions
|
@ -124,11 +124,11 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
||||||
CreateOptions);
|
CreateOptions);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ObDereferenceObject(KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
ObDereferenceObject(Object);
|
ObDereferenceObject(Object);
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyObject->Name = KeyObject->KeyCell->Name;
|
KeyObject->Name = KeyObject->KeyCell->Name;
|
||||||
KeyObject->NameSize = KeyObject->KeyCell->NameSize;
|
KeyObject->NameSize = KeyObject->KeyCell->NameSize;
|
||||||
|
@ -1193,16 +1193,16 @@ NtSetValueKey(
|
||||||
IN PVOID Data,
|
IN PVOID Data,
|
||||||
IN ULONG DataSize)
|
IN ULONG DataSize)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKEY_OBJECT KeyObject;
|
PKEY_OBJECT KeyObject;
|
||||||
PREGISTRY_HIVE RegistryHive;
|
PREGISTRY_HIVE RegistryHive;
|
||||||
PKEY_CELL KeyCell;
|
PKEY_CELL KeyCell;
|
||||||
PVALUE_CELL ValueCell;
|
PVALUE_CELL ValueCell;
|
||||||
BLOCK_OFFSET VBOffset;
|
BLOCK_OFFSET VBOffset;
|
||||||
char ValueName2[MAX_PATH];
|
char ValueName2[MAX_PATH];
|
||||||
PDATA_CELL DataCell;
|
PDATA_CELL DataCell;
|
||||||
PDATA_CELL NewDataCell;
|
PDATA_CELL NewDataCell;
|
||||||
PHBIN pBin;
|
PHBIN pBin;
|
||||||
// KIRQL OldIrql;
|
// KIRQL OldIrql;
|
||||||
|
|
||||||
DPRINT("KeyHandle %x ValueName %S Type %d\n",
|
DPRINT("KeyHandle %x ValueName %S Type %d\n",
|
||||||
|
@ -1218,9 +1218,8 @@ NtSetValueKey(
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID *) &KeyObject,
|
(PVOID *) &KeyObject,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return(Status);
|
||||||
|
|
||||||
VERIFY_KEY_OBJECT(KeyObject);
|
VERIFY_KEY_OBJECT(KeyObject);
|
||||||
|
|
||||||
|
@ -1228,103 +1227,104 @@ NtSetValueKey(
|
||||||
KeyCell = KeyObject->KeyCell;
|
KeyCell = KeyObject->KeyCell;
|
||||||
RegistryHive = KeyObject->RegistryHive;
|
RegistryHive = KeyObject->RegistryHive;
|
||||||
Status = CmiScanKeyForValue(RegistryHive,
|
Status = CmiScanKeyForValue(RegistryHive,
|
||||||
KeyCell,
|
KeyCell,
|
||||||
ValueName2,
|
ValueName2,
|
||||||
&ValueCell,
|
&ValueCell,
|
||||||
&VBOffset);
|
&VBOffset);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Value not found. Status 0x%X\n", Status);
|
DPRINT1("Value not found. Status 0x%X\n", Status);
|
||||||
|
|
||||||
ObDereferenceObject(KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
return Status;
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeAcquireSpinLock(&RegistryHive->RegLock, &OldIrql);
|
// KeAcquireSpinLock(&RegistryHive->RegLock, &OldIrql);
|
||||||
|
|
||||||
if (ValueCell == NULL)
|
if (ValueCell == NULL)
|
||||||
{
|
{
|
||||||
Status = CmiAddValueToKey(RegistryHive,
|
Status = CmiAddValueToKey(RegistryHive,
|
||||||
KeyCell,
|
KeyCell,
|
||||||
ValueName2,
|
ValueName2,
|
||||||
&ValueCell,
|
&ValueCell,
|
||||||
&VBOffset);
|
&VBOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Cannot add value. Status 0x%X\n", Status);
|
DPRINT1("Cannot add value. Status 0x%X\n", Status);
|
||||||
ObDereferenceObject(KeyObject);
|
|
||||||
return Status;
|
ObDereferenceObject(KeyObject);
|
||||||
}
|
return(Status);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT("DataSize (%d)\n", DataSize);
|
DPRINT("DataSize (%d)\n", DataSize);
|
||||||
|
|
||||||
/* If datasize <= 4 then write in valueblock directly */
|
/* If datasize <= 4 then write in valueblock directly */
|
||||||
if (DataSize <= 4)
|
if (DataSize <= 4)
|
||||||
{
|
{
|
||||||
if ((ValueCell->DataSize < 0)
|
DPRINT("ValueCell->DataSize %lu\n", ValueCell->DataSize);
|
||||||
&& (DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL)))
|
if ((ValueCell->DataSize >= 0) &&
|
||||||
{
|
(DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL)))
|
||||||
CmiDestroyBlock(RegistryHive, DataCell, ValueCell->DataOffset);
|
{
|
||||||
}
|
CmiDestroyBlock(RegistryHive, DataCell, ValueCell->DataOffset);
|
||||||
|
}
|
||||||
|
|
||||||
RtlCopyMemory(&ValueCell->DataOffset, Data, DataSize);
|
RtlCopyMemory(&ValueCell->DataOffset, Data, DataSize);
|
||||||
ValueCell->DataSize = DataSize | 0x80000000;
|
ValueCell->DataSize = DataSize | 0x80000000;
|
||||||
ValueCell->DataType = Type;
|
ValueCell->DataType = Type;
|
||||||
RtlMoveMemory(&ValueCell->DataOffset, Data, DataSize);
|
RtlMoveMemory(&ValueCell->DataOffset, Data, DataSize);
|
||||||
}
|
}
|
||||||
/* If new data size is <= current then overwrite current data */
|
/* If new data size is <= current then overwrite current data */
|
||||||
else if (DataSize <= (ValueCell->DataSize & 0x7fffffff))
|
else if (DataSize <= (ValueCell->DataSize & 0x7fffffff))
|
||||||
{
|
{
|
||||||
DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset,&pBin);
|
DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset,&pBin);
|
||||||
RtlCopyMemory(DataCell->Data, Data, DataSize);
|
RtlCopyMemory(DataCell->Data, Data, DataSize);
|
||||||
ValueCell->DataSize = DataSize;
|
ValueCell->DataSize = DataSize;
|
||||||
ValueCell->DataType = Type;
|
ValueCell->DataType = Type;
|
||||||
CmiReleaseBlock(RegistryHive, DataCell);
|
CmiReleaseBlock(RegistryHive, DataCell);
|
||||||
/* Update time of heap */
|
/* Update time of heap */
|
||||||
if (IsPermanentHive(RegistryHive))
|
if (IsPermanentHive(RegistryHive))
|
||||||
{
|
{
|
||||||
ZwQuerySystemTime((PTIME) &pBin->DateModified);
|
ZwQuerySystemTime((PTIME) &pBin->DateModified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BLOCK_OFFSET NewOffset;
|
BLOCK_OFFSET NewOffset;
|
||||||
|
|
||||||
/* Destroy current data block and allocate a new one */
|
/* Destroy current data block and allocate a new one */
|
||||||
if ((ValueCell->DataSize < 0)
|
if ((ValueCell->DataSize >= 0) &&
|
||||||
&& (DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL)))
|
(DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL)))
|
||||||
{
|
{
|
||||||
CmiDestroyBlock(RegistryHive, DataCell, ValueCell->DataOffset);
|
CmiDestroyBlock(RegistryHive, DataCell, ValueCell->DataOffset);
|
||||||
}
|
}
|
||||||
Status = CmiAllocateBlock(RegistryHive,
|
Status = CmiAllocateBlock(RegistryHive,
|
||||||
(PVOID *) &NewDataCell,
|
(PVOID *)&NewDataCell,
|
||||||
DataSize,
|
DataSize,
|
||||||
&NewOffset);
|
&NewOffset);
|
||||||
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
|
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
|
||||||
ValueCell->DataSize = DataSize;
|
ValueCell->DataSize = DataSize;
|
||||||
ValueCell->DataType = Type;
|
ValueCell->DataType = Type;
|
||||||
CmiReleaseBlock(RegistryHive, NewDataCell);
|
CmiReleaseBlock(RegistryHive, NewDataCell);
|
||||||
ValueCell->DataOffset = NewOffset;
|
ValueCell->DataOffset = NewOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update time of heap */
|
/* Update time of heap */
|
||||||
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin))
|
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin))
|
||||||
{
|
{
|
||||||
ZwQuerySystemTime((PTIME) &pBin->DateModified);
|
ZwQuerySystemTime((PTIME) &pBin->DateModified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeReleaseSpinLock(&RegistryHive->RegLock, OldIrql);
|
// KeReleaseSpinLock(&RegistryHive->RegLock, OldIrql);
|
||||||
|
|
||||||
ObDereferenceObject (KeyObject);
|
ObDereferenceObject(KeyObject);
|
||||||
|
|
||||||
DPRINT("Return Status 0x%X\n", Status);
|
DPRINT("Return Status 0x%X\n", Status);
|
||||||
|
|
||||||
return Status;
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -621,7 +621,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue