forget update de.rc
[reactos.git] / reactos / ntoskrnl / cm / regobj.c
index 4a5ffa8..b824c85 100644 (file)
@@ -1,5 +1,5 @@
 /* $Id$
- * 
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/cm/regobj.c
@@ -176,6 +176,15 @@ CmiObjectParse(PVOID ParsedObject,
          RtlFreeUnicodeString(&KeyName);
          return(Status);
        }
+    DPRINT("Inserting Key into Object Tree\n");
+    Status =  ObInsertObject((PVOID)FoundObject,
+                             NULL,
+                             KEY_ALL_ACCESS,
+                             0,
+                             NULL,
+                             NULL);
+    DPRINT("Status %x\n", Status);
+
       /* Add the keep-alive reference */
       ObReferenceObject(FoundObject);
 
@@ -187,7 +196,7 @@ CmiObjectParse(PVOID ParsedObject,
       RtlpCreateUnicodeString(&FoundObject->Name,
               KeyName.Buffer, NonPagedPool);
       CmiAddKeyToList(ParsedKey, FoundObject);
-      DPRINT("Created object 0x%x\n", FoundObject);
+      DPRINT("Created object 0x%p\n", FoundObject);
     }
   else
     {
@@ -203,7 +212,7 @@ CmiObjectParse(PVOID ParsedObject,
          if (NT_SUCCESS(Status))
            {
              DPRINT("LinkPath '%wZ'\n", &LinkPath);
-       
+
               ExReleaseResourceLite(&CmiRegistryLock);
               KeLeaveCriticalRegion();
 
@@ -263,35 +272,6 @@ CmiObjectParse(PVOID ParsedObject,
   return(STATUS_SUCCESS);
 }
 
-
-NTSTATUS STDCALL
-CmiObjectCreate(PVOID ObjectBody,
-               PVOID Parent,
-               PWSTR RemainingPath,
-               POBJECT_ATTRIBUTES ObjectAttributes)
-{
-  PKEY_OBJECT KeyObject = ObjectBody;
-  PWSTR Start;
-
-  KeyObject->ParentKey = Parent;
-  if (RemainingPath)
-    {
-      Start = RemainingPath;
-      if(*Start == L'\\')
-       Start++;
-      RtlpCreateUnicodeString(&KeyObject->Name,
-              Start, NonPagedPool);
-    }
-   else
-    {
-      RtlInitUnicodeString(&KeyObject->Name,
-                          NULL);
-    }
-
-  return STATUS_SUCCESS;
-}
-
-
 VOID STDCALL
 CmiObjectDelete(PVOID DeletedObject)
 {
@@ -356,7 +336,7 @@ CmiObjectDelete(PVOID DeletedObject)
 static NTSTATUS
 CmiQuerySecurityDescriptor(PKEY_OBJECT KeyObject,
                           SECURITY_INFORMATION SecurityInformation,
-                          PSECURITY_DESCRIPTOR SecurityDescriptor,
+                          PISECURITY_DESCRIPTOR SecurityDescriptor,
                           PULONG BufferLength)
 {
   ULONG_PTR Current;
@@ -470,7 +450,10 @@ CmiObjectSecurity(PVOID ObjectBody,
                  SECURITY_OPERATION_CODE OperationCode,
                  SECURITY_INFORMATION SecurityInformation,
                  PSECURITY_DESCRIPTOR SecurityDescriptor,
-                 PULONG BufferLength)
+                 PULONG BufferLength,
+                 PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
+                 POOL_TYPE PoolType,
+                 PGENERIC_MAPPING GenericMapping)
 {
   DPRINT("CmiObjectSecurity() called\n");
 
@@ -507,49 +490,49 @@ CmiObjectQueryName (PVOID ObjectBody,
                    ULONG Length,
                    PULONG ReturnLength)
 {
-  POBJECT_NAME_INFORMATION LocalInfo;
   PKEY_OBJECT KeyObject;
-  ULONG LocalReturnLength;
   NTSTATUS Status;
 
   DPRINT ("CmiObjectQueryName() called\n");
 
   KeyObject = (PKEY_OBJECT)ObjectBody;
 
-  LocalInfo = ExAllocatePool (NonPagedPool,
-                             sizeof(OBJECT_NAME_INFORMATION) +
-                               MAX_PATH * sizeof(WCHAR));
-  if (LocalInfo == NULL)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
   if (KeyObject->ParentKey != KeyObject)
     {
       Status = ObQueryNameString (KeyObject->ParentKey,
-                                 LocalInfo,
-                                 MAX_PATH * sizeof(WCHAR),
-                                 &LocalReturnLength);
+                                 ObjectNameInfo,
+                                 Length,
+                                 ReturnLength);
     }
   else
     {
       /* KeyObject is the root key */
-      Status = ObQueryNameString (BODY_TO_HEADER(KeyObject)->Parent,
-                                 LocalInfo,
-                                 MAX_PATH * sizeof(WCHAR),
-                                 &LocalReturnLength);
+      Status = ObQueryNameString (HEADER_TO_OBJECT_NAME(BODY_TO_HEADER(KeyObject))->Directory,
+                                 ObjectNameInfo,
+                                 Length,
+                                 ReturnLength);
     }
 
-  if (!NT_SUCCESS (Status))
+  if (!NT_SUCCESS(Status) && Status != STATUS_INFO_LENGTH_MISMATCH)
     {
-      ExFreePool (LocalInfo);
       return Status;
     }
-  DPRINT ("Parent path: %wZ\n", &LocalInfo->Name);
+  (*ReturnLength) += sizeof(WCHAR) + KeyObject->Name.Length;
 
-  Status = RtlAppendUnicodeStringToString (&ObjectNameInfo->Name,
-                                          &LocalInfo->Name);
-  ExFreePool (LocalInfo);
-  if (!NT_SUCCESS (Status))
-    return Status;
+  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 = Length - sizeof(OBJECT_NAME_INFORMATION);
+    }
+
+
+  DPRINT ("Parent path: %wZ\n", ObjectNameInfo->Name);
 
   Status = RtlAppendUnicodeToString (&ObjectNameInfo->Name,
                                     L"\\");
@@ -598,7 +581,7 @@ CmiAddKeyToList(PKEY_OBJECT ParentKey,
   /*      to allow a dichotomic search */
   ParentKey->SubKeys[ParentKey->NumberOfSubKeys++] = NewKey;
 
-  DPRINT("Reference parent key: 0x%x\n", ParentKey);
+  DPRINT("Reference parent key: 0x%p\n", ParentKey);
 
   ObReferenceObjectByPointer(ParentKey,
                STANDARD_RIGHTS_REQUIRED,
@@ -627,7 +610,7 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove)
          ParentKey->NumberOfSubKeys--;
 
          DPRINT("Dereference parent key: 0x%x\n", ParentKey);
-       
+
          ObDereferenceObject(ParentKey);
          return STATUS_SUCCESS;
        }
@@ -645,7 +628,7 @@ CmiScanKeyList(PKEY_OBJECT Parent,
 {
   PKEY_OBJECT CurKey;
   ULONG Index;
-  
+
   DPRINT("Scanning key list for: %wZ (Parent: %wZ)\n",
         KeyName, &Parent->Name);
 
@@ -670,7 +653,7 @@ CmiScanKeyList(PKEY_OBJECT Parent,
            }
        }
     }
-  
+
   if (Index < Parent->NumberOfSubKeys)
   {
      if (CurKey->Flags & KO_MARKED_FOR_DELETE)
@@ -694,7 +677,7 @@ CmiGetLinkTarget(PREGISTRY_HIVE RegistryHive,
                 PKEY_CELL KeyCell,
                 PUNICODE_STRING TargetPath)
 {
-  UNICODE_STRING LinkName = ROS_STRING_INITIALIZER(L"SymbolicLinkValue");
+  UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"SymbolicLinkValue");
   PVALUE_CELL ValueCell;
   PDATA_CELL DataCell;
   NTSTATUS Status;