mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Use the parents registry hive if the parent is accessed in CmiRemoveSubKey.
svn path=/trunk/; revision=5937
This commit is contained in:
parent
72bb12e96c
commit
5a6cf4163c
1 changed files with 117 additions and 43 deletions
|
@ -1998,40 +1998,78 @@ CmiFlushRegistryHive(PREGISTRY_HIVE RegistryHive)
|
|||
|
||||
|
||||
ULONG
|
||||
CmiGetMaxNameLength(PREGISTRY_HIVE RegistryHive,
|
||||
PKEY_CELL KeyCell)
|
||||
CmiGetMaxNameLength(PKEY_OBJECT KeyObject)
|
||||
{
|
||||
PHASH_TABLE_CELL HashBlock;
|
||||
PKEY_OBJECT CurKey;
|
||||
PKEY_CELL CurSubKeyCell;
|
||||
PKEY_CELL KeyCell;
|
||||
ULONG MaxName;
|
||||
ULONG NameSize;
|
||||
ULONG i;
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
KeyCell = KeyObject->KeyCell;
|
||||
VERIFY_KEY_CELL(KeyCell);
|
||||
|
||||
MaxName = 0;
|
||||
HashBlock = CmiGetBlock(RegistryHive, KeyCell->HashTableOffset, NULL);
|
||||
HashBlock = CmiGetBlock(KeyObject->RegistryHive,
|
||||
KeyCell->HashTableOffset,
|
||||
NULL);
|
||||
if (HashBlock == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (i = 0; i < HashBlock->HashTableSize; i++)
|
||||
{
|
||||
if (HashBlock->Table[i].KeyOffset != 0)
|
||||
{
|
||||
CurSubKeyCell = CmiGetBlock(RegistryHive,
|
||||
CurSubKeyCell = CmiGetBlock(KeyObject->RegistryHive,
|
||||
HashBlock->Table[i].KeyOffset,
|
||||
NULL);
|
||||
if (CurSubKeyCell == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
return 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (MaxName < CurSubKeyCell->NameSize)
|
||||
NameSize = CurSubKeyCell->NameSize;
|
||||
if (CurSubKeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
MaxName = CurSubKeyCell->NameSize;
|
||||
NameSize *= sizeof(WCHAR);
|
||||
}
|
||||
if (MaxName < NameSize)
|
||||
{
|
||||
MaxName = NameSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (KeyObject->RegistryHive != CmiVolatileHive)
|
||||
{
|
||||
DPRINT("KeyObject->NumberOfSubKeys %d\n", KeyObject->NumberOfSubKeys);
|
||||
for (i = 0; i < KeyObject->NumberOfSubKeys; i++)
|
||||
{
|
||||
CurKey = KeyObject->SubKeys[i];
|
||||
if (CurKey->RegistryHive == CmiVolatileHive)
|
||||
{
|
||||
CurSubKeyCell = CurKey->KeyCell;
|
||||
if (CurSubKeyCell == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
continue;
|
||||
}
|
||||
NameSize = CurSubKeyCell->NameSize;
|
||||
if (CurSubKeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
NameSize *= sizeof(WCHAR);
|
||||
}
|
||||
if (MaxName < NameSize)
|
||||
{
|
||||
MaxName = NameSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2041,35 +2079,41 @@ CmiGetMaxNameLength(PREGISTRY_HIVE RegistryHive,
|
|||
|
||||
|
||||
ULONG
|
||||
CmiGetMaxClassLength(PREGISTRY_HIVE RegistryHive,
|
||||
PKEY_CELL KeyCell)
|
||||
CmiGetMaxClassLength(PKEY_OBJECT KeyObject)
|
||||
{
|
||||
PHASH_TABLE_CELL HashBlock;
|
||||
PKEY_OBJECT CurKey;
|
||||
PKEY_CELL CurSubKeyCell;
|
||||
PKEY_CELL KeyCell;
|
||||
ULONG MaxClass;
|
||||
ULONG i;
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
KeyCell = KeyObject->KeyCell;
|
||||
VERIFY_KEY_CELL(KeyCell);
|
||||
|
||||
MaxClass = 0;
|
||||
HashBlock = CmiGetBlock(RegistryHive, KeyCell->HashTableOffset, NULL);
|
||||
HashBlock = CmiGetBlock(KeyObject->RegistryHive,
|
||||
KeyCell->HashTableOffset,
|
||||
NULL);
|
||||
if (HashBlock == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (i = 0; i < HashBlock->HashTableSize; i++)
|
||||
{
|
||||
if (HashBlock->Table[i].KeyOffset != 0)
|
||||
{
|
||||
CurSubKeyCell = CmiGetBlock(RegistryHive,
|
||||
CurSubKeyCell = CmiGetBlock(KeyObject->RegistryHive,
|
||||
HashBlock->Table[i].KeyOffset,
|
||||
NULL);
|
||||
if (CurSubKeyCell == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
return 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (MaxClass < CurSubKeyCell->ClassSize)
|
||||
|
@ -2078,6 +2122,28 @@ CmiGetMaxClassLength(PREGISTRY_HIVE RegistryHive,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (KeyObject->RegistryHive != CmiVolatileHive)
|
||||
{
|
||||
DPRINT("KeyObject->NumberOfSubKeys %d\n", KeyObject->NumberOfSubKeys);
|
||||
for (i = 0; i < KeyObject->NumberOfSubKeys; i++)
|
||||
{
|
||||
CurKey = KeyObject->SubKeys[i];
|
||||
if (CurKey->RegistryHive == CmiVolatileHive)
|
||||
{
|
||||
CurSubKeyCell = CurKey->KeyCell;
|
||||
if (CurSubKeyCell == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
continue;
|
||||
}
|
||||
if (MaxClass < CurSubKeyCell->ClassSize)
|
||||
{
|
||||
MaxClass = CurSubKeyCell->ClassSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MaxClass;
|
||||
}
|
||||
|
@ -2090,6 +2156,7 @@ CmiGetMaxValueNameLength(PREGISTRY_HIVE RegistryHive,
|
|||
PVALUE_LIST_CELL ValueListCell;
|
||||
PVALUE_CELL CurValueCell;
|
||||
ULONG MaxValueName;
|
||||
ULONG Size;
|
||||
ULONG i;
|
||||
|
||||
VERIFY_KEY_CELL(KeyCell);
|
||||
|
@ -2114,10 +2181,17 @@ CmiGetMaxValueNameLength(PREGISTRY_HIVE RegistryHive,
|
|||
DPRINT("CmiGetBlock() failed\n");
|
||||
}
|
||||
|
||||
if (CurValueCell != NULL &&
|
||||
MaxValueName < CurValueCell->NameSize)
|
||||
if (CurValueCell != NULL)
|
||||
{
|
||||
MaxValueName = CurValueCell->NameSize;
|
||||
Size = CurValueCell->NameSize;
|
||||
if (CurValueCell->Flags & REG_VALUE_NAME_PACKED)
|
||||
{
|
||||
Size *= sizeof(WCHAR);
|
||||
}
|
||||
if (MaxValueName < Size)
|
||||
{
|
||||
MaxValueName = Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2519,7 +2593,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
|
|||
if (ParentKey->KeyCell->HashTableOffset != (BLOCK_OFFSET) -1)
|
||||
{
|
||||
DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
|
||||
HashBlock = CmiGetBlock(RegistryHive,
|
||||
HashBlock = CmiGetBlock(ParentKey->RegistryHive,
|
||||
ParentKey->KeyCell->HashTableOffset,
|
||||
NULL);
|
||||
if (HashBlock == NULL)
|
||||
|
@ -2530,10 +2604,10 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
|
|||
DPRINT("ParentKey HashBlock %p\n", HashBlock)
|
||||
if (HashBlock != NULL)
|
||||
{
|
||||
CmiRemoveKeyFromHashTable(RegistryHive,
|
||||
CmiRemoveKeyFromHashTable(ParentKey->RegistryHive,
|
||||
HashBlock,
|
||||
SubKey->BlockOffset);
|
||||
CmiMarkBlockDirty(RegistryHive,
|
||||
CmiMarkBlockDirty(ParentKey->RegistryHive,
|
||||
ParentKey->KeyCell->HashTableOffset);
|
||||
}
|
||||
}
|
||||
|
@ -2570,7 +2644,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
|
|||
if (ParentKey->KeyCell->NumberOfSubKeys == 0)
|
||||
{
|
||||
DPRINT("ParentKey HashTableOffset %lx\n", ParentKey->KeyCell->HashTableOffset)
|
||||
HashBlock = CmiGetBlock(RegistryHive,
|
||||
HashBlock = CmiGetBlock(ParentKey->RegistryHive,
|
||||
ParentKey->KeyCell->HashTableOffset,
|
||||
NULL);
|
||||
if (HashBlock == NULL)
|
||||
|
@ -2581,7 +2655,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
|
|||
DPRINT("ParentKey HashBlock %p\n", HashBlock)
|
||||
if (HashBlock != NULL)
|
||||
{
|
||||
CmiDestroyBlock(RegistryHive,
|
||||
CmiDestroyBlock(ParentKey->RegistryHive,
|
||||
HashBlock,
|
||||
ParentKey->KeyCell->HashTableOffset);
|
||||
ParentKey->KeyCell->HashTableOffset = -1;
|
||||
|
@ -2589,7 +2663,7 @@ CmiRemoveSubKey(PREGISTRY_HIVE RegistryHive,
|
|||
}
|
||||
|
||||
NtQuerySystemTime(&ParentKey->KeyCell->LastWriteTime);
|
||||
CmiMarkBlockDirty(RegistryHive,
|
||||
CmiMarkBlockDirty(ParentKey->RegistryHive,
|
||||
ParentKey->BlockOffset);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue