Author: fireball
Date: Thu Dec 6 22:46:59 2007
New Revision: 31047
URL:
http://svn.reactos.org/svn/reactos?rev=31047&view=rev
Log:
- Rewrite CmiScanKeyList to use the NCB.
- Disable private KCB allocator and allocate separate pool entries for each KCB -- should
fix issues some people have been experiencing until the real bug is found
- Remove all code that builds the name for the PKEY_OBJECT. This reduces non-paged pool
allocation usage since the name is now stored compressed in the NCB, in paged pool.
Modified:
trunk/reactos/ntoskrnl/cm/ntfunc.c
trunk/reactos/ntoskrnl/cm/regobj.c
trunk/reactos/ntoskrnl/config/cm.h
trunk/reactos/ntoskrnl/config/cmalloc.c
trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/cm/ntfunc.c (original)
+++ trunk/reactos/ntoskrnl/cm/ntfunc.c Thu Dec 6 22:46:59 2007
@@ -160,13 +160,7 @@
/* If we got here, this is a new key */
LocalDisposition = REG_CREATED_NEW_KEY;
- /* Now save the key name */
- RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
- &RemainingPath,
- &KeyObject->Name);
-
/* Get the parent node and the child node */
-
ParentNode =
(PCM_KEY_NODE)HvGetCell(KeyObject->KeyControlBlock->ParentKcb->KeyHive,
KeyObject->KeyControlBlock->ParentKcb->KeyCell);
Node = (PCM_KEY_NODE)HvGetCell(KeyObject->KeyControlBlock->KeyHive,
Modified: trunk/reactos/ntoskrnl/cm/regobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/regobj.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/cm/regobj.c (original)
+++ trunk/reactos/ntoskrnl/cm/regobj.c Thu Dec 6 22:46:59 2007
@@ -436,7 +436,6 @@
return STATUS_SUCCESS;
}
-
/* Preconditions: Must be called with CmpRegistryLock held. */
NTSTATUS
CmiScanKeyList(PCM_KEY_CONTROL_BLOCK Parent,
@@ -445,48 +444,74 @@
PKEY_OBJECT* ReturnedObject)
{
PKEY_OBJECT CurKey = NULL;
+ PCM_NAME_CONTROL_BLOCK Ncb;
PLIST_ENTRY NextEntry;
-
+ PWCHAR p, pp;
+ ULONG i;
+ *ReturnedObject = NULL;
+
+ /* Loop child keys in the KCB */
NextEntry = Parent->KeyBodyListHead.Flink;
while (NextEntry != &Parent->KeyBodyListHead)
{
+ /* Get the current ReactOS Key Object */
CurKey = CONTAINING_RECORD(NextEntry, KEY_OBJECT, KeyBodyEntry);
- if (Attributes & OBJ_CASE_INSENSITIVE)
- {
- DPRINT("Comparing %wZ and %wZ\n", KeyName, &CurKey->Name);
- if ((KeyName->Length == CurKey->Name.Length)
- && (_wcsicmp(KeyName->Buffer, CurKey->Name.Buffer) == 0))
+
+ /* Get the NCB */
+ Ncb = CurKey->KeyControlBlock->NameBlock;
+
+ /* Check if the key is compressed */
+ if (Ncb->Compressed)
+ {
+ /* Do a compressed compare */
+ if (!CmpCompareCompressedName(KeyName,
+ Ncb->Name,
+ Ncb->NameLength))
{
+ /* We got it */
break;
}
}
else
{
- if ((KeyName->Length == CurKey->Name.Length)
- && (wcscmp(KeyName->Buffer, CurKey->Name.Buffer) == 0))
+ /* Do a manual compare */
+ p = KeyName->Buffer;
+ pp = Ncb->Name;
+ for (i = 0; i < Ncb->NameLength; i += sizeof(WCHAR))
{
+ /* Compare the character */
+ if (RtlUpcaseUnicodeChar(*p) != RtlUpcaseUnicodeChar(*pp))
+ {
+ /* Failed */
+ break;
+ }
+
+ /* Next chars */
+ p++;
+ pp++;
+ }
+
+ /* Did we find it? */
+ if (i == Ncb->NameLength - 1)
+ {
+ /* We found it, break out */
break;
}
}
+ /* Go go the next entry */
NextEntry = NextEntry->Flink;
}
+ /* Check if we got here and found something */
if (NextEntry != &Parent->KeyBodyListHead)
{
- if (CurKey->KeyControlBlock->Delete)
- {
- CHECKPOINT;
- *ReturnedObject = NULL;
- return STATUS_UNSUCCESSFUL;
- }
+ /* Refernece the object and return it */
ObReferenceObject(CurKey);
*ReturnedObject = CurKey;
}
- else
- {
- *ReturnedObject = NULL;
- }
+
+ /* Return success */
return STATUS_SUCCESS;
}
@@ -719,7 +744,6 @@
FoundObject->KeyControlBlock = Kcb;
ASSERT(FoundObject->KeyControlBlock->KeyHive ==
ParsedKey->KeyControlBlock->KeyHive);
- RtlpCreateUnicodeString(&FoundObject->Name, KeyName.Buffer,
NonPagedPool);
InsertTailList(&ParsedKey->KeyControlBlock->KeyBodyListHead,
&FoundObject->KeyBodyEntry);
DPRINT("Created object 0x%p\n", FoundObject);
}
@@ -783,8 +807,6 @@
ExReleaseResourceLite(&CmpRegistryLock);
KeLeaveCriticalRegion();
- DPRINT("CmpParseKey: %wZ\n", &FoundObject->Name);
-
*Path = EndPtr;
VERIFY_KEY_OBJECT(FoundObject);
@@ -823,8 +845,6 @@
/* Acquire hive lock */
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
-
- RtlFreeUnicodeString(&KeyObject->Name);
ASSERT((KeyObject->KeyControlBlock->Delete) == FALSE);
@@ -845,61 +865,6 @@
{
DPRINT1("CmpQueryKeyName() called\n");
while (TRUE);
-#if 0
- PKEY_OBJECT KeyObject;
- NTSTATUS Status;
-
- KeyObject = (PKEY_OBJECT)ObjectBody;
-
- if (KeyObject->KeyControlBlock->ParentKcb != KeyObject->KeyControlBlock)
- {
- Status = ObQueryNameString (KeyObject->ParentKey,
- ObjectNameInfo,
- Length,
- ReturnLength);
- }
- else
- {
- /* KeyObject is the root key */
- Status = ObQueryNameString
(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(KeyObject))->Directory,
- ObjectNameInfo,
- Length,
- ReturnLength);
- }
-
- if (!NT_SUCCESS(Status) && Status != STATUS_INFO_LENGTH_MISMATCH)
- {
- return Status;
- }
- (*ReturnLength) += sizeof(WCHAR) + KeyObject->Name.Length;
-
- if (Status == STATUS_INFO_LENGTH_MISMATCH || *ReturnLength > Length)
- {
- return STATUS_INFO_LENGTH_MISMATCH;
- }
-
- if (ObjectNameInfo->Name.Buffer == NULL)
- {
- ObjectNameInfo->Name.Buffer = (PWCHAR)(ObjectNameInfo + 1);
- ObjectNameInfo->Name.Length = 0;
- ObjectNameInfo->Name.MaximumLength = (USHORT)Length -
sizeof(OBJECT_NAME_INFORMATION);
- }
-
- DPRINT ("Parent path: %wZ\n", ObjectNameInfo->Name);
-
- Status = RtlAppendUnicodeToString (&ObjectNameInfo->Name,
- L"\\");
- if (!NT_SUCCESS (Status))
- return Status;
-
- Status = RtlAppendUnicodeStringToString (&ObjectNameInfo->Name,
- &KeyObject->Name);
- if (NT_SUCCESS (Status))
- {
- DPRINT ("Total path: %wZ\n", &ObjectNameInfo->Name);
- }
-#endif
-
return STATUS_SUCCESS;
}
Modified: trunk/reactos/ntoskrnl/config/cm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Thu Dec 6 22:46:59 2007
@@ -492,8 +492,6 @@
//
typedef struct _KEY_OBJECT
{
- ULONG Type;
- UNICODE_STRING Name;
PCM_KEY_CONTROL_BLOCK KeyControlBlock;
LIST_ENTRY KeyBodyEntry;
} KEY_OBJECT, *PKEY_OBJECT;
Modified: trunk/reactos/ntoskrnl/config/cmalloc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmalloc.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmalloc.c (original)
+++ trunk/reactos/ntoskrnl/config/cmalloc.c Thu Dec 6 22:46:59 2007
@@ -116,9 +116,9 @@
PCM_ALLOC_PAGE AllocPage;
ULONG i;
PAGED_CODE();
-
+
/* Check if private allocations are initialized */
- if (CmpAllocInited)
+ if (FALSE)
{
/* They are, acquire the bucket lock */
KeAcquireGuardedMutex(&CmpAllocBucketLock);
@@ -178,7 +178,7 @@
goto SearchKcbList;
}
}
-
+
/* Allocate a KCB only */
CurrentKcb = ExAllocatePoolWithTag(PagedPool,
sizeof(CM_KEY_CONTROL_BLOCK),
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c Thu Dec 6 22:46:59 2007
@@ -604,12 +604,7 @@
/* Update KCB information */
NewKey->KeyControlBlock->KeyCell =
RegistryHive->Hive.BaseBlock->RootCell;
NewKey->KeyControlBlock->KeyHive = &RegistryHive->Hive;
-
- /* Build the key name */
- RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
- &RemainingPath,
- &NewKey->Name);
-
+
/* Reference the new key */
ObReferenceObject(NewKey);
@@ -900,13 +895,11 @@
if (!Kcb) return FALSE;
/* Initialize the object */
- RootKey->Type = TAG('k', 'v', '0', '2');
RootKey->KeyControlBlock = Kcb;
#if 0
+ RootKey->Type = TAG('k', 'v', '0', '2');
RootKey->NotifyBlock = NULL;
RootKey->ProcessID = PsGetCurrentProcessId();
-#else
- RtlpCreateUnicodeString(&RootKey->Name, L"Registry", NonPagedPool);
#endif
/* Insert the key into the namespace */