- Don't do ObInsertObject() for a key object, but use CmpCreateHandle() instead.

- Remove some dead code from CmiConnectHive() and move freeing of the create information to a different place.

svn path=/trunk/; revision=27690
This commit is contained in:
Aleksey Bragin 2007-07-15 21:35:16 +00:00
parent 0d051c196e
commit 938646d914
2 changed files with 26 additions and 32 deletions

View file

@ -322,24 +322,6 @@ NtCreateKey(OUT PHANDLE KeyHandle,
goto Cleanup;
}
Status = ObInsertObject((PVOID)KeyObject,
NULL,
DesiredAccess,
0,
NULL,
&hKey);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(KeyObject);
DPRINT1("ObInsertObject() failed!\n");
PostCreateKeyInfo.Object = NULL;
PostCreateKeyInfo.Status = Status;
CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo);
goto Cleanup;
}
KeyObject->ParentKey = Object;
KeyObject->RegistryHive = KeyObject->ParentKey->RegistryHive;
KeyObject->Flags = 0;
@ -398,6 +380,28 @@ NtCreateKey(OUT PHANDLE KeyHandle,
VERIFY_KEY_OBJECT(KeyObject);
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))
{
DPRINT1("ObInsertObject() failed!\n");
PostCreateKeyInfo.Object = NULL;
PostCreateKeyInfo.Status = Status;
CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo);
goto Cleanup;
}
/* Add the keep-alive reference */
ObReferenceObject(KeyObject);
/* Release hive lock */
ExReleaseResourceLite(&CmpRegistryLock);
KeLeaveCriticalRegion();

View file

@ -281,20 +281,6 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
return Status;
}
#if 0
DPRINT("Inserting Key into Object Tree\n");
Status = ObInsertObject((PVOID)NewKey,
NULL,
KEY_ALL_ACCESS,
0,
NULL,
NULL);
DPRINT("Status %x\n", Status);
#else
/* Free the create information */
ObpFreeAndReleaseCapturedAttributes(OBJECT_TO_OBJECT_HEADER(NewKey)->ObjectCreateInfo);
OBJECT_TO_OBJECT_HEADER(NewKey)->ObjectCreateInfo = NULL;
#endif
NewKey->Flags = 0;
NewKey->SubKeyCounts = 0;
NewKey->SubKeys = NULL;
@ -333,6 +319,10 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Free the create information */
ObpFreeAndReleaseCapturedAttributes(OBJECT_TO_OBJECT_HEADER(NewKey)->ObjectCreateInfo);
OBJECT_TO_OBJECT_HEADER(NewKey)->ObjectCreateInfo = NULL;
/* FN1 */
ObReferenceObject (NewKey);