Fixed registry bug.

svn path=/trunk/; revision=2510
This commit is contained in:
Eric Kohl 2002-01-14 04:51:15 +00:00
parent 13b04f00b5
commit d2b345f07d
2 changed files with 67 additions and 51 deletions

View file

@ -631,6 +631,7 @@ CmiScanKeyForValue(IN PREGISTRY_FILE RegistryFile,
ULONG Idx;
PVALUE_LIST_BLOCK ValueListBlock;
PVALUE_BLOCK CurValueBlock;
ValueListBlock = CmiGetBlock(RegistryFile,
KeyBlock->ValuesOffset,NULL);
*ValueBlock = NULL;
@ -672,6 +673,7 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_FILE RegistryFile,
{
PVALUE_LIST_BLOCK ValueListBlock;
PVALUE_BLOCK CurValueBlock;
ValueListBlock = CmiGetBlock(RegistryFile,
KeyBlock->ValuesOffset,NULL);
*ValueBlock = NULL;
@ -733,19 +735,23 @@ CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
}
KeyBlock->ValuesOffset = VLBOffset;
}
else if ( KeyBlock->NumberOfValues
>= -(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET))
else if (KeyBlock->NumberOfValues
>= ((LONG)(ValueListBlock->SubBlockSize-4))/(LONG)sizeof(BLOCK_OFFSET))
// >= -(ValueListBlock->SubBlockSize-4)/sizeof(BLOCK_OFFSET))
{
DPRINT1("\n");
Status = CmiAllocateBlock(RegistryFile,
(PVOID) &NewValueListBlock,
sizeof(BLOCK_OFFSET) *
(KeyBlock->NumberOfValues +
REG_VALUE_LIST_BLOCK_MULTIPLE),&VLBOffset);
REG_VALUE_LIST_BLOCK_MULTIPLE),
&VLBOffset);
if (!NT_SUCCESS(Status))
{
CmiDestroyValueBlock(RegistryFile,
NewValueBlock,VBOffset);
return Status;
NewValueBlock,
VBOffset);
return(Status);
}
RtlCopyMemory(&NewValueListBlock->Values[0],
&ValueListBlock->Values[0],
@ -754,13 +760,17 @@ CmiAddValueToKey(IN PREGISTRY_FILE RegistryFile,
KeyBlock->ValuesOffset = VLBOffset;
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;
KeyBlock->NumberOfValues++;
CmiReleaseBlock(RegistryFile, ValueListBlock);
CmiReleaseBlock(RegistryFile, NewValueBlock);
*pValueBlock = NewValueBlock;
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
NTSTATUS
@ -1099,6 +1109,7 @@ CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
else
{
PFREE_SUB_BLOCK pFree = Block;
if (pFree->SubBlockSize <0)
pFree->SubBlockSize = -pFree->SubBlockSize;
CmiAddFree(RegistryFile,Block,Offset);
@ -1106,7 +1117,7 @@ CmiDestroyBlock(PREGISTRY_FILE RegistryFile,
/* update time of heap */
if(RegistryFile->Filename && CmiGetBlock(RegistryFile, Offset,&pHeap))
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 */
}
@ -1195,7 +1206,8 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
BLOCK_OFFSET BlockOffset,
OUT PHEAP_BLOCK * ppHeap)
{
if( BlockOffset == 0 || BlockOffset == -1) return NULL;
if( BlockOffset == 0 || BlockOffset == -1)
return NULL;
if (RegistryFile->Filename == NULL)
{
@ -1204,6 +1216,7 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
else
{
PHEAP_BLOCK pHeap;
pHeap = RegistryFile->BlockList[BlockOffset/4096];
if(ppHeap) *ppHeap = pHeap;
return ((char *)pHeap
@ -1211,7 +1224,7 @@ CmiGetBlock(PREGISTRY_FILE RegistryFile,
}
}
void
VOID
CmiLockBlock(PREGISTRY_FILE RegistryFile,
PVOID Block)
{
@ -1221,7 +1234,7 @@ CmiLockBlock(PREGISTRY_FILE RegistryFile,
}
}
void
VOID
CmiReleaseBlock(PREGISTRY_FILE RegistryFile,
PVOID Block)
{

View file

@ -96,6 +96,7 @@ DPRINT("CmiObjectParse %s\n",cPath);
FoundObject->BlockOffset = BlockOffset;
FoundObject->RegistryFile = ParsedKey->RegistryFile;
CmiAddKeyToList(ParsedKey,FoundObject);
DPRINT("CmiObjectParse(): created object 0x%x\n",FoundObject);
}
else
ObReferenceObjectByPointer(FoundObject,
@ -150,7 +151,7 @@ CmiObjectDelete(PVOID DeletedObject)
{
PKEY_OBJECT KeyObject;
DPRINT("delete object key\n");
DPRINT("delete object key\n");
KeyObject = (PKEY_OBJECT) DeletedObject;
if(!NT_SUCCESS(CmiRemoveKeyFromList(KeyObject)))
{
@ -158,7 +159,7 @@ DPRINT("delete object key\n");
}
if (KeyObject->Flags & KO_MARKED_FOR_DELETE)
{
DPRINT1("delete really key\n");
DPRINT("delete really key\n");
CmiDestroyBlock(KeyObject->RegistryFile,
KeyObject->KeyBlock,
KeyObject->BlockOffset);
@ -190,6 +191,7 @@ CmiAddKeyToList(PKEY_OBJECT ParentKey,PKEY_OBJECT NewKey)
/* FIXME : please maintain the list in alphabetic order */
/* to allow a dichotomic search */
ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey;
DPRINT("Reference parent key: 0x%x\n", ParentKey);
ObReferenceObjectByPointer(ParentKey,
STANDARD_RIGHTS_REQUIRED,
NULL,
@ -218,6 +220,7 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove)
,(ParentKey->NumberOfSubKeys-Index-1)*sizeof(PKEY_OBJECT));
ParentKey->NumberOfSubKeys--;
KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
DPRINT("Dereference parent key: 0x%x\n",ParentKey);
ObDereferenceObject(ParentKey);
return STATUS_SUCCESS;
}