[ros-diffs] [fireball] 31112: - Our NtCreateKey currently allows building trees (which is incorrect) if the parent key is a symbolic link (which does exist), but if the target doesn't exist (Since the check 'does parent exist' is done Before the symlink is converted to its target. One side-effect is that although we create the CurrentControlSet symlink to ControlSet001, we never create ControlSet001. We end up creating it later during the boot by creating a sub-key, by exposing the bug in NtCreateKey. Since the new NtCreateKey uses the new parse routine code and doesn't exhibit this bug, we have to create ControlSet001 manually to avoid a failure. Other bugs of this nature may exist. Bug found and fixed by Alex. - Implement the last bit of the new parse routine (creating children) and write a new version of NtCreateKey which uses the parse routine. Disable it for now until other latent bugs are fixed.

fireball at svn.reactos.org fireball at svn.reactos.org
Sun Dec 9 20:36:04 CET 2007


Author: fireball
Date: Sun Dec  9 22:36:04 2007
New Revision: 31112

URL: http://svn.reactos.org/svn/reactos?rev=31112&view=rev
Log:
- Our NtCreateKey currently allows building trees (which is incorrect) if the parent key is a symbolic link (which does exist), but if the target doesn't exist (Since the check 'does parent exist' is done Before the symlink is converted to its target. One side-effect is that although we create the CurrentControlSet symlink to ControlSet001, we never create ControlSet001. We end up creating it later during the boot by creating a sub-key, by exposing the bug in NtCreateKey. Since the new NtCreateKey uses the new parse routine code and doesn't exhibit this bug, we have to create ControlSet001 manually to avoid a failure. Other bugs of this nature may exist. Bug found and fixed by Alex.
- Implement the last bit of the new parse routine (creating children) and write a new version of NtCreateKey which uses the parse routine. Disable it for now until other latent bugs are fixed.

Modified:
    trunk/reactos/ntoskrnl/config/cm.h
    trunk/reactos/ntoskrnl/config/cmparse.c
    trunk/reactos/ntoskrnl/config/cmsysini.c
    trunk/reactos/ntoskrnl/config/ntapi.c

Modified: trunk/reactos/ntoskrnl/config/cm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Sun Dec  9 22:36:04 2007
@@ -495,15 +495,6 @@
 //
 // BUGBUG Old Hive Stuff for Temporary Support
 //
-NTSTATUS
-NTAPI
-CmFindObject(POBJECT_CREATE_INFORMATION ObjectCreateInfo,
-             PUNICODE_STRING ObjectName,
-             PVOID* ReturnedObject,
-             PUNICODE_STRING RemainingPath,
-             POBJECT_TYPE ObjectType,
-             IN PACCESS_STATE AccessState,
-             IN PVOID ParseContext);
 NTSTATUS CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2);
 ///////////////////////////////////////////////////////////////////////////////
 

Modified: trunk/reactos/ntoskrnl/config/cmparse.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmparse.c?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmparse.c (original)
+++ trunk/reactos/ntoskrnl/config/cmparse.c Sun Dec  9 22:36:04 2007
@@ -1077,7 +1077,7 @@
     while (TRUE)
     {
         /* Get the next component */
-        Result = CmpGetNextName(&Current, &NextName, &Last); 
+        Result = CmpGetNextName(&Current, &NextName, &Last);
         if ((Result) && (NextName.Length))
         {
             /* See if this is a sym link */
@@ -1184,9 +1184,15 @@
                         }
                         else
                         {
-                            /* Create: should not see this (yet) */
-                            DPRINT1("Unexpected: Creating new child\n");
-                            while (TRUE);
+                            /* Do the create */
+                            Status = CmpDoCreate(Hive,
+                                                 Cell,
+                                                 AccessState,
+                                                 &NextName,
+                                                 AccessMode,
+                                                 ParseContext,
+                                                 ParentKcb,
+                                                 Object);
                         }
                         
                         /* Check for reparse (in this case, someone beat us) */

Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c Sun Dec  9 22:36:04 2007
@@ -363,6 +363,26 @@
         /* ReactOS Hack: Hard-code current to 001 for SetupLdr */
         if (!LoaderBlock->RegistryBase)
         {
+            /* Build the ControlSet001 key */
+            RtlInitUnicodeString(&KeyName,
+                                 L"\\Registry\\Machine\\System\\ControlSet001");
+            InitializeObjectAttributes(&ObjectAttributes,
+                                       &KeyName,
+                                       OBJ_CASE_INSENSITIVE,
+                                       NULL,
+                                       NULL);
+            Status = NtCreateKey(&KeyHandle,
+                                 KEY_ALL_ACCESS,
+                                 &ObjectAttributes,
+                                 0,
+                                 NULL,
+                                 0,
+                                 &Disposition);
+            if (!NT_SUCCESS(Status)) return Status;
+
+            /* Don't need the handle */
+            ZwClose(KeyHandle);
+
             /* Use hard-coded setting */
             ControlSet = 1;
             goto UseSet;
@@ -396,7 +416,6 @@
                                OBJ_CASE_INSENSITIVE,
                                NULL,
                                NULL);
-
     Status = NtCreateKey(&KeyHandle,
                          KEY_CREATE_LINK,
                          &ObjectAttributes,

Modified: trunk/reactos/ntoskrnl/config/ntapi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/ntapi.c (original)
+++ trunk/reactos/ntoskrnl/config/ntapi.c Sun Dec  9 22:36:04 2007
@@ -17,6 +17,42 @@
 BOOLEAN CmFirstTime = TRUE;
 
 /* FUNCTIONS *****************************************************************/
+
+#if 0
+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)
+{
+    NTSTATUS Status;
+    KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
+    CM_PARSE_CONTEXT ParseContext = {0};
+    PAGED_CODE();
+    
+    /* Setup the parse context */
+    ParseContext.CreateOperation = TRUE;
+    ParseContext.CreateOptions = CreateOptions;
+    if (Class) ParseContext.Class = *Class;
+    
+    /* Do the create */
+    Status = ObOpenObjectByName(ObjectAttributes,
+                                CmpKeyObjectType,
+                                PreviousMode,
+                                NULL,
+                                DesiredAccess,
+                                &ParseContext,
+                                KeyHandle);
+    
+    /* Return data to user */
+    if (Disposition) *Disposition = ParseContext.Disposition;
+    return Status;
+}
+#endif
 
 NTSTATUS
 NTAPI




More information about the Ros-diffs mailing list