Author: fireball Date: Sun Dec 9 00:00:45 2007 New Revision: 31094
URL: http://svn.reactos.org/svn/reactos?rev=31094&view=rev Log: - Move NtCreateKey to regobj.c, delete ntfunc.c, now all those routines exist solely for creating keys. - Move NtOpenKey to ntapi.c and rewrite it to use the new parse routine. It's now 6 lines of code instead of 80. - Fix a bug in CmpDereferenceNameCnotrolBlockWithLock. - Fix bugs during reference and dereference of KCB. - Fix KCB structure. - CmpDelayDerefKCBWorker is now called, don't make it assert anymore, just print out that it's not completed. - Remove debug output from new parse routine, since it's now called for each key open. - Add one more case to handle: opening the root \REGISTRY node. - Don't dereference KCBs in the parse routine anymore: we have some bugs related to this and it would make ReactOS crash.
Removed: trunk/reactos/ntoskrnl/cm/ntfunc.c Modified: trunk/reactos/ntoskrnl/cm/regobj.c trunk/reactos/ntoskrnl/config/cm.h trunk/reactos/ntoskrnl/config/cmdelay.c trunk/reactos/ntoskrnl/config/cmkcbncb.c trunk/reactos/ntoskrnl/config/cmparse.c trunk/reactos/ntoskrnl/config/ntapi.c trunk/reactos/ntoskrnl/ntoskrnl.rbuild
Removed: trunk/reactos/ntoskrnl/cm/ntfunc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=31... ============================================================================== --- trunk/reactos/ntoskrnl/cm/ntfunc.c (original) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c (removed) @@ -1,289 +1,0 @@ -/* - * PROJECT: ReactOS Kernel - * COPYRIGHT: GPL - See COPYING in the top level directory - * FILE: ntoskrnl/cm/ntfunc.c - * PURPOSE: Ntxxx function for registry access - * - * PROGRAMMERS: Hartmut Birr - * Casper Hornstrup - * Alex Ionescu - * Rex Jolliff - * Eric Kohl - * Filip Navara - * Thomas Weidenmueller - */ - -/* INCLUDES *****************************************************************/ - -#include <ntoskrnl.h> -#define NDEBUG -#include <internal/debug.h> - -#include "cm.h" - -/* GLOBALS ******************************************************************/ - -NTSTATUS -NTAPI -CmpCreateHandle(PVOID ObjectBody, - ACCESS_MASK GrantedAccess, - ULONG HandleAttributes, - PHANDLE HandleReturn); - -/* FUNCTIONS ****************************************************************/ - -NTSTATUS -NTAPI -NtCreateKey(OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG TitleIndex, - IN PUNICODE_STRING Class, - IN ULONG CreateOptions, - OUT PULONG Disposition) -{ - UNICODE_STRING RemainingPath = {0}, ReturnedPath = {0}; - ULONG LocalDisposition; - PCM_KEY_BODY KeyObject, Parent; - NTSTATUS Status = STATUS_SUCCESS; - UNICODE_STRING ObjectName; - OBJECT_CREATE_INFORMATION ObjectCreateInfo; - ULONG i; - KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - HANDLE hKey; - PCM_KEY_NODE Node, ParentNode; - CM_PARSE_CONTEXT ParseContext = {0}; - PAGED_CODE(); - - /* Setup the parse context */ - ParseContext.CreateOperation = TRUE; - ParseContext.CreateOptions = CreateOptions; - if (Class) ParseContext.Class = *Class; - - /* Capture all the info */ - Status = ObpCaptureObjectAttributes(ObjectAttributes, - PreviousMode, - FALSE, - &ObjectCreateInfo, - &ObjectName); - if (!NT_SUCCESS(Status)) return Status; - - /* Find the key object */ - Status = CmFindObject(&ObjectCreateInfo, - &ObjectName, - (PVOID*)&Parent, - &ReturnedPath, - CmpKeyObjectType, - NULL, - NULL); - if (!NT_SUCCESS(Status)) goto Cleanup; - - /* Check if we found the entire path */ - RemainingPath = ReturnedPath; - if (!RemainingPath.Length) - { - /* Check if the parent has been deleted */ - if (Parent->KeyControlBlock->Delete) - { - /* Fail */ - DPRINT1("Object marked for delete!\n"); - Status = STATUS_UNSUCCESSFUL; - goto Cleanup; - } - - /* Create a new handle to the parent */ - Status = CmpCreateHandle(Parent, - DesiredAccess, - ObjectCreateInfo.Attributes, - &hKey); - if (!NT_SUCCESS(Status)) goto Cleanup; - - /* Tell the caller we did this */ - LocalDisposition = REG_OPENED_EXISTING_KEY; - goto SuccessReturn; - } - - /* Loop every leading slash */ - while ((RemainingPath.Length) && - (*RemainingPath.Buffer == OBJ_NAME_PATH_SEPARATOR)) - { - /* And remove it */ - RemainingPath.Length -= sizeof(WCHAR); - RemainingPath.MaximumLength -= sizeof(WCHAR); - RemainingPath.Buffer++; - } - - /* Loop every terminating slash */ - while ((RemainingPath.Length) && - (RemainingPath.Buffer[(RemainingPath.Length / sizeof(WCHAR)) - 1] == - OBJ_NAME_PATH_SEPARATOR)) - { - /* And remove it */ - RemainingPath.Length -= sizeof(WCHAR); - RemainingPath.MaximumLength -= sizeof(WCHAR); - } - - /* Now loop the entire path */ - for (i = 0; i < RemainingPath.Length / sizeof(WCHAR); i++) - { - /* And check if we found slahes */ - if (RemainingPath.Buffer[i] == OBJ_NAME_PATH_SEPARATOR) - { - /* We don't create trees -- parent key doesn't exist, so fail */ - Status = STATUS_OBJECT_NAME_NOT_FOUND; - goto Cleanup; - } - } - - /* Now check if we're left with no name by this point */ - if (!(RemainingPath.Length) || (RemainingPath.Buffer[0] == UNICODE_NULL)) - { - /* Then fail since we can't do anything */ - Status = STATUS_OBJECT_NAME_NOT_FOUND; - goto Cleanup; - } - - /* Lock the registry */ - CmpLockRegistry(); - - /* Create the key */ - Status = CmpDoCreate(Parent->KeyControlBlock->KeyHive, - Parent->KeyControlBlock->KeyCell, - NULL, - &RemainingPath, - KernelMode, - &ParseContext, - Parent->KeyControlBlock, - (PVOID*)&KeyObject); - if (!NT_SUCCESS(Status)) goto Cleanup; - - /* If we got here, this is a new key */ - LocalDisposition = REG_CREATED_NEW_KEY; - - /* 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, - KeyObject->KeyControlBlock->KeyCell); - - /* Inherit some information */ - Node->Parent = KeyObject->KeyControlBlock->ParentKcb->KeyCell; - Node->Security = ParentNode->Security; - KeyObject->KeyControlBlock->ValueCache.ValueList = Node->ValueList.List; - KeyObject->KeyControlBlock->ValueCache.Count = Node->ValueList.Count; - - /* Link child to parent */ - InsertTailList(&Parent->KeyControlBlock->KeyBodyListHead, &KeyObject->KeyBodyList); - - /* Create the actual handle to the object */ - Status = CmpCreateHandle(KeyObject, - DesiredAccess, - ObjectCreateInfo.Attributes, - &hKey); - - /* Free the create information */ - ObpFreeAndReleaseCapturedAttributes(OBJECT_TO_OBJECT_HEADER(KeyObject)->ObjectCreateInfo); - OBJECT_TO_OBJECT_HEADER(KeyObject)->ObjectCreateInfo = NULL; - if (!NT_SUCCESS(Status)) goto Cleanup; - - /* Add the keep-alive reference */ - ObReferenceObject(KeyObject); - - /* Unlock registry */ - CmpUnlockRegistry(); - - /* Force a lazy flush */ - CmpLazyFlush(); - -SuccessReturn: - /* Return data to user */ - *KeyHandle = hKey; - if (Disposition) *Disposition = LocalDisposition; - -Cleanup: - /* Cleanup */ - ObpReleaseCapturedAttributes(&ObjectCreateInfo); - if (ObjectName.Buffer) ObpFreeObjectNameBuffer(&ObjectName); - RtlFreeUnicodeString(&ReturnedPath); - if (Parent) ObDereferenceObject(Parent); - return Status; -} - -NTSTATUS -NTAPI -NtOpenKey(OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes) -{ - UNICODE_STRING RemainingPath = {0}; - KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - PCM_KEY_BODY Object = NULL; - HANDLE hKey = NULL; - NTSTATUS Status = STATUS_SUCCESS; - UNICODE_STRING ObjectName; - OBJECT_CREATE_INFORMATION ObjectCreateInfo; - PAGED_CODE(); - - /* Capture all the info */ - Status = ObpCaptureObjectAttributes(ObjectAttributes, - PreviousMode, - FALSE, - &ObjectCreateInfo, - &ObjectName); - if (!NT_SUCCESS(Status)) return Status; - - /* Loop every terminating slash */ - while ((ObjectName.Length) && - (ObjectName.Buffer[(ObjectName.Length / sizeof(WCHAR)) - 1] == - OBJ_NAME_PATH_SEPARATOR)) - { - /* And remove it */ - ObjectName.Length -= sizeof(WCHAR); - ObjectName.MaximumLength -= sizeof(WCHAR); - } - - /* Find the key */ - Status = CmFindObject(&ObjectCreateInfo, - &ObjectName, - (PVOID*)&Object, - &RemainingPath, - CmpKeyObjectType, - NULL, - NULL); - if (!NT_SUCCESS(Status)) goto openkey_cleanup; - - /* Make sure we don't have any remaining path */ - if ((RemainingPath.Buffer) && (RemainingPath.Buffer[0] != UNICODE_NULL)) - { - /* Fail */ - Status = STATUS_OBJECT_NAME_NOT_FOUND; - goto openkey_cleanup; - } - - /* Check if the key has been deleted */ - if (Object->KeyControlBlock->Delete) - { - /* Fail */ - Status = STATUS_UNSUCCESSFUL; - goto openkey_cleanup; - } - - /* Create the actual handle */ - Status = CmpCreateHandle(Object, - DesiredAccess, - ObjectCreateInfo.Attributes, - &hKey); - -openkey_cleanup: - /* Cleanup */ - ObpReleaseCapturedAttributes(&ObjectCreateInfo); - if (ObjectName.Buffer) ObpFreeObjectNameBuffer(&ObjectName); - RtlFreeUnicodeString(&RemainingPath); - if (Object) ObDereferenceObject(Object); - - /* Return information and status to user */ - *KeyHandle = hKey; - return Status; -} - -/* EOF */
Modified: trunk/reactos/ntoskrnl/cm/regobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/regobj.c?rev=31... ============================================================================== --- trunk/reactos/ntoskrnl/cm/regobj.c (original) +++ trunk/reactos/ntoskrnl/cm/regobj.c Sun Dec 9 00:00:45 2007 @@ -875,4 +875,181 @@ return(STATUS_SUCCESS); }
+NTSTATUS +NTAPI +NtCreateKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class, + IN ULONG CreateOptions, + OUT PULONG Disposition) +{ + UNICODE_STRING RemainingPath = {0}, ReturnedPath = {0}; + ULONG LocalDisposition; + PCM_KEY_BODY KeyObject, Parent; + NTSTATUS Status = STATUS_SUCCESS; + UNICODE_STRING ObjectName; + OBJECT_CREATE_INFORMATION ObjectCreateInfo; + ULONG i; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + HANDLE hKey; + PCM_KEY_NODE Node, ParentNode; + CM_PARSE_CONTEXT ParseContext = {0}; + PAGED_CODE(); + + /* Setup the parse context */ + ParseContext.CreateOperation = TRUE; + ParseContext.CreateOptions = CreateOptions; + if (Class) ParseContext.Class = *Class; + + /* Capture all the info */ + Status = ObpCaptureObjectAttributes(ObjectAttributes, + PreviousMode, + FALSE, + &ObjectCreateInfo, + &ObjectName); + if (!NT_SUCCESS(Status)) return Status; + + /* Find the key object */ + Status = CmFindObject(&ObjectCreateInfo, + &ObjectName, + (PVOID*)&Parent, + &ReturnedPath, + CmpKeyObjectType, + NULL, + NULL); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* Check if we found the entire path */ + RemainingPath = ReturnedPath; + if (!RemainingPath.Length) + { + /* Check if the parent has been deleted */ + if (Parent->KeyControlBlock->Delete) + { + /* Fail */ + DPRINT1("Object marked for delete!\n"); + Status = STATUS_UNSUCCESSFUL; + goto Cleanup; + } + + /* Create a new handle to the parent */ + Status = CmpCreateHandle(Parent, + DesiredAccess, + ObjectCreateInfo.Attributes, + &hKey); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* Tell the caller we did this */ + LocalDisposition = REG_OPENED_EXISTING_KEY; + goto SuccessReturn; + } + + /* Loop every leading slash */ + while ((RemainingPath.Length) && + (*RemainingPath.Buffer == OBJ_NAME_PATH_SEPARATOR)) + { + /* And remove it */ + RemainingPath.Length -= sizeof(WCHAR); + RemainingPath.MaximumLength -= sizeof(WCHAR); + RemainingPath.Buffer++; + } + + /* Loop every terminating slash */ + while ((RemainingPath.Length) && + (RemainingPath.Buffer[(RemainingPath.Length / sizeof(WCHAR)) - 1] == + OBJ_NAME_PATH_SEPARATOR)) + { + /* And remove it */ + RemainingPath.Length -= sizeof(WCHAR); + RemainingPath.MaximumLength -= sizeof(WCHAR); + } + + /* Now loop the entire path */ + for (i = 0; i < RemainingPath.Length / sizeof(WCHAR); i++) + { + /* And check if we found slahes */ + if (RemainingPath.Buffer[i] == OBJ_NAME_PATH_SEPARATOR) + { + /* We don't create trees -- parent key doesn't exist, so fail */ + Status = STATUS_OBJECT_NAME_NOT_FOUND; + goto Cleanup; + } + } + + /* Now check if we're left with no name by this point */ + if (!(RemainingPath.Length) || (RemainingPath.Buffer[0] == UNICODE_NULL)) + { + /* Then fail since we can't do anything */ + Status = STATUS_OBJECT_NAME_NOT_FOUND; + goto Cleanup; + } + + /* Lock the registry */ + CmpLockRegistry(); + + /* Create the key */ + Status = CmpDoCreate(Parent->KeyControlBlock->KeyHive, + Parent->KeyControlBlock->KeyCell, + NULL, + &RemainingPath, + KernelMode, + &ParseContext, + Parent->KeyControlBlock, + (PVOID*)&KeyObject); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* If we got here, this is a new key */ + LocalDisposition = REG_CREATED_NEW_KEY; + + /* 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, + KeyObject->KeyControlBlock->KeyCell); + + /* Inherit some information */ + Node->Parent = KeyObject->KeyControlBlock->ParentKcb->KeyCell; + Node->Security = ParentNode->Security; + KeyObject->KeyControlBlock->ValueCache.ValueList = Node->ValueList.List; + KeyObject->KeyControlBlock->ValueCache.Count = Node->ValueList.Count; + + /* Link child to parent */ + InsertTailList(&Parent->KeyControlBlock->KeyBodyListHead, &KeyObject->KeyBodyList); + + /* Create the actual handle to the object */ + Status = CmpCreateHandle(KeyObject, + DesiredAccess, + ObjectCreateInfo.Attributes, + &hKey); + + /* Free the create information */ + ObpFreeAndReleaseCapturedAttributes(OBJECT_TO_OBJECT_HEADER(KeyObject)->ObjectCreateInfo); + OBJECT_TO_OBJECT_HEADER(KeyObject)->ObjectCreateInfo = NULL; + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* Add the keep-alive reference */ + ObReferenceObject(KeyObject); + + /* Unlock registry */ + CmpUnlockRegistry(); + + /* Force a lazy flush */ + CmpLazyFlush(); + +SuccessReturn: + /* Return data to user */ + *KeyHandle = hKey; + if (Disposition) *Disposition = LocalDisposition; + +Cleanup: + /* Cleanup */ + ObpReleaseCapturedAttributes(&ObjectCreateInfo); + if (ObjectName.Buffer) ObpFreeObjectNameBuffer(&ObjectName); + RtlFreeUnicodeString(&ReturnedPath); + if (Parent) ObDereferenceObject(Parent); + return Status; +} + /* EOF */
Modified: trunk/reactos/ntoskrnl/config/cm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=31... ============================================================================== --- trunk/reactos/ntoskrnl/config/cm.h (original) +++ trunk/reactos/ntoskrnl/config/cm.h Sun Dec 9 00:00:45 2007 @@ -231,11 +231,14 @@ { USHORT RefCount; USHORT Flags; - ULONG ExtFlags:8; - ULONG PrivateAlloc:1; - ULONG Delete:1; - ULONG DelayedCloseIndex:12; - ULONG TotalLevels:10; + struct + { + ULONG ExtFlags:8; + ULONG PrivateAlloc:1; + ULONG Delete:1; + ULONG DelayedCloseIndex:12; + ULONG TotalLevels:10; + }; union { CM_KEY_HASH KeyHash; @@ -251,9 +254,12 @@ PCM_NAME_CONTROL_BLOCK NameBlock; PCM_KEY_SECURITY_CACHE CachedSecurity; CACHED_CHILD_LIST ValueCache; - PCM_INDEX_HINT_BLOCK IndexHint; - ULONG HashKey; - ULONG SubKeyCount; + union + { + PCM_INDEX_HINT_BLOCK IndexHint; + ULONG HashKey; + ULONG SubKeyCount; + }; union { LIST_ENTRY KeyBodyListHead;
Modified: trunk/reactos/ntoskrnl/config/cmdelay.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmdelay.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmdelay.c (original) +++ trunk/reactos/ntoskrnl/config/cmdelay.c Sun Dec 9 00:00:45 2007 @@ -107,6 +107,8 @@ ASSERT(CmpDelayDerefKCBWorkItemActive);
/* FIXME: TODO */ + DPRINT1("CmpDelayDerefKCBWorker has work to do!\n"); + return; ASSERT(FALSE); }
@@ -307,3 +309,4 @@ }
+
Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmkcbncb.c (original) +++ trunk/reactos/ntoskrnl/config/cmkcbncb.c Sun Dec 9 00:00:45 2007 @@ -312,9 +312,10 @@ CmpDereferenceNameControlBlockWithLock(IN PCM_NAME_CONTROL_BLOCK Ncb) { PCM_NAME_HASH Current, *Next; + ULONG ConvKey = Ncb->ConvKey;
/* Lock the NCB */ - CmpAcquireNcbLockExclusive(Ncb); + CmpAcquireNcbLockExclusiveByKey(ConvKey);
/* Decrease the reference count */ if (!(--Ncb->RefCount)) @@ -342,7 +343,7 @@ }
/* Release the lock */ - CmpReleaseNcbLock(Ncb); + CmpReleaseNcbLockByKey(ConvKey); }
BOOLEAN @@ -363,13 +364,13 @@
/* Increase the reference count while we release the lock */ InterlockedIncrement((PLONG)&Kcb->RefCount); - + /* Go from shared to exclusive */ CmpConvertKcbSharedToExclusive(Kcb);
/* Decrement the reference count; the lock is now held again */ InterlockedDecrement((PLONG)&Kcb->RefCount); - + /* Check if we still control the index */ if (Kcb->DelayedCloseIndex == 1) { @@ -387,7 +388,7 @@ }
/* Increase the reference count */ - if (InterlockedIncrement((PLONG)&Kcb->RefCount) == 0) + if ((InterlockedIncrement((PLONG)&Kcb->RefCount) & 0xFFFF) == 0) { /* We've overflown to 64K references, bail out */ InterlockedDecrement((PLONG)&Kcb->RefCount); @@ -511,9 +512,9 @@ /* Get the ref count and update it */ OldRefCount = *(PLONG)&Kcb->RefCount; NewRefCount = OldRefCount - 1; - - /* Check if we still have refenreces */ - if( (NewRefCount & 0xffff) > 0) + + /* Check if we still have references */ + if( (NewRefCount & 0xFFFF) > 0) { /* Do the dereference */ if (InterlockedCompareExchange((PLONG)&Kcb->RefCount, @@ -544,7 +545,7 @@ (CmpTestRegistryLockExclusive() == TRUE));
/* Check if this is the last reference */ - if (InterlockedDecrement((PLONG)&Kcb->RefCount) == 0) + if ((InterlockedDecrement((PLONG)&Kcb->RefCount) & 0xFFFF) == 0) { /* Check if we should do a direct delete */ if (((CmpHoldLazyFlush) && @@ -783,7 +784,7 @@ } } } - + /* Sanity check */ ASSERT((!Kcb) || (Kcb->Delete == FALSE));
@@ -821,3 +822,4 @@ /* FIXME: Implement once we don't link parents to children anymore */ }
+
Modified: trunk/reactos/ntoskrnl/config/cmparse.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmparse.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmparse.c (original) +++ trunk/reactos/ntoskrnl/config/cmparse.c Sun Dec 9 00:00:45 2007 @@ -782,7 +782,7 @@ /* Release it */ HvReleaseCell(Context->ChildHive.KeyHive, ChildCell);
- /* Set the parent adn flags */ + /* Set the parent and flags */ KeyNode->Parent = LinkCell; KeyNode->Flags |= KEY_HIVE_ENTRY | KEY_NO_DELETE;
@@ -977,7 +977,6 @@ PULONG LockedKcbs = NULL; BOOLEAN Result, Last; PAGED_CODE(); - DPRINT1("New style parse routine called: %wZ %wZ!\n", CompleteName, RemainingName);
/* Loop path separators at the end */ while ((RemainingName->Length) && @@ -1003,7 +1002,6 @@
/* Grab the KCB */ Kcb = ((PCM_KEY_BODY)ParseObject)->KeyControlBlock; - DPRINT1("KCB Parse: %p\n", Kcb);
/* Lookup in the cache */ Status = CmpBuildHashStackAndLookupCache(ParseObject, @@ -1019,9 +1017,6 @@
/* This is now the parent */ ParentKcb = Kcb; - DPRINT1("ParentKcb Parse: %p\n", ParentKcb); - DPRINT1("Hive Parse: %p\n", Hive); - DPRINT1("Cell Parse: %p\n", Cell);
/* Check if everything was found cached */ if (!TotalRemainingSubkeys) ASSERTMSG("Caching not implemented", FALSE); @@ -1032,9 +1027,6 @@ /* Check if this is a symlink */ if (Kcb->Flags & KEY_SYM_LINK) { - DPRINT1("Parsing sym link: %lx %lx %lx\n", Kcb->Flags, Status, - CompleteName); - /* Get the next name */ Result = CmpGetNextName(&Current, &NextName, &Last); Current.Buffer = NextName.Buffer; @@ -1071,10 +1063,6 @@ /* Couldn't find symlink */ Status = STATUS_OBJECT_NAME_NOT_FOUND; } - - /* Not implemented */ - DPRINT1("Parsing sym link: %lx %wZ %wZ\n", Status, - CompleteName, &Current);
/* We're done */ goto Quickie; @@ -1083,7 +1071,6 @@ /* Get the key node */ Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!Node) return STATUS_INSUFFICIENT_RESOURCES; - DPRINT1("Node Parse: %p\n", Node);
/* Start parsing */ Status = STATUS_NOT_IMPLEMENTED; @@ -1091,7 +1078,6 @@ { /* Get the next component */ Result = CmpGetNextName(&Current, &NextName, &Last); - DPRINT1("Result Parse: %p\n", Result); if ((Result) && (NextName.Length)) { /* See if this is a sym link */ @@ -1099,13 +1085,11 @@ { /* Find the subkey */ NextCell = CmpFindSubKeyByName(Hive, Node, &NextName); - DPRINT1("NextCell Parse: %lx %wZ\n", NextCell, &NextName); if (NextCell != HCELL_NIL) { /* Get the new node */ Cell = NextCell; Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell); - DPRINT1("Node Parse: %p\n", Node); if (!Node) ASSERT(FALSE);
/* Check if this was the last key */ @@ -1115,13 +1099,11 @@ if (Node->Flags & KEY_HIVE_EXIT) { /* Handle it */ - DPRINT1("Exit node\n"); CmpHandleExitNode(&Hive, &Cell, &Node, &HiveToRelease, &CellToRelease); - DPRINT1("Node Parse: %p\n", Node); if (!Node) ASSERT(FALSE); }
@@ -1139,9 +1121,6 @@ Object); if (Status == STATUS_REPARSE) { - DPRINT1("Parsing sym link: %lx %lx\n", Status, - CompleteName); - /* Parse the symlink */ if (!CmpGetSymbolicLink(Hive, CompleteName, @@ -1151,15 +1130,9 @@ /* Symlink parse failed */ Status = STATUS_OBJECT_NAME_NOT_FOUND; } - - /* Not implemented */ - DPRINT1("Parsing sym link: %lx %wZ\n", Status, - CompleteName); - while (TRUE); }
/* We are done */ - DPRINT1("Open of last key\n"); break; }
@@ -1167,13 +1140,11 @@ if (Node->Flags & KEY_HIVE_EXIT) { /* Handle it */ - DPRINT1("Exit node: %lx\n", Node->Flags); CmpHandleExitNode(&Hive, &Cell, &Node, &HiveToRelease, &CellToRelease); - DPRINT1("Node Parse: %p\n", Node); if (!Node) ASSERT(FALSE); }
@@ -1185,10 +1156,9 @@ 0, &NextName); if (!Kcb) ASSERT(FALSE); - DPRINT1("Kcb Parse: %p\n", Kcb);
/* Dereference the parent and set the new one */ - CmpDereferenceKeyControlBlock(ParentKcb); + //CmpDereferenceKeyControlBlock(ParentKcb); ParentKcb = Kcb; } else @@ -1211,7 +1181,6 @@ ParseContext, ParentKcb, Object); - DPRINT1("Link created: %lx\n", Status); } else { @@ -1242,9 +1211,6 @@ } else { - DPRINT1("Parsing sym link: %lx %lx\n", Status, - CompleteName); - /* Save the next name */ Current.Buffer = NextName.Buffer;
@@ -1280,20 +1246,47 @@ /* Couldn't find symlink */ Status = STATUS_OBJECT_NAME_NOT_FOUND; } - - /* Not implemented */ - DPRINT1("Parsing sym link: %lx %wZ %wZ\n", Status, - CompleteName, &Current); - + /* We're done */ break; } } else if ((Result) && (Last)) { - /* Opening root: unexpected */ - DPRINT1("Unexpected: Opening root\n"); - while (TRUE); + /* Opening the root. Is this an exit node? */ + if (Node->Flags & KEY_HIVE_EXIT) + { + /* Handle it */ + CmpHandleExitNode(&Hive, + &Cell, + &Node, + &HiveToRelease, + &CellToRelease); + if (!Node) ASSERT(FALSE); + } + + /* FIXME: This hack seems required? */ + RtlInitUnicodeString(&NextName, L"\REGISTRY"); + + /* Do the open */ + Status = CmpDoOpen(Hive, + Cell, + Node, + AccessState, + AccessMode, + Attributes, + ParseContext, + 0, + &Kcb, + &NextName, + Object); + if (Status == STATUS_REPARSE) + { + /* Nothing to do */ + } + + /* We're done */ + break; } else { @@ -1305,7 +1298,7 @@
/* Dereference the parent if it exists */ Quickie: - if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb); + //if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb);
/* Unlock the registry */ CmpUnlockRegistry();
Modified: trunk/reactos/ntoskrnl/config/ntapi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/config/ntapi.c (original) +++ trunk/reactos/ntoskrnl/config/ntapi.c Sun Dec 9 00:00:45 2007 @@ -17,6 +17,25 @@ BOOLEAN CmFirstTime = TRUE;
/* FUNCTIONS *****************************************************************/ + +NTSTATUS +NTAPI +NtOpenKey(OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes) +{ + CM_PARSE_CONTEXT ParseContext = {0}; + PAGED_CODE(); + + /* Just let the object manager handle this */ + return ObOpenObjectByName(ObjectAttributes, + CmpKeyObjectType, + ExGetPreviousMode(), + NULL, + DesiredAccess, + &ParseContext, + KeyHandle); +}
NTSTATUS NTAPI @@ -472,26 +491,10 @@
NTSTATUS NTAPI -NtCompactKeys(IN ULONG Count, - IN PHANDLE KeyArray) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -NTAPI -NtCompressKey(IN HANDLE Key) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -NTAPI NtLoadKey(IN POBJECT_ATTRIBUTES KeyObjectAttributes, IN POBJECT_ATTRIBUTES FileObjectAttributes) { + /* Call the newer API */ return NtLoadKey2(KeyObjectAttributes, FileObjectAttributes, 0); }
@@ -501,6 +504,7 @@ IN POBJECT_ATTRIBUTES FileObjectAttributes, IN ULONG Flags) { + /* Call the newer API */ return NtLoadKeyEx(KeyObjectAttributes, FileObjectAttributes, Flags, NULL); }
@@ -553,6 +557,34 @@
/* Return status */ return Status; +} + +NTSTATUS +NTAPI +NtNotifyChangeKey(IN HANDLE KeyHandle, + IN HANDLE Event, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG CompletionFilter, + IN BOOLEAN WatchTree, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN Asynchronous) +{ + /* Call the newer API */ + return NtNotifyChangeMultipleKeys(KeyHandle, + 0, + NULL, + Event, + ApcRoutine, + ApcContext, + IoStatusBlock, + CompletionFilter, + WatchTree, + Buffer, + Length, + Asynchronous); }
NTSTATUS @@ -619,6 +651,23 @@
NTSTATUS NTAPI +NtCompactKeys(IN ULONG Count, + IN PHANDLE KeyArray) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +NtCompressKey(IN HANDLE Key) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI NtLockProductActivationKeys(IN PULONG pPrivateVer, IN PULONG pSafeMode) { @@ -655,33 +704,6 @@
NTSTATUS NTAPI -NtNotifyChangeKey(IN HANDLE KeyHandle, - IN HANDLE Event, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG CompletionFilter, - IN BOOLEAN WatchTree, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN Asynchronous) -{ - return NtNotifyChangeMultipleKeys(KeyHandle, - 0, - NULL, - Event, - ApcRoutine, - ApcContext, - IoStatusBlock, - CompletionFilter, - WatchTree, - Buffer, - Length, - Asynchronous); -} - -NTSTATUS -NTAPI NtQueryMultipleValueKey(IN HANDLE KeyHandle, IN OUT PKEY_VALUE_ENTRY ValueList, IN ULONG NumberOfValues,
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?re... ============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Sun Dec 9 00:00:45 2007 @@ -139,7 +139,6 @@ <file>ntapi.c</file> </directory> <directory name="cm"> - <file>ntfunc.c</file> <file>regobj.c</file> </directory> <directory name="dbgk">