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
|
@ -631,6 +631,7 @@ CmiScanKeyForValue(IN PREGISTRY_FILE RegistryFile,
|
||||||
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;
|
||||||
|
@ -672,6 +673,7 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_FILE RegistryFile,
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -734,18 +736,22 @@ 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
|
||||||
|
@ -1099,6 +1109,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -1204,6 +1216,7 @@ 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,7 +1234,7 @@ CmiLockBlock(PREGISTRY_FILE RegistryFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
VOID
|
||||||
CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
|
CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
|
||||||
PVOID Block)
|
PVOID Block)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -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);
|
||||||
|
@ -190,6 +191,7 @@ 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,
|
||||||
|
@ -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