- Implement CmpQueryKeyName as a wrapper around CmpConstructName helper function (which is stubbed now).

svn path=/trunk/; revision=35705
This commit is contained in:
Aleksey Bragin 2008-08-27 15:55:32 +00:00
parent 0a12af7eab
commit ac962ebea4
3 changed files with 82 additions and 3 deletions

View file

@ -886,6 +886,14 @@ CmpCreateKeyControlBlock(IN PHHIVE Hive,
return Kcb;
}
PUNICODE_STRING
NTAPI
CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
{
UNIMPLEMENTED;
return NULL;
}
VOID
NTAPI
EnlistKeyBodyWithKCB(IN PCM_KEY_BODY KeyBody,

View file

@ -119,9 +119,74 @@ CmpQueryKeyName(IN PVOID ObjectBody,
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

View file

@ -899,6 +899,12 @@ CmpCleanUpSubKeyInfo(
IN PCM_KEY_CONTROL_BLOCK Kcb
);
PUNICODE_STRING
NTAPI
CmpConstructName(
IN PCM_KEY_CONTROL_BLOCK Kcb
);
VOID
NTAPI
CmpDereferenceKeyControlBlockWithLock(