mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed registry bug.
svn path=/trunk/; revision=2510
This commit is contained in:
parent
13b04f00b5
commit
d2b345f07d
2 changed files with 67 additions and 51 deletions
|
@ -628,9 +628,10 @@ CmiScanKeyForValue(IN PREGISTRY_FILE RegistryFile,
|
||||||
OUT BLOCK_OFFSET *VBOffset)
|
OUT BLOCK_OFFSET *VBOffset)
|
||||||
{
|
{
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
ULONG Idx;
|
ULONG Idx;
|
||||||
PVALUE_LIST_BLOCK ValueListBlock;
|
PVALUE_LIST_BLOCK ValueListBlock;
|
||||||
PVALUE_BLOCK CurValueBlock;
|
PVALUE_BLOCK CurValueBlock;
|
||||||
|
|
||||||
ValueListBlock = CmiGetBlock(RegistryFile,
|
ValueListBlock = CmiGetBlock(RegistryFile,
|
||||||
KeyBlock->ValuesOffset,NULL);
|
KeyBlock->ValuesOffset,NULL);
|
||||||
*ValueBlock = NULL;
|
*ValueBlock = NULL;
|
||||||
|
@ -670,8 +671,9 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_FILE RegistryFile,
|
||||||
IN ULONG Index,
|
IN ULONG Index,
|
||||||
OUT PVALUE_BLOCK *ValueBlock)
|
OUT PVALUE_BLOCK *ValueBlock)
|
||||||
{
|
{
|
||||||
PVALUE_LIST_BLOCK ValueListBlock;
|
PVALUE_LIST_BLOCK ValueListBlock;
|
||||||
PVALUE_BLOCK CurValueBlock;
|
PVALUE_BLOCK CurValueBlock;
|
||||||
|
|
||||||
ValueListBlock = CmiGetBlock(RegistryFile,
|
ValueListBlock = CmiGetBlock(RegistryFile,
|
||||||
KeyBlock->ValuesOffset,NULL);
|
KeyBlock->ValuesOffset,NULL);
|
||||||
*ValueBlock = NULL;
|
*ValueBlock = NULL;
|
||||||
|
@ -697,16 +699,16 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_FILE RegistryFile,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
|
CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
IN PKEY_BLOCK KeyBlock,
|
IN PKEY_BLOCK KeyBlock,
|
||||||
IN PCHAR ValueNameBuf,
|
IN PCHAR ValueNameBuf,
|
||||||
OUT PVALUE_BLOCK *pValueBlock,
|
OUT PVALUE_BLOCK *pValueBlock,
|
||||||
OUT BLOCK_OFFSET *pVBOffset)
|
OUT BLOCK_OFFSET *pVBOffset)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVALUE_LIST_BLOCK ValueListBlock, NewValueListBlock;
|
PVALUE_LIST_BLOCK ValueListBlock, NewValueListBlock;
|
||||||
BLOCK_OFFSET VBOffset;
|
BLOCK_OFFSET VBOffset;
|
||||||
BLOCK_OFFSET VLBOffset;
|
BLOCK_OFFSET VLBOffset;
|
||||||
PVALUE_BLOCK NewValueBlock;
|
PVALUE_BLOCK NewValueBlock;
|
||||||
|
|
||||||
Status = CmiAllocateValueBlock(RegistryFile,
|
Status = CmiAllocateValueBlock(RegistryFile,
|
||||||
&NewValueBlock,
|
&NewValueBlock,
|
||||||
|
@ -733,19 +735,23 @@ CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
KeyBlock->ValuesOffset = VLBOffset;
|
KeyBlock->ValuesOffset = VLBOffset;
|
||||||
}
|
}
|
||||||
else if ( KeyBlock->NumberOfValues
|
else if (KeyBlock->NumberOfValues
|
||||||
>= -(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET))
|
>= ((LONG)(ValueListBlock->SubBlockSize-4))/(LONG)sizeof(BLOCK_OFFSET))
|
||||||
|
// >= -(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET))
|
||||||
{
|
{
|
||||||
|
DPRINT1("\n");
|
||||||
Status = CmiAllocateBlock(RegistryFile,
|
Status = CmiAllocateBlock(RegistryFile,
|
||||||
(PVOID) &NewValueListBlock,
|
(PVOID) &NewValueListBlock,
|
||||||
sizeof(BLOCK_OFFSET) *
|
sizeof(BLOCK_OFFSET) *
|
||||||
(KeyBlock->NumberOfValues +
|
(KeyBlock->NumberOfValues +
|
||||||
REG_VALUE_LIST_BLOCK_MULTIPLE),&VLBOffset);
|
REG_VALUE_LIST_BLOCK_MULTIPLE),
|
||||||
|
&VLBOffset);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CmiDestroyValueBlock(RegistryFile,
|
CmiDestroyValueBlock(RegistryFile,
|
||||||
NewValueBlock,VBOffset);
|
NewValueBlock,
|
||||||
return Status;
|
VBOffset);
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
RtlCopyMemory(&NewValueListBlock->Values[0],
|
RtlCopyMemory(&NewValueListBlock->Values[0],
|
||||||
&ValueListBlock->Values[0],
|
&ValueListBlock->Values[0],
|
||||||
|
@ -754,13 +760,17 @@ CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
|
||||||
KeyBlock->ValuesOffset = VLBOffset;
|
KeyBlock->ValuesOffset = VLBOffset;
|
||||||
ValueListBlock = NewValueListBlock;
|
ValueListBlock = NewValueListBlock;
|
||||||
}
|
}
|
||||||
|
DPRINT1("KeyBlock->NumberOfValues %d, ValueListBlock->SubBlockSize %d (%d %x)\n",
|
||||||
|
KeyBlock->NumberOfValues, ValueListBlock->SubBlockSize,
|
||||||
|
-(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET),
|
||||||
|
-(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET));
|
||||||
ValueListBlock->Values[KeyBlock->NumberOfValues] = VBOffset;
|
ValueListBlock->Values[KeyBlock->NumberOfValues] = VBOffset;
|
||||||
KeyBlock->NumberOfValues++;
|
KeyBlock->NumberOfValues++;
|
||||||
CmiReleaseBlock(RegistryFile, ValueListBlock);
|
CmiReleaseBlock(RegistryFile, ValueListBlock);
|
||||||
CmiReleaseBlock(RegistryFile, NewValueBlock);
|
CmiReleaseBlock(RegistryFile, NewValueBlock);
|
||||||
*pValueBlock = NewValueBlock;
|
*pValueBlock = NewValueBlock;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -820,9 +830,9 @@ CmiAllocateHashTableBlock(IN PREGISTRY_FILE RegistryFile,
|
||||||
OUT BLOCK_OFFSET *HBOffset,
|
OUT BLOCK_OFFSET *HBOffset,
|
||||||
IN ULONG HashTableSize)
|
IN ULONG HashTableSize)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG NewHashSize;
|
ULONG NewHashSize;
|
||||||
PHASH_TABLE_BLOCK NewHashBlock;
|
PHASH_TABLE_BLOCK NewHashBlock;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
*HashBlock = NULL;
|
*HashBlock = NULL;
|
||||||
|
@ -1086,8 +1096,8 @@ NTSTATUS
|
||||||
CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
|
CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
|
||||||
PVOID Block,BLOCK_OFFSET Offset)
|
PVOID Block,BLOCK_OFFSET Offset)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PHEAP_BLOCK pHeap;
|
PHEAP_BLOCK pHeap;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -1098,7 +1108,8 @@ CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PFREE_SUB_BLOCK pFree = Block;
|
PFREE_SUB_BLOCK pFree = Block;
|
||||||
|
|
||||||
if (pFree->SubBlockSize <0)
|
if (pFree->SubBlockSize <0)
|
||||||
pFree->SubBlockSize = -pFree->SubBlockSize;
|
pFree->SubBlockSize = -pFree->SubBlockSize;
|
||||||
CmiAddFree(RegistryFile,Block,Offset);
|
CmiAddFree(RegistryFile,Block,Offset);
|
||||||
|
@ -1106,7 +1117,7 @@ CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
|
||||||
/* update time of heap */
|
/* update time of heap */
|
||||||
if(RegistryFile->Filename && CmiGetBlock(RegistryFile, Offset,&pHeap))
|
if(RegistryFile->Filename && CmiGetBlock(RegistryFile, Offset,&pHeap))
|
||||||
ZwQuerySystemTime((PTIME) &pHeap->DateModified);
|
ZwQuerySystemTime((PTIME) &pHeap->DateModified);
|
||||||
/* FIXME : set first dword to block_offset of another free bloc ? */
|
/* FIXME : set first dword to block_offset of another free block ? */
|
||||||
/* FIXME : concatenate with previous and next block if free */
|
/* FIXME : concatenate with previous and next block if free */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1206,8 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
|
||||||
BLOCK_OFFSET BlockOffset,
|
BLOCK_OFFSET BlockOffset,
|
||||||
OUT PHEAP_BLOCK * ppHeap)
|
OUT PHEAP_BLOCK * ppHeap)
|
||||||
{
|
{
|
||||||
if( BlockOffset == 0 || BlockOffset == -1) return NULL;
|
if( BlockOffset == 0 || BlockOffset == -1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (RegistryFile->Filename == NULL)
|
if (RegistryFile->Filename == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1203,7 +1215,8 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PHEAP_BLOCK pHeap;
|
PHEAP_BLOCK pHeap;
|
||||||
|
|
||||||
pHeap = RegistryFile->BlockList[BlockOffset/4096];
|
pHeap = RegistryFile->BlockList[BlockOffset/4096];
|
||||||
if(ppHeap) *ppHeap = pHeap;
|
if(ppHeap) *ppHeap = pHeap;
|
||||||
return ((char *)pHeap
|
return ((char *)pHeap
|
||||||
|
@ -1211,7 +1224,7 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
VOID
|
||||||
CmiLockBlock(PREGISTRY_FILE RegistryFile,
|
CmiLockBlock(PREGISTRY_FILE RegistryFile,
|
||||||
PVOID Block)
|
PVOID Block)
|
||||||
{
|
{
|
||||||
|
@ -1221,9 +1234,9 @@ CmiLockBlock(PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
VOID
|
||||||
CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
|
CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
|
||||||
PVOID Block)
|
PVOID Block)
|
||||||
{
|
{
|
||||||
if (RegistryFile->Filename != NULL)
|
if (RegistryFile->Filename != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,7 @@ DPRINT("CmiObjectParse %s\n",cPath);
|
||||||
FoundObject->BlockOffset = BlockOffset;
|
FoundObject->BlockOffset = BlockOffset;
|
||||||
FoundObject->RegistryFile = ParsedKey->RegistryFile;
|
FoundObject->RegistryFile = ParsedKey->RegistryFile;
|
||||||
CmiAddKeyToList(ParsedKey,FoundObject);
|
CmiAddKeyToList(ParsedKey,FoundObject);
|
||||||
|
DPRINT("CmiObjectParse(): created object 0x%x\n",FoundObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ObReferenceObjectByPointer(FoundObject,
|
ObReferenceObjectByPointer(FoundObject,
|
||||||
|
@ -150,7 +151,7 @@ CmiObjectDelete(PVOID DeletedObject)
|
||||||
{
|
{
|
||||||
PKEY_OBJECT KeyObject;
|
PKEY_OBJECT KeyObject;
|
||||||
|
|
||||||
DPRINT("delete object key\n");
|
DPRINT("delete object key\n");
|
||||||
KeyObject = (PKEY_OBJECT) DeletedObject;
|
KeyObject = (PKEY_OBJECT) DeletedObject;
|
||||||
if(!NT_SUCCESS(CmiRemoveKeyFromList(KeyObject)))
|
if(!NT_SUCCESS(CmiRemoveKeyFromList(KeyObject)))
|
||||||
{
|
{
|
||||||
|
@ -158,7 +159,7 @@ DPRINT("delete object key\n");
|
||||||
}
|
}
|
||||||
if (KeyObject->Flags & KO_MARKED_FOR_DELETE)
|
if (KeyObject->Flags & KO_MARKED_FOR_DELETE)
|
||||||
{
|
{
|
||||||
DPRINT1("delete really key\n");
|
DPRINT("delete really key\n");
|
||||||
CmiDestroyBlock(KeyObject->RegistryFile,
|
CmiDestroyBlock(KeyObject->RegistryFile,
|
||||||
KeyObject->KeyBlock,
|
KeyObject->KeyBlock,
|
||||||
KeyObject->BlockOffset);
|
KeyObject->BlockOffset);
|
||||||
|
@ -173,7 +174,7 @@ DPRINT1("delete really key\n");
|
||||||
void
|
void
|
||||||
CmiAddKeyToList(PKEY_OBJECT ParentKey,PKEY_OBJECT NewKey)
|
CmiAddKeyToList(PKEY_OBJECT ParentKey,PKEY_OBJECT NewKey)
|
||||||
{
|
{
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
|
||||||
KeAcquireSpinLock(&CmiKeyListLock, &OldIrql);
|
KeAcquireSpinLock(&CmiKeyListLock, &OldIrql);
|
||||||
if (ParentKey->SizeOfSubKeys <= ParentKey->NumberOfSubKeys)
|
if (ParentKey->SizeOfSubKeys <= ParentKey->NumberOfSubKeys)
|
||||||
|
@ -190,10 +191,11 @@ CmiAddKeyToList(PKEY_OBJECT ParentKey,PKEY_OBJECT NewKey)
|
||||||
/* FIXME : please maintain the list in alphabetic order */
|
/* FIXME : please maintain the list in alphabetic order */
|
||||||
/* to allow a dichotomic search */
|
/* to allow a dichotomic search */
|
||||||
ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey;
|
ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey;
|
||||||
|
DPRINT("Reference parent key: 0x%x\n", ParentKey);
|
||||||
ObReferenceObjectByPointer(ParentKey,
|
ObReferenceObjectByPointer(ParentKey,
|
||||||
STANDARD_RIGHTS_REQUIRED,
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
NULL,
|
NULL,
|
||||||
UserMode);
|
UserMode);
|
||||||
NewKey->ParentKey = ParentKey;
|
NewKey->ParentKey = ParentKey;
|
||||||
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
|
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
|
||||||
}
|
}
|
||||||
|
@ -218,6 +220,7 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove)
|
||||||
,(ParentKey->NumberOfSubKeys-Index-1)*sizeof(PKEY_OBJECT));
|
,(ParentKey->NumberOfSubKeys-Index-1)*sizeof(PKEY_OBJECT));
|
||||||
ParentKey->NumberOfSubKeys--;
|
ParentKey->NumberOfSubKeys--;
|
||||||
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
|
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
|
||||||
|
DPRINT("Dereference parent key: 0x%x\n",ParentKey);
|
||||||
ObDereferenceObject(ParentKey);
|
ObDereferenceObject(ParentKey);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue