[ros-diffs] [fireball] 35705: - Implement CmpQueryKeyName as a wrapper around CmpConstructName helper function (which is stubbed now).

fireball at svn.reactos.org fireball at svn.reactos.org
Wed Aug 27 17:55:33 CEST 2008


Author: fireball
Date: Wed Aug 27 10:55:32 2008
New Revision: 35705

URL: http://svn.reactos.org/svn/reactos?rev=35705&view=rev
Log:
- Implement CmpQueryKeyName as a wrapper around CmpConstructName helper function (which is stubbed now).

Modified:
    trunk/reactos/ntoskrnl/config/cmkcbncb.c
    trunk/reactos/ntoskrnl/config/cmsysini.c
    trunk/reactos/ntoskrnl/include/internal/cm.h

Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c?rev=35705&r1=35704&r2=35705&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] Wed Aug 27 10:55:32 2008
@@ -886,6 +886,14 @@
     return Kcb;
 }
 
+PUNICODE_STRING
+NTAPI
+CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
+{
+    UNIMPLEMENTED;
+    return NULL;
+}
+
 VOID
 NTAPI
 EnlistKeyBodyWithKCB(IN PCM_KEY_BODY KeyBody,

Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?rev=35705&r1=35704&r2=35705&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Wed Aug 27 10:55:32 2008
@@ -119,9 +119,74 @@
                 OUT PULONG ReturnLength,
                 IN KPROCESSOR_MODE PreviousMode)
 {
-    DPRINT1("CmpQueryKeyName() called\n");
-    ASSERT(FALSE);
-    return STATUS_SUCCESS;
+    PUNICODE_STRING KeyName;
+    NTSTATUS Status = STATUS_SUCCESS;
+    PCM_KEY_BODY KeyBody = (PCM_KEY_BODY)ObjectBody;
+    PCM_KEY_CONTROL_BLOCK Kcb = KeyBody->KeyControlBlock;
+
+    /* Acquire hive lock */
+    CmpLockRegistry();
+
+    /* Lock KCB shared */
+    CmpAcquireKcbLockShared(Kcb);
+
+    /* Check if it's a deleted block */
+    if (Kcb->Delete)
+    {
+        /* Release the locks */
+        CmpReleaseKcbLock(Kcb);
+        CmpUnlockRegistry();
+
+        /* Let the caller know it's deleted */
+        return STATUS_KEY_DELETED;
+    }
+
+    /* Get the name */
+    KeyName = CmpConstructName(Kcb);
+
+    /* Release the locks */
+    CmpReleaseKcbLock(Kcb);
+    CmpUnlockRegistry();
+
+    /* Check if we got the name */
+    if (!KeyName) return STATUS_INSUFFICIENT_RESOURCES;
+
+    /* Set the returned length */
+    *ReturnLength = KeyName->Length + sizeof(OBJECT_NAME_INFORMATION) + sizeof(WCHAR);
+
+    /* Check if it fits into the provided buffer */
+    if ((Length < sizeof(OBJECT_NAME_INFORMATION)) ||
+        (Length < (*ReturnLength - sizeof(OBJECT_NAME_INFORMATION))))
+    {
+        /* Free the buffer allocated by CmpConstructName */
+        ExFreePool(KeyName->Buffer);
+
+        /* Return buffer length failure */
+        return STATUS_INFO_LENGTH_MISMATCH;
+    }
+
+    /* Fill in the result */
+    _SEH_TRY
+    {
+        /* Return data to user */
+        ObjectNameInfo->Name.Buffer = (PWCHAR)(ObjectNameInfo + 1);
+        ObjectNameInfo->Name.MaximumLength = KeyName->Length;
+        ObjectNameInfo->Name.Length = KeyName->Length;
+
+        /* Copy string content*/
+        RtlCopyMemory(ObjectNameInfo->Name.Buffer, KeyName->Buffer, *ReturnLength);
+    }
+    _SEH_HANDLE
+    {
+        /* Get the status */
+        Status = _SEH_GetExceptionCode();
+    }
+    _SEH_END;
+
+    /* Free the buffer allocated by CmpConstructName */
+    ExFreePool(KeyName->Buffer);
+
+    return Status;
 }
 
 NTSTATUS

Modified: trunk/reactos/ntoskrnl/include/internal/cm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/cm.h?rev=35705&r1=35704&r2=35705&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] Wed Aug 27 10:55:32 2008
@@ -896,6 +896,12 @@
 VOID
 NTAPI
 CmpCleanUpSubKeyInfo(
+    IN PCM_KEY_CONTROL_BLOCK Kcb
+);
+
+PUNICODE_STRING
+NTAPI
+CmpConstructName(
     IN PCM_KEY_CONTROL_BLOCK Kcb
 );
 



More information about the Ros-diffs mailing list